Changeset 5719 for ComponentRegistry
- Timestamp:
- 10/15/14 15:22:05 (10 years ago)
- Location:
- ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/ComponentRegistryRestService.java
r5717 r5719 200 200 return new ArrayList<ComponentDescription>(); 201 201 202 203 202 203 204 204 } catch (ItemNotFoundException e) { 205 205 response.sendError(Status.NOT_FOUND.getStatusCode(), e.toString()); … … 241 241 response.sendError(Status.FORBIDDEN.getStatusCode(), e.toString()); 242 242 return new ArrayList<ProfileDescription>(); 243 244 243 244 245 245 } catch (ItemNotFoundException e) { 246 246 response.sendError(Status.NOT_FOUND.getStatusCode(), e.toString()); … … 1538 1538 } 1539 1539 1540 private String helpToMakeTitleForRssDescriptions(String registrySpace, String groupId, String resource) { 1541 if (registrySpace == null || (registrySpace.equalsIgnoreCase("group") && groupId == null) 1542 || resource == null) { 1543 return "Undefined registry space or uindefined type of resource"; 1544 } 1545 if (registrySpace.equalsIgnoreCase("published")) { 1546 return "Published " + resource; 1547 } 1548 if (registrySpace.equalsIgnoreCase("private")) { 1549 return "Private " + resource; 1550 } 1551 if (registrySpace.equalsIgnoreCase("group") && groupId != null) { 1552 return resource + " of group " + groupId; 1553 } 1554 1555 return "Undefined registry space or uindefined type of resource"; 1556 } 1557 1540 1558 /** 1541 1559 * … … 1567 1585 response.sendError(Status.FORBIDDEN.getStatusCode(), e.toString()); 1568 1586 return new Rss(); 1569 } 1570 catch (ItemNotFoundException e) { 1587 } catch (ItemNotFoundException e) { 1571 1588 response.sendError(Status.NOT_FOUND.getStatusCode(), e.toString()); 1572 1589 return new Rss(); 1573 1590 } 1574 1591 // obsolete, add group Id 1575 final RssCreatorDescriptions instance = new RssCreatorDescriptions(!registrySpace.equalsIgnoreCase("published"), getApplicationBaseURI(), "components", 1592 String title = this.helpToMakeTitleForRssDescriptions(registrySpace, groupId, "Components"); 1593 final RssCreatorDescriptions instance = new RssCreatorDescriptions(getApplicationBaseURI(), "components", 1576 1594 Integer.parseInt(limit), components, 1577 BaseDescription.COMPARE_ON_DATE );1595 BaseDescription.COMPARE_ON_DATE, title); 1578 1596 final Rss rss = instance.getRss(); 1579 1597 LOG.debug("Releasing RSS of {} most recently registered components", … … 1611 1629 response.sendError(Status.FORBIDDEN.getStatusCode(), e.toString()); 1612 1630 return new Rss(); 1613 1631 1614 1632 } catch (ItemNotFoundException e) { 1615 1633 response.sendError(Status.NOT_FOUND.getStatusCode(), e.toString()); 1616 1634 return new Rss(); 1617 1635 } 1618 final RssCreatorDescriptions instance = new RssCreatorDescriptions(1619 !registrySpace.equalsIgnoreCase("published"),getApplicationBaseURI(), "profiles",1636 String title = this.helpToMakeTitleForRssDescriptions(registrySpace, groupId, "Profiles"); 1637 final RssCreatorDescriptions instance = new RssCreatorDescriptions(getApplicationBaseURI(), "profiles", 1620 1638 Integer.parseInt(limit), profiles, 1621 BaseDescription.COMPARE_ON_DATE );1639 BaseDescription.COMPARE_ON_DATE, title); 1622 1640 final Rss rss = instance.getRss(); 1623 1641 LOG.debug("Releasing RSS of {} most recently registered profiles", 1624 1642 limit); 1625 1643 return rss; 1644 } 1645 1646 private String helpToMakeTitleForRssComments(String itemId, String resource) { 1647 if (itemId == null || resource == null) { 1648 return "Undefined description"; 1649 } 1650 return ("Comments for "+resource+ " "+itemId); 1626 1651 } 1627 1652 … … 1655 1680 final ProfileDescription pd = cr.getProfileDescriptionAccessControlled(profileId); 1656 1681 final String profileName = pd.getName(); 1657 boolean profileIsPrivate = !pd.isPublic();1658 // obsolete, status must be involved, not boolean profileIsPrivate1659 final RssCreatorComments instance = new RssCreatorComments( profileIsPrivate,1682 1683 String title = this.helpToMakeTitleForRssComments(profileId, "profile"); 1684 final RssCreatorComments instance = new RssCreatorComments( 1660 1685 getApplicationBaseURI(), Integer.parseInt(limit), profileId, 1661 profileName, "profile", comments, Comment.COMPARE_ON_DATE );1686 profileName, "profile", comments, Comment.COMPARE_ON_DATE, title); 1662 1687 final Rss rss = instance.getRss(); 1663 1688 LOG.debug("Releasing RSS of {} most recent post on profile {}", limit, … … 1704 1729 final ComponentDescription cd = cr.getComponentDescriptionAccessControlled(componentId); 1705 1730 final String componentName = cd.getName(); 1706 final boolean isPrivate = !cd.isPublic();1707 1731 //oboslete. status must be involved, not boolean isPrivate 1708 final RssCreatorComments instance = new RssCreatorComments(isPrivate, 1732 String title = this.helpToMakeTitleForRssComments(componentId, "component"); 1733 final RssCreatorComments instance = new RssCreatorComments( 1709 1734 getApplicationBaseURI(), Integer.parseInt(limit), componentId, 1710 componentName, "component", comments, Comment.COMPARE_ON_DATE );1735 componentName, "component", comments, Comment.COMPARE_ON_DATE, title); 1711 1736 final Rss rss = instance.getRss(); 1712 1737 LOG.debug("Releasing RSS of {} most recent post on component {}", … … 1889 1914 } catch (ItemNotFoundException e) { 1890 1915 return Response.status(Status.NOT_FOUND).entity(e.getMessage()).build(); 1891 1916 1892 1917 } catch (AuthenticationFailException e) { 1893 1918 return Response.status(Status.UNAUTHORIZED).build(); 1894 1919 } 1895 1920 } 1896 1921 1897 1922 // @Override 1898 1923 // @DELETE … … 1914 1939 // } 1915 1940 // } 1916 1917 1941 @Override 1918 1942 @GET … … 1992 2016 this.strings = strings; 1993 2017 } 1994 1995 1996 2018 } 1997 2019 } -
ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rss/RssCreator.java
r5549 r5719 20 20 private String channelTitle; 21 21 private Comparator<T> comparator; 22 protected final boolean isPrivate;23 22 private List<T> objs; 24 23 private int limit; 25 24 26 protected RssCreator(boolean isPrivate, String baseURI, int limit, List<T> objs) { 27 this.isPrivate = isPrivate; 25 protected RssCreator(String baseURI, int limit, List<T> objs) { 28 26 this.baseURI = baseURI; 29 27 this.limit = limit; -
ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rss/RssCreatorComments.java
r5549 r5719 27 27 * @param comparator compare comments by dates 28 28 */ 29 public RssCreatorComments( boolean isPrivate,String baseURI, int limit,30 String descriptionId, String descriptionName, String descriptionType, List<Comment> comms, Comparator<Comment> comparator ) {31 super( isPrivate,baseURI, limit, comms);32 setChannelLink(baseURI + "?item=" + descriptionId + ((isPrivate) ? "&space=user" : "") +"&browserview=comments");33 setChannelTitle( (isPrivate ? "Private " : "Public ") + descriptionType + " \"" + descriptionName + "\"");29 public RssCreatorComments(String baseURI, int limit, 30 String descriptionId, String descriptionName, String descriptionType, List<Comment> comms, Comparator<Comment> comparator, String title) { 31 super(baseURI, limit, comms); 32 setChannelLink(baseURI + "?item=" + descriptionId + "&browserview=comments"); 33 setChannelTitle(title); 34 34 setChannelDescription(String.format("Comments feed for the %s \"%s\"", descriptionType, descriptionName)); 35 35 setComparator(comparator); -
ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rss/RssCreatorDescriptions.java
r5549 r5719 23 23 * @param comparator compare descriptions by dates 24 24 */ 25 public RssCreatorDescriptions( boolean isPrivate,String baseURI, String descriptionType,26 int limit, List<T> descriptions, Comparator<T> comparator ) {27 super( isPrivate,baseURI, limit, descriptions);25 public RssCreatorDescriptions(String baseURI, String descriptionType, 26 int limit, List<T> descriptions, Comparator<T> comparator, String title) { 27 super(baseURI, limit, descriptions); 28 28 setChannelLink(baseURI + "/"); 29 setChannelTitle( (isPrivate ? "Private " : "Public ") + descriptionType);29 setChannelTitle(title); 30 30 setChannelDescription(String.format("News feed for the %s", descriptionType)); 31 31 setComparator(comparator); … … 41 41 @Override 42 42 protected RssItem fromArgToRssItem(T desc) { 43 String href = getBaseURI() + "?item=" + desc.getId() + (isPrivate ? "&space=user" : "");43 String href = getBaseURI() + "?item=" + desc.getId(); 44 44 RssItem retval = new RssItem(); 45 45 retval.setDescription(desc.getDescription());
Note: See TracChangeset
for help on using the changeset viewer.