Changeset 2252
- Timestamp:
- 09/25/12 16:35:46 (12 years ago)
- Location:
- ComponentRegistry/branches/ComponentRegistry-1.13.0-olha/ComponentRegistry
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
ComponentRegistry/branches/ComponentRegistry-1.13.0-olha/ComponentRegistry/pom.xml
r2248 r2252 342 342 <!-- <bindingDirectory>${basedir}/src/generated/jaxb/rss</bindingDirectory> --> 343 343 <bindingDirectory>src/main/binding/rss</bindingDirectory> 344 <bindingIncludes>345 <include>bindings.xml346 </include>347 </bindingIncludes>348 344 349 <args>350 <arg>-extension</arg>351 <arg>-Xnamespace-prefix</arg>352 </args>353 <!-- <extension>true</extension> -->354 345 <generateDirectory>${basedir}/src/generated/jaxb/rss</generateDirectory> 355 346 <generatePackage>clarin.cmdi.componentregistry.rss</generatePackage> … … 360 351 </execution> 361 352 </executions> 362 <dependencies>363 <dependency>364 <groupId>org.jvnet.jaxb2_commons</groupId>365 <artifactId>jaxb2-namespace-prefix</artifactId>366 <version>1.1</version>367 </dependency>368 <dependency>369 <groupId>com.sun.xml.bind</groupId>370 <artifactId>jaxb-impl</artifactId>371 <version>2.2.6</version>372 </dependency>373 </dependencies>374 353 </plugin> 375 354 <plugin> -
ComponentRegistry/branches/ComponentRegistry-1.13.0-olha/ComponentRegistry/src/main/binding/rss/rss-2_0.xsd
r2248 r2252 40 40 --> 41 41 <xs:schema 42 xmlns:dc="http://purl.org/dc/elements/1.1/"43 xmlns:atom="http://www.w3.org/2005/Atom"44 42 xmlns:xs="http://www.w3.org/2001/XMLSchema" 45 43 elementFormDefault="unqualified" … … 57 55 58 56 59 <xs:import namespace="http://purl.org/dc/elements/1.1/" 60 schemaLocation="http://dublincore.org/schemas/xmls/simpledc20021212.xsd"/> 61 62 <xs:import namespace="http://www.w3.org/2005/Atom" 63 schemaLocation="http://dataconnector.eea.europa.eu/wise/bwqd/atom.xsd"/> 64 <!-- Possible schemaLocation for Atom: 65 "http://www.w3.org/2005/Atom http://www.openarchives.org/OAI/2.0/atom_entry.xsd" : was not found 66 "http://dataconnector.eea.europa.eu/wise/bwqd/atom.xsd" - currently it is there 67 http://dataconnector.eea.europa.eu/wise/bwqd/atom.xsd - not checked --> 68 69 57 70 58 <xs:element name="rss"> 71 59 <xs:complexType> … … 95 83 <xs:element name="link" type="xs:anyURI" minOccurs="0"> 96 84 </xs:element> 97 <xs:element ref="dc:creator"></xs:element>98 <!--99 The value for "author" must be an e-mail,100 otherwise the rss-feed will not be validated.101 Sunce we want to have just the author's name there,102 we must use the element103 dc:creator104 <xs:element name="author" type="xs:string" minOccurs="0" nillable="false">105 <xs:annotation>106 <xs:documentation>The name of the author of the item.</xs:documentation>107 </xs:annotation>108 </xs:element> -->109 85 <xs:element name="category" type="Category" minOccurs="0"> 110 86 <xs:annotation> … … 130 106 <xs:annotation> 131 107 <xs:documentation>Indicates when the item was published.</xs:documentation> 132 </xs:annotation>133 </xs:element>134 <xs:element name="source" type="Source" minOccurs="0">135 <xs:annotation>136 <xs:documentation>The RSS channel that the item came from.</xs:documentation>137 108 </xs:annotation> 138 109 </xs:element> … … 152 123 </xs:annotation> 153 124 </xs:element> 154 < !-- <xs:element name="link" type="xs:anyURI">125 <xs:element name="link" type="xs:anyURI"> 155 126 <xs:annotation> 156 127 <xs:documentation>The URL to the HTML website corresponding to the channel.</xs:documentation> 157 128 </xs:annotation> 158 </xs:element> -->129 </xs:element> 159 130 <xs:element name="description" type="xs:string"> 160 131 <xs:annotation> … … 242 213 </xs:annotation> 243 214 </xs:element> 244 <xs:element ref="atom:link" ></xs:element>245 215 <xs:element name="item" type="RssItem" minOccurs="1" maxOccurs="unbounded"> 246 216 <!-- -
ComponentRegistry/branches/ComponentRegistry-1.13.0-olha/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/RssCreator.java
r2247 r2252 3 3 import clarin.cmdi.componentregistry.rss.Category; 4 4 import clarin.cmdi.componentregistry.rss.Cloud; 5 import clarin.cmdi.componentregistry.rss.ElementType;6 5 import clarin.cmdi.componentregistry.rss.Guid; 7 6 import clarin.cmdi.componentregistry.rss.Image; 8 import clarin.cmdi.componentregistry.rss.Link;9 7 import clarin.cmdi.componentregistry.rss.Rss; 10 8 import clarin.cmdi.componentregistry.rss.RssChannel; … … 30 28 // all the fields below are not mandatory, no crashes will happen if they are not set 31 29 private String title; 32 private String href;30 private String link; 33 31 private String description; 34 32 private String language; … … 79 77 */ 80 78 public void setLink(String value) { 81 this. href= value;79 this.link = value; 82 80 } 83 81 … … 270 268 channel.setLanguage(language); 271 269 channel.setLastBuildDate(lastBuildDate); 272 channel.setLink( makeLink(href));270 channel.setLink(link); 273 271 channel.setManagingEditor(managingEditor); 274 272 channel.setPubDate(pubDate); … … 288 286 289 287 290 // QName x= new QName("xmlns:dc");291 292 293 // rss.getOtherAttributes().put(x, "http://purl.org/dc/elements/1.1");294 295 296 288 297 289 for (RssItem currentItem : rssItems) { … … 318 310 return (makeRssChannel(makeListOfRssItems(objs))); 319 311 } 312 320 313 321 314 protected String getRFCDateTime(String datestring) throws ParseException { … … 326 319 } 327 320 328 protected ElementType makeElementType(String username) {329 ElementType result = new ElementType();330 result.setValue(username);331 result.setLang(null);332 return result;333 }334 321 335 322 protected Guid makeGuid(String id){ 336 323 Guid result = new Guid(); 337 324 result.setIsPermaLink(null); … … 340 327 } 341 328 342 protected Link makeLink(String href){343 344 Link lnk = new Link();345 lnk.setHref(href);346 //rel="self" type="application/rss+xml347 lnk.setRel("self");348 return lnk;349 350 351 }352 329 } -
ComponentRegistry/branches/ComponentRegistry-1.13.0-olha/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/RssCreatorDescriptions.java
r2247 r2252 6 6 7 7 import clarin.cmdi.componentregistry.model.AbstractDescription; 8 import clarin.cmdi.componentregistry.rss.ElementType;9 8 import clarin.cmdi.componentregistry.rss.RssItem; 10 9 … … 23 22 RssItem retval = new RssItem(); 24 23 24 //Description (blah-blah) 25 retval.setDescription(desc.getDescription()); 25 26 27 28 //guid 29 retval.setGuid(makeGuid(desc.getHref())); 26 30 27 retval.setCreator(makeElementType(desc.getCreatorName())); 28 // retval.setCategory(desc.???); 29 // retval.setComments(desc.???); 30 retval.setDescription(desc.getDescription()); 31 //retval.setEnclosure(desc.???); 31 //time-date 32 retval.setPubDate(desc.getRegistrationDate()); 32 33 33 String message ="The is of the"; 34 if (desc.isProfile()) {message = message +"profile is ";} 35 else {message = message +"component is ";} 36 retval.setGuid(makeGuid(message+desc.getId())); 37 38 retval.setLink(desc.getHref()); 39 retval.setPubDate(desc.getRegistrationDate()); 40 //retval.setSource(desc.???); 41 retval.setTitle(desc.getName()); 34 //Title 35 retval.setTitle(makeDescriptionTitle(desc.getName(),desc.getCreatorName(), desc.getGroupName(),desc.getDomainName())); 42 36 43 37 … … 46 40 } 47 41 48 42 protected String makeDescriptionTitle(String name, String creatorname, String group, String domain){ 43 String retval = name+"by user"+creatorname+", group "+group+",domain "+domain; 44 45 return retval; 46 } 49 47 } -
ComponentRegistry/branches/ComponentRegistry-1.13.0-olha/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/ComponentRegistryRestService.java
r2248 r2252 7 7 import clarin.cmdi.componentregistry.ComponentStatus; 8 8 import clarin.cmdi.componentregistry.DeleteFailedException; 9 import clarin.cmdi.componentregistry.ExtendedComment; 9 10 import clarin.cmdi.componentregistry.MDMarshaller; 10 11 import clarin.cmdi.componentregistry.Owner; … … 983 984 RssCreatorDescriptions rssCreator = new RssCreatorDescriptions(); 984 985 rssCreator.setVersion(2.0); 986 987 985 988 int limitInt = Integer.parseInt(limit); 986 989 … … 1055 1058 1056 1059 1057 // TODO: add sorting and limiting items per page!1060 // TODO: add sorting ! 1058 1061 1059 1062 final Principal principal = security.getUserPrincipal(); 1060 1063 List<Comment> comments = getRegistry(getStatus(userspace)).getCommentsInProfile(profileId, principal); 1061 1064 1065 1062 1066 int limitInt = Integer.parseInt(limit); 1063 1067 1064 1068 if (comments.size()<limitInt) {limitInt = comments.size();}; 1065 List<Comment> sublist = comments.subList(0, limitInt); 1069 List<Comment> sublistAux = comments.subList(0, limitInt); 1070 1071 String href = getRegistry(getStatus(userspace)).getProfileDescription(profileId).getHref(); 1072 1073 List<ExtendedComment> sublist = new ArrayList<ExtendedComment>(); 1074 for (Comment currentcom : sublistAux) { 1075 ExtendedComment currentextcom = new ExtendedComment(); 1076 currentextcom.setCom(currentcom); 1077 currentextcom.setHref(href); 1078 sublist.add(currentextcom); 1079 } 1066 1080 1067 1081 … … 1069 1083 instance.setFlagIsFromProfile(true); 1070 1084 instance.setDescription("Update of comments for current profile"); 1071 instance.setLink("http://www.clarin.eu/cmdi/profiles/"); 1072 instance.setTitle("Comments feed for the profile"+profileId); 1073 1074 1085 instance.setTitle("Comments feed for the profile "+profileId); 1086 1087 Rss result = instance.makeRss(sublist); 1075 1088 1076 1089 //this is a testing piece testing piece: prints out on tomcat's output terminal the comments … … 1080 1093 System.out.println("Name: "+ registry.getName()); 1081 1094 System.out.println("Owner: "+ registry.getOwner()); 1082 for (Comment comment : sublist ){1095 for (Comment comment : sublistAux){ 1083 1096 System.out.println(comment.getComment()); 1084 1097 System.out.println(comment.getCommentDate()); … … 1094 1107 1095 1108 1096 Rss result = instance.makeRss(comments);1109 1097 1110 1098 1111 // testing stuff -
ComponentRegistry/branches/ComponentRegistry-1.13.0-olha/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/RssCreatorCommentsTest.java
r2247 r2252 22 22 23 23 24 private Comment makeTestComment(boolean flag, String comtext, String date, String commentDescrId,25 String id, String profileDescrId, String userId, String userName){24 private Comment makeTestComment(boolean canDelete, boolean isFromProfile, String comtext, String date, String commentId, 25 String descrId, String userName){ 26 26 27 27 Comment comm =new Comment(); 28 28 29 comm.setCanDelete( flag);29 comm.setCanDelete(canDelete); 30 30 comm.setComment(comtext); 31 31 comm.setCommentDate(date); 32 comm.setComponentDescriptionId(commentDescrId); 33 comm.setId(id); 34 comm.setProfileDescriptionId(profileDescrId); 35 comm.setUserId(userId); 32 if (isFromProfile) {comm.setComponentDescriptionId(descrId);} 33 else {comm.setProfileDescriptionId(descrId);} 34 comm.setId(commentId); 36 35 comm.setUserName(userName); 37 36 … … 44 43 */ 45 44 46 private void compareInputsVsRssItems(String userName, String commtext, String date, String title, RssItem rssItem){45 private void compareInputsVsRssItems(String href, String commtext, String date, String title, RssItem rssItem){ 47 46 48 47 49 assertEquals( userName, rssItem.getCreator().getValue());48 assertEquals(href, rssItem.getGuid().getValue()); 50 49 assertEquals(commtext, rssItem.getDescription()); 51 50 assertEquals(date, rssItem.getPubDate()); … … 59 58 public void testMakeRss() throws ParseException{ 60 59 60 String href = "http"; 61 Boolean isFromProfile = true; 61 62 62 Comment comm1 = makeTestComment(true, "this is comment # 1", "2012-04-02T11:38:23+00:00", "DescrId1",63 "Id1", "ProfileDescId1", "us1","userello");63 Comment comm1 = makeTestComment(true, isFromProfile, "this is comment # 1", "2012-04-02T11:38:23+00:00", "commentId1", "DescrId1", 64 "userello"); 64 65 65 Comment comm2 = makeTestComment(false, "this is comment # 2", "2012-05-02T12:38:23+00:00", "DescrId2",66 "Id2", "ProfileDescId2", "us2","userino");66 Comment comm2 = makeTestComment(false, isFromProfile, "this is comment # 2", "2011-04-02T11:38:22+00:00", "commentId2", "DescrId2", 67 "userino"); 67 68 68 Comment comm3 = makeTestComment(true, "this is comment # 3", "2012-04-07T11:38:23+01:00", "DescrId3",69 "Id3", "ProfileDescId3", "us3","userito");69 Comment comm3 = makeTestComment(true, isFromProfile, "this is comment # 3", "2010-05-02T11:38:22+00:00", "commentId3", "DescrId3", 70 "userito"); 70 71 71 72 Comment[] commar = {comm1, comm2, comm3}; 72 73 List<Comment> comms = new ArrayList<Comment>(Arrays.asList(commar)); 73 74 75 List<ExtendedComment> extcomms = new ArrayList<ExtendedComment>(); 76 for (Comment currentcom : comms){ 77 ExtendedComment currentextcom = new ExtendedComment(); 78 currentextcom.setCom(currentcom); 79 currentextcom.setHref(href); 80 extcomms.add(currentextcom); 81 } 82 74 83 RssCreatorComments instance = new RssCreatorComments(); 75 84 assertEquals(Double.toString(instance.getVersion()) , "2.0"); // check if the default version is set properly 76 85 77 instance.setFlagIsFromProfile( true);86 instance.setFlagIsFromProfile(isFromProfile); 78 87 instance.setVersion(3.0); 79 88 80 Rss result = instance.makeRss( comms);89 Rss result = instance.makeRss(extcomms); 81 90 82 91 assertEquals(Double.toString(result.getVersion()), "3.0"); // now, check if updating version has taken place 83 92 84 93 String rfcdate1 = instance.getRFCDateTime("2012-04-02T11:38:23+00:00"); 85 String rfcdate2 = instance.getRFCDateTime("201 2-05-02T12:38:23+00:00");86 String rfcdate3 = instance.getRFCDateTime("201 2-04-07T11:38:23+01:00");94 String rfcdate2 = instance.getRFCDateTime("2011-04-02T11:38:22+00:00"); 95 String rfcdate3 = instance.getRFCDateTime("2010-05-02T11:38:22+00:00"); 87 96 88 97 List<RssItem> resitems = result.getChannel().getItem(); 89 compareInputsVsRssItems("userello", "this is comment # 1", rfcdate1 , "The comment in ProfileDescId1.", resitems.get(0)); 90 compareInputsVsRssItems("userino", "this is comment # 2", rfcdate2, "The comment in ProfileDescId2.", resitems.get(1)); 91 compareInputsVsRssItems("userito", "this is comment # 3", rfcdate3, "The comment in ProfileDescId3.", resitems.get(2)); 98 compareInputsVsRssItems(href, "this is comment # 1", rfcdate1, 99 instance.makeCommentTitle("commentId1", "descrId1", "userello"), resitems.get(0)); 100 compareInputsVsRssItems(href, "this is comment # 2", rfcdate2, 101 instance.makeCommentTitle("commentId2", "descrId2", "userino"), 102 resitems.get(1)); 103 compareInputsVsRssItems(href, "this is comment # 3", rfcdate3, 104 instance.makeCommentTitle("commentId3", "descrId3", "userito") 105 , resitems.get(2)); 92 106 93 107 94 System.out.println(resitems.get(0).getPubDate()); 95 System.out.println("hallo"); 108 96 109 } 97 110 -
ComponentRegistry/branches/ComponentRegistry-1.13.0-olha/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/RssCreatorDescriptionsTest.java
r2247 r2252 47 47 48 48 private void createTestDescription(AbstractDescription desc, int commentcount, String creatorname, 49 String description, String domainname, String groupname, String href,50 String name, String uid, String date) {49 String description, String domainname, String groupname, 50 String name, String date, String href) { 51 51 52 52 desc.setCommentsCount(commentcount); … … 55 55 desc.setDomainName(domainname); 56 56 desc.setGroupName(groupname); 57 desc.setName(name); 58 desc.setRegistrationDate(date); 57 59 desc.setHref(href); 58 desc.setName(name);59 desc.setUserId(uid);60 desc.setRegistrationDate(date);61 60 62 61 } 63 62 64 63 private ProfileDescription createTestProfileDescription(int commentcount, String creatorname, 65 String description, String domainname, String groupname, String href,66 String name, boolean editorFlag, String uid, String date) {64 String description, String domainname, String groupname, 65 String name, boolean editorFlag, String date, String href) { 67 66 68 67 ProfileDescription pdesc = ProfileDescription.createNewDescription(); 69 68 70 createTestDescription(pdesc, commentcount, creatorname, description, domainname, groupname, href, name, uid, date);69 createTestDescription(pdesc, commentcount, creatorname, description, domainname, groupname, name, date, href); 71 70 72 71 pdesc.setShowInEditor(editorFlag); … … 78 77 79 78 private ComponentDescription createTestComponentDescription(int commentcount, String creatorname, 80 String description, String domainname, String groupname, String href,81 String name, String uid, String date) {79 String description, String domainname, String groupname, 80 String name, String date, String href) { 82 81 83 82 ComponentDescription cdesc = ComponentDescription.createNewDescription(); 84 83 85 createTestDescription(cdesc, commentcount, creatorname, description, domainname, groupname, href, name, uid, date);84 createTestDescription(cdesc, commentcount, creatorname, description, domainname, groupname, name, date, href); 86 85 87 86 return cdesc; … … 91 90 92 91 ////////////////////////////////////// 93 private void compareRssVsValues(String creatorname, String description, String href, String date, String nametitle, RssItem item) {94 assertEquals(creatorname, item.getCreator().getValue());92 private void compareRssVsValues(String description, String href, String date, String title, RssItem item) { 93 95 94 assertEquals(description, item.getDescription()); 96 assertEquals(href, item.get Link());95 assertEquals(href, item.getGuid().getValue() ); 97 96 assertEquals(date, item.getPubDate()); 98 assertEquals( nametitle, item.getTitle());97 assertEquals(title, item.getTitle()); 99 98 } 100 99 … … 106 105 public void testMakeRss() throws JAXBException, UnsupportedEncodingException, IOException, ParseException{ 107 106 107 String href="http"; 108 108 109 110 ProfileDescription desc1 = createTestProfileDescription(23, "Joe Unit", 111 "description-1", "domainname-1", "groupname-1", "href-1", "titlename-1", true, "uid1", "2001-01-01"); 109 ProfileDescription desc1 = createTestProfileDescription(23, "Creator 1", 110 "description-1", "domainname-1", "groupname-1", "name-1", true, "2001-01-01", href); 112 111 113 ProfileDescription desc2 = createTestProfileDescription(23, " Joe Unit",114 "description-2", "domainname-2", "groupname-2", " href-2", "titlename-2", false, "uid-2", "2001-01-02");112 ProfileDescription desc2 = createTestProfileDescription(23, "Creator 2", 113 "description-2", "domainname-2", "groupname-2", "name-2", false, "2001-01-02", href); 115 114 116 ProfileDescription desc3 = createTestProfileDescription(23, " Terminator",117 "description-3", "domainname-3", "groupname-3", " href-3", "titlename-3", true, "uid-3", "2001-01-03");115 ProfileDescription desc3 = createTestProfileDescription(23, "Creator 3", 116 "description-3", "domainname-3", "groupname-3", "name-3", true, "2001-01-03", href); 118 117 119 118 List<ProfileDescription> descriptions = Arrays.asList(desc1, desc2, desc3); … … 126 125 instance.setVersion(2.0); 127 126 127 instance.setLink(href); 128 128 instance.setCategory(null); 129 129 instance.setCloud(null); … … 135 135 instance.setLanguage("engl"); 136 136 instance.setLastBuildDate("today"); 137 instance.setLink("link");138 137 instance.setManagingEditor("twan"); 139 138 instance.setPubDate("publication date"); … … 154 153 155 154 // String creatorname, String description, String href, String date, String nametitle, RssItem item 156 compareRssVsValues(" Joe Unit",157 "description-1", "href-1", "2001-01-01", "titlename-1", items.get(0));155 compareRssVsValues("description-1", href, "2001-01-01", 156 instance.makeDescriptionTitle("name-1", "Creator-1", "groupname-1","domainname-1"), items.get(0)); 158 157 159 compareRssVsValues(" Joe Unit",160 "description-2", "href-2", "2001-01-02", "titlename-2", items.get(1));158 compareRssVsValues("description-2", href, "2001-01-02", 159 instance.makeDescriptionTitle("name-2", "Creator-2", "groupname-2","domainname-2"), items.get(1)); 161 160 162 compareRssVsValues(" Terminator",163 "description-3", "href-3", "2001-01-03", "titlename-3", items.get(2));161 compareRssVsValues("description-3", href, "2001-01-03", 162 instance.makeDescriptionTitle("name-3", "Creator-3", "groupname-3","domainname-3"), items.get(2)); 164 163 165 164 … … 176 175 assertEquals("engl", result.getChannel().getLanguage()); 177 176 assertEquals("today", result.getChannel().getLastBuildDate()); 178 assertEquals( "link", result.getChannel().getLink());177 assertEquals(href, result.getChannel().getLink()); 179 178 assertEquals("twan", result.getChannel().getManagingEditor()); 180 179 assertEquals("publication date", result.getChannel().getPubDate()); … … 192 191 } 193 192 194 195 // the test below shows that if we do not set parameters for the channel or no version for Rss 196 // then nothing wrong happen, no null pointer exception, etc. 197 @Test 198 public void testMakeRssNoChannelSet() throws JAXBException, UnsupportedEncodingException, IOException, ParseException{ 199 200 201 ProfileDescription desc1 = createTestProfileDescription(23, "Joe Unit", 202 "description-1", "domainname-1", "groupname-1", "href-1", "titlename-1", true, "uid1", "2001-01-01"); 203 204 List<ProfileDescription> descriptions = Arrays.asList(desc1); 205 206 RssCreatorDescriptions instance = new RssCreatorDescriptions(); 207 Rss result = instance.makeRss(descriptions); 208 209 210 List<RssItem> items = result.getChannel().getItem(); 211 212 assertEquals(1, result.getChannel().getItem().size()); 213 214 // String creatorname, String description, String href, String date, String nametitle, RssItem item 215 compareRssVsValues("Joe Unit", 216 "description-1", "href-1", "2001-01-01", "titlename-1", items.get(0)); 217 218 219 //write the Rss chaneel into the file, so you can see how it looks like in the browser 220 String path=RegistryTestHelper.openTestDir("testRss"); 221 String os = MDMarshaller.marshalToString(result); 222 RegistryTestHelper.writeStringToFile(os, path + "testRssNoChannelSet.xml"); 223 } 224 225 193 226 194 } 227 // String comp1 = "Component1.xml";228 // String path = RegistryTestHelper.openTestDir("MyTestXmls");229 // FileInputStream is1 = new FileInputStream(path + comp1);230 // ComponentDescription desc1 = MDMarshaller.unmarshal(ComponentDescription.class, is1, null);
Note: See TracChangeset
for help on using the changeset viewer.