|
From: <jbo...@li...> - 2006-06-09 16:37:13
|
Author: adamw Date: 2006-06-09 12:37:08 -0400 (Fri, 09 Jun 2006) New Revision: 4696 Removed: labs/shotoku/trunk/shotoku-tags/src/java/org/jboss/shotoku/tags/TagList.java labs/shotoku/trunk/shotoku-tags/src/java/org/jboss/shotoku/tags/TagListImpl.java Modified: labs/shotoku/trunk/shotoku-tags/src/java/org/jboss/shotoku/tags/TagService.java labs/shotoku/trunk/shotoku-tags/src/java/org/jboss/shotoku/tags/service/TagServiceImpl.java labs/shotoku/trunk/shotoku-tags/src/java/org/jboss/shotoku/tags/test/TagsTestServlet.java labs/shotoku/trunk/shotoku-tags/src/java/org/jboss/shotoku/tags/tools/Constants.java Log: http://jira.jboss.com/jira/browse/JBSHOTOKU-86 Deleted: labs/shotoku/trunk/shotoku-tags/src/java/org/jboss/shotoku/tags/TagList.java =================================================================== --- labs/shotoku/trunk/shotoku-tags/src/java/org/jboss/shotoku/tags/TagList.java 2006-06-09 16:27:37 UTC (rev 4695) +++ labs/shotoku/trunk/shotoku-tags/src/java/org/jboss/shotoku/tags/TagList.java 2006-06-09 16:37:08 UTC (rev 4696) @@ -1,11 +0,0 @@ -package org.jboss.shotoku.tags; - -import java.util.List; - -/** - * @author Adam Warski (ad...@as...) - */ -public interface TagList { - public List<Tag> getList(); - public String getFeedAddress(String type); -} Deleted: labs/shotoku/trunk/shotoku-tags/src/java/org/jboss/shotoku/tags/TagListImpl.java =================================================================== --- labs/shotoku/trunk/shotoku-tags/src/java/org/jboss/shotoku/tags/TagListImpl.java 2006-06-09 16:27:37 UTC (rev 4695) +++ labs/shotoku/trunk/shotoku-tags/src/java/org/jboss/shotoku/tags/TagListImpl.java 2006-06-09 16:37:08 UTC (rev 4696) @@ -1,24 +0,0 @@ -package org.jboss.shotoku.tags; - -import java.util.List; - -/** - * @author Adam Warski (ad...@as...) - */ -public class TagListImpl implements TagList { - private List<Tag> list; - private String feedAddress; - - public TagListImpl(List<Tag> list, String feedAddress) { - this.list = list; - this.feedAddress = feedAddress; - } - - public List<Tag> getList() { - return list; - } - - public String getFeedAddress(String type) { - return feedAddress + type; - } -} Modified: labs/shotoku/trunk/shotoku-tags/src/java/org/jboss/shotoku/tags/TagService.java =================================================================== --- labs/shotoku/trunk/shotoku-tags/src/java/org/jboss/shotoku/tags/TagService.java 2006-06-09 16:27:37 UTC (rev 4695) +++ labs/shotoku/trunk/shotoku-tags/src/java/org/jboss/shotoku/tags/TagService.java 2006-06-09 16:37:08 UTC (rev 4696) @@ -4,6 +4,7 @@ import org.jboss.shotoku.tags.exceptions.TagAddException; import org.jboss.shotoku.tags.exceptions.TagDeleteException; import org.jboss.shotoku.tags.exceptions.TagGetException; +import org.jboss.shotoku.tags.tools.FeedType; import java.util.List; @@ -16,8 +17,17 @@ public Tag getTag(String tagName) throws TagGetException; - public TagList getTags(List<String> tagNames) throws TagGetException; - public TagList getTags(String resourceId) throws TagGetException; - public TagList getTagsByAuthor(String author) throws TagGetException; - public TagList getRelatedTags(List<Tag> relateTo) throws TagGetException; + public List<Tag> getTags(List<String> tagNames) throws TagGetException; + public List<Tag> getTags(String resourceId) throws TagGetException; + public List<Tag> getTagsByAuthor(String author) throws TagGetException; + public List<Tag> getRelatedTags(List<Tag> relateTo) throws TagGetException; + + /** + * Gets a link to a tag feed. + * @param feedType Type of the tag feed - resource feed, author feed etc. + * @param data Additinal data - resource id, author name etc. + * @param type Type of the feed - rss2, atom or rdf. + * @return A relative link to a feed with the given parameters. + */ + public String getFeedLink(FeedType feedType, String data, String type); } Modified: labs/shotoku/trunk/shotoku-tags/src/java/org/jboss/shotoku/tags/service/TagServiceImpl.java =================================================================== --- labs/shotoku/trunk/shotoku-tags/src/java/org/jboss/shotoku/tags/service/TagServiceImpl.java 2006-06-09 16:27:37 UTC (rev 4695) +++ labs/shotoku/trunk/shotoku-tags/src/java/org/jboss/shotoku/tags/service/TagServiceImpl.java 2006-06-09 16:37:08 UTC (rev 4696) @@ -25,6 +25,7 @@ import java.util.List; import java.util.ArrayList; import java.net.URLEncoder; +import java.io.UnsupportedEncodingException; import javax.ejb.Local; import javax.persistence.EntityManager; @@ -41,6 +42,7 @@ import org.jboss.shotoku.service.AdministratedService; import org.jboss.shotoku.tags.*; import org.jboss.shotoku.tags.tools.TagTools; +import org.jboss.shotoku.tags.tools.FeedType; import org.jboss.shotoku.tags.exceptions.TagGetException; import org.jboss.shotoku.tags.exceptions.TagAddException; import org.jboss.shotoku.tags.exceptions.TagDeleteException; @@ -174,7 +176,7 @@ } } - public TagList getTags(String resourceId) throws TagGetException { + public List<Tag> getTags(String resourceId) throws TagGetException { try { //noinspection unchecked List<TagEntity> result = manager.createQuery( @@ -186,8 +188,7 @@ ret.add(te.getTag()); } - return new TagListImpl(ret, - "/feeds/tag/resource/" + URLEncoder.encode(resourceId, "UTF-8") + "/"); + return ret; } catch (Throwable e) { throw new TagGetException(e); } @@ -209,15 +210,24 @@ } } - public TagList getTags(List<String> tagNames) throws TagGetException { + public List<Tag> getTags(List<String> tagNames) throws TagGetException { return null; } - public TagList getRelatedTags(List<Tag> relateTo) throws TagGetException { + public List<Tag> getRelatedTags(List<Tag> relateTo) throws TagGetException { return null; } - public TagList getTagsByAuthor(String author) throws TagGetException { + public List<Tag> getTagsByAuthor(String author) throws TagGetException { return null; } + + public String getFeedLink(FeedType feedType, String data, String type) { + try { + return "/feeds/tag/" + feedType.toString() + "/" + + URLEncoder.encode(data, "UTF-8") + "/" + type; + } catch (UnsupportedEncodingException e) { + return ""; + } + } } Modified: labs/shotoku/trunk/shotoku-tags/src/java/org/jboss/shotoku/tags/test/TagsTestServlet.java =================================================================== --- labs/shotoku/trunk/shotoku-tags/src/java/org/jboss/shotoku/tags/test/TagsTestServlet.java 2006-06-09 16:27:37 UTC (rev 4695) +++ labs/shotoku/trunk/shotoku-tags/src/java/org/jboss/shotoku/tags/test/TagsTestServlet.java 2006-06-09 16:37:08 UTC (rev 4696) @@ -32,7 +32,7 @@ } try { - for (Tag t : TagTools.getService().getTags("r1").getList()) { + for (Tag t : TagTools.getService().getTags("r1")) { httpServletResponse.getWriter().println(t.getName() + " - " + t.getData()); } } catch (TagGetException e) { Modified: labs/shotoku/trunk/shotoku-tags/src/java/org/jboss/shotoku/tags/tools/Constants.java =================================================================== --- labs/shotoku/trunk/shotoku-tags/src/java/org/jboss/shotoku/tags/tools/Constants.java 2006-06-09 16:27:37 UTC (rev 4695) +++ labs/shotoku/trunk/shotoku-tags/src/java/org/jboss/shotoku/tags/tools/Constants.java 2006-06-09 16:37:08 UTC (rev 4696) @@ -10,7 +10,4 @@ public static final String WEBSITE_TAG = "website"; public static final String TAG_FEED_TYPE_VARIABLE = "%type%"; - public static final String TAG_FEED_TYPE_RESOURCE = "resource"; - public static final String TAG_FEED_TYPE_AUTHOR = "author"; - public static final String TAG_FEED_TYPE_TAGS = "tags"; } |