find ./ -type f -name "*.jar" -print -exec jar tvf {} \; | less
Sunday, July 27, 2008
Find a class in a lot of JAR files
Where did that class come from? Which JAR do I need to import to resolve this compilation error? Arrgh.
Thursday, July 10, 2008
Example Java code for posting to blogger.com using labels/tags
So I really can't believe how long it took to get this right, but here is some example code for posting to blogger.com with the ability to add some tags or categories or labels.
You just try searching for some code example on how to "post to a blog using tags". Jeez, it took about 45 minutes of searching to find an actual post that WASN'T a blog post that had a tag.
You just try searching for some code example on how to "post to a blog using tags". Jeez, it took about 45 minutes of searching to find an actual post that WASN'T a blog post that had a tag.
public class GoogleBlogPostTest extends TestCase { public void testBlogPost() throws Exception { GoogleService myService = new GoogleService("blogger", "company-xampleApp-1"); myService.setUserCredentials("googleusername", "googlepassword"); String title = "This is my title " + (new Date()).toString(); String blogID = "blognumber"; String contentStr = "This is a test of the emergency blogging system"; String authorName = "Test Author"; String userName = "author@email.com"; String summary = "This is the summary"; ArrayListtags = new ArrayList (); tags.add("News"); tags.add("Alerts"); Entry myEntry = new Entry(); for(String tag : tags) { Category category = new Category(); category.setScheme("http://www.blogger.com/atom/ns#"); category.setTerm(tag); myEntry.getCategories().add(category); } Content content = new TextContent(new PlainTextConstruct(contentStr)); myEntry.setTitle(new PlainTextConstruct(title)); myEntry.setContent(content); Person author = new Person(authorName, "http://flatebo.org", userName); myEntry.getAuthors().add(author); myEntry.setSummary(new PlainTextConstruct(summary)); URL postUrl = new URL("http://www.blogger.com/feeds/" + blogID + "/posts/default"); Entry newEntry = myService.insert(postUrl, myEntry); assertEquals(title, newEntry.getTitle().getPlainText()); } }
Labels:
blogger,
blogger.com,
categories,
frustrating,
gdata,
google,
google API,
java,
labels,
tags
Subscribe to:
Posts (Atom)