Changeset 5834
- Timestamp:
- 11/17/14 10:45:37 (10 years ago)
- Location:
- ComponentRegistry/branches/ComponentRegistry-oauth-1.14.0
- Files:
-
- 13 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
ComponentRegistry/branches/ComponentRegistry-oauth-1.14.0
- Property svn:mergeinfo changed
/ComponentRegistry/branches/ComponentRegistry-schematron reverse-merged: 1775,1777,1796-1797 marked as non-inheritable: 1775,1777,1796-1797 /ComponentRegistry/trunk (added) merged: 5826-5828,5831-5833
- Property svn:mergeinfo changed
-
ComponentRegistry/branches/ComponentRegistry-oauth-1.14.0/ComponentRegistry
- Property svn:mergeinfo changed
/ComponentRegistry/trunk/ComponentRegistry (added) merged: 5826-5828,5832
- Property svn:mergeinfo changed
-
ComponentRegistry/branches/ComponentRegistry-oauth-1.14.0/ComponentRegistry/pom.xml
r5781 r5834 22 22 <packaging>war</packaging> 23 23 <!-- Properties to configure ComponentRegistry override on commandline 24 24 with -D or change here --> 25 25 <serviceRootUrl>http://localhost:8080/${project.artifactId}</serviceRootUrl> 26 26 <!-- Will be inserted in context.xml --> … … 133 133 <exclusions> 134 134 <!-- Jersey has dependencies with different group ids therefore maven 135 136 135 cannot resolve the conflict and gives me both jars (two of stax and two of 136 jaxb-impl). Excluding them manually to overcome the problem --> 137 137 <exclusion> 138 138 <groupId>stax</groupId> … … 146 146 <version>${jersey.version}</version> 147 147 <scope>test</scope> 148 </dependency> 149 <dependency> 150 <groupId>com.wordnik</groupId> 151 <artifactId>swagger-jersey-jaxrs_2.10</artifactId> 152 <version>1.3.0</version> 148 153 </dependency> 149 154 <dependency> … … 539 544 540 545 <!-- 541 542 543 544 545 546 547 548 549 550 551 552 553 554 546 <reporting> 547 <plugins> 548 <plugin> 549 <groupId>org.codehaus.mojo</groupId> 550 <artifactId>findbugs-maven-plugin</artifactId> 551 <version>2.5.4-SNAPSHOT</version> 552 <configuration> 553 <excludeFilterFile>${basedir}/src/main/resources/findbugs-exclude.xml</excludeFilterFile> 554 <threshold>Normal</threshold> 555 <effort>Min</effort> 556 </configuration> 557 </plugin> 558 </plugins> 559 </reporting> 555 560 --> 556 561 <repositories> … … 561 566 </repository> 562 567 <!-- 563 564 565 566 567 568 <repository> 569 <id>sonatype</id> 570 <url>https://oss.sonatype.org/content/groups/public</url> 571 </repository> 572 --> 568 573 </repositories> 569 574 </project> -
ComponentRegistry/branches/ComponentRegistry-oauth-1.14.0/ComponentRegistry/src/main/java
- Property svn:mergeinfo changed
/ComponentRegistry/trunk/ComponentRegistry/src/main/java (added) merged: 5826,5828,5832
- Property svn:mergeinfo changed
-
ComponentRegistry/branches/ComponentRegistry-oauth-1.14.0/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/ComponentRegistryRestService.java
r5823 r5834 31 31 import com.sun.jersey.api.core.InjectParam; 32 32 import com.sun.jersey.multipart.FormDataParam; 33 import com.wordnik.swagger.annotations.ApiOperation; 34 import com.wordnik.swagger.annotations.ApiResponse; 35 import com.wordnik.swagger.annotations.ApiResponses; 33 36 34 37 import java.io.IOException; … … 89 92 public class ComponentRegistryRestService implements 90 93 IComponentRegistryRestService { 91 94 92 95 private final static Logger LOG = LoggerFactory 93 96 .getLogger(ComponentRegistryRestService.class); … … 108 111 @Autowired 109 112 private GroupService groupService; 110 113 111 114 private ComponentRegistry getBaseRegistry() throws AuthenticationRequiredException { 112 115 Principal userPrincipal = security.getUserPrincipal(); … … 118 121 } 119 122 } 120 123 121 124 private ComponentRegistry getRegistry(RegistrySpace space, Number groupId) { 122 125 Principal userPrincipal = security.getUserPrincipal(); … … 145 148 return principal; 146 149 } 147 150 148 151 private UserCredentials getUserCredentials(Principal userPrincipal) { 149 152 UserCredentials userCredentials = null; … … 153 156 return userCredentials; 154 157 } 155 158 156 159 private ComponentRegistry initialiseRegistry(String space, String groupId) throws AuthenticationRequiredException { 157 160 //checking credentials … … 166 169 groupIdNumber = Integer.parseInt(groupId); 167 170 } 168 171 169 172 return this.getRegistry(regSpace, groupIdNumber); 170 173 } 171 174 172 175 private boolean checkRegistrySpaceString(String registrySpace) { 173 176 return (registrySpace.equalsIgnoreCase(REGISTRY_SPACE_GROUP) || registrySpace.equalsIgnoreCase(REGISTRY_SPACE_PRIVATE) || registrySpace.equalsIgnoreCase(REGISTRY_SPACE_PUBLISHED)); 174 177 } 175 178 176 179 @Override 177 180 @GET … … 185 188 throws ComponentRegistryException, IOException { 186 189 long start = System.currentTimeMillis(); 187 190 188 191 // deprecated parameter, processed here for backwards compatibility 189 192 if (!Strings.isNullOrEmpty(userSpace)) { … … 193 196 } 194 197 } 195 198 196 199 if (!checkRegistrySpaceString(registrySpace)) { 197 200 response.sendError(Status.NOT_FOUND.getStatusCode(), "illegal registry space"); 198 201 return new ArrayList<ComponentDescription>(); 199 202 } 200 203 201 204 try { 202 205 ComponentRegistry cr = this.initialiseRegistry(registrySpace, groupId); … … 205 208 "Releasing {} registered components into the world ({} millisecs)", 206 209 result.size(), (System.currentTimeMillis() - start)); 207 210 208 211 return result; 209 212 } catch (AuthenticationRequiredException e) { 210 213 response.sendError(Status.UNAUTHORIZED.getStatusCode(), e.toString()); 211 214 return new ArrayList<ComponentDescription>(); 212 215 213 216 } catch (UserUnauthorizedException e) { 214 217 response.sendError(Status.FORBIDDEN.getStatusCode(), e.toString()); 215 218 return new ArrayList<ComponentDescription>(); 216 219 217 220 } catch (ItemNotFoundException e) { 218 221 response.sendError(Status.NOT_FOUND.getStatusCode(), e.toString()); 219 222 return new ArrayList<ComponentDescription>(); 220 223 } 221 222 } 223 224 225 } 226 224 227 @Override 225 228 @GET … … 234 237 ) 235 238 throws ComponentRegistryException, IOException { 236 239 237 240 long start = System.currentTimeMillis(); 238 241 … … 244 247 } 245 248 } 246 249 247 250 if (!checkRegistrySpaceString(registrySpace)) { 248 251 response.sendError(Status.NOT_FOUND.getStatusCode(), "illegal registry space"); … … 255 258 "Releasing {} registered components into the world ({} millisecs)", 256 259 result.size(), (System.currentTimeMillis() - start)); 257 260 258 261 return result; 259 262 } catch (AuthenticationRequiredException e) { 260 263 response.sendError(Status.UNAUTHORIZED.getStatusCode(), e.toString()); 261 264 return new ArrayList<ProfileDescription>(); 262 265 263 266 } catch (UserUnauthorizedException e) { 264 267 response.sendError(Status.FORBIDDEN.getStatusCode(), e.toString()); 265 268 return new ArrayList<ProfileDescription>(); 266 269 267 270 } catch (ItemNotFoundException e) { 268 271 response.sendError(Status.NOT_FOUND.getStatusCode(), e.toString()); … … 270 273 } 271 274 } 272 275 273 276 @Override 274 277 @GET … … 292 295 } 293 296 } 294 297 295 298 @Override 296 299 @GET … … 298 301 @Produces({MediaType.TEXT_XML, MediaType.APPLICATION_XML, 299 302 MediaType.APPLICATION_JSON}) 303 @ApiOperation(value = "Get the component specification XML a single profile", response = CMDComponentSpec.class) 304 @ApiResponses(value = { 305 @ApiResponse(code = 403, message = "Profile does not exist") 306 }) 300 307 public Response getRegisteredProfile( 301 308 @PathParam("profileId") String profileId) throws IOException { … … 314 321 } 315 322 } 316 323 317 324 @Override 318 325 @GET … … 321 328 public Response getRegisteredComponentRawType( 322 329 @PathParam("componentId") final String componentId, @PathParam("rawType") String rawType) throws ComponentRegistryException { 323 330 324 331 LOG.debug("Component with id: {} and rawType: {} is requested.", componentId, rawType); 325 332 try { … … 356 363 .build()); 357 364 } 358 365 359 366 } catch (UserUnauthorizedException e2) { 360 367 LOG.error(e2.toString()); … … 393 400 LOG.error(e2.toString()); 394 401 } 395 402 396 403 } 397 404 }; … … 400 407 return Response.status(Status.NOT_FOUND).entity("Usupported raw type " + rawType).build(); 401 408 } 402 409 403 410 } catch (UserUnauthorizedException e2) { 404 411 return Response.status(Status.FORBIDDEN).build(); … … 410 417 } 411 418 } 412 419 413 420 @Override 414 421 @GET … … 418 425 public List<BaseDescription> getComponentUsage( 419 426 @PathParam("componentId") String componentId) throws ComponentRegistryException, IOException { 420 427 421 428 final long start = System.currentTimeMillis(); 422 429 try { … … 424 431 List<ComponentDescription> components = registry.getUsageInComponents(componentId); 425 432 List<ProfileDescription> profiles = registry.getUsageInProfiles(componentId); 426 433 427 434 LOG.debug( 428 435 "Found {} components and {} profiles that use component {} ({} millisecs)", 429 436 components.size(), profiles.size(), componentId, 430 437 (System.currentTimeMillis() - start)); 431 438 432 439 List<BaseDescription> usages = new ArrayList<BaseDescription>(components.size() + profiles.size()); 433 440 usages.addAll(components); 434 441 usages.addAll(profiles); 435 442 436 443 return usages; 437 444 } catch (ComponentRegistryException e) { … … 444 451 } 445 452 } 446 453 447 454 @Override 448 455 @GET … … 474 481 } 475 482 } 476 483 477 484 @Override 478 485 @GET … … 504 511 } 505 512 } 506 513 507 514 @Override 508 515 @GET … … 514 521 @PathParam("commentId") String commentId) 515 522 throws IOException { 516 523 517 524 LOG.debug("Comments of profile with id {} are requested.", commentId); 518 525 try { 519 526 520 527 return this.getBaseRegistry().getSpecifiedCommentInProfile(profileId, commentId); 521 528 } catch (ComponentRegistryException e) { … … 533 540 } 534 541 } 535 542 536 543 @Override 537 544 @GET … … 584 591 } 585 592 } 586 593 587 594 @Override 588 595 @POST … … 598 605 } 599 606 } 600 607 601 608 @Override 602 609 @POST … … 625 632 @FormDataParam(GROUP_FORM_FIELD) String group, 626 633 @FormDataParam(DOMAIN_FORM_FIELD) String domainName) { 627 634 628 635 try { 629 636 Principal principal = checkAndGetUserPrincipal(); … … 645 652 .build(); 646 653 } 647 654 648 655 } catch (AuthenticationRequiredException e) { 649 656 return Response.serverError().status(Status.UNAUTHORIZED) … … 661 668 } 662 669 } 663 670 664 671 @Override 665 672 @POST … … 680 687 return Response.status(Status.CONFLICT).entity("Cannot update already published profile.") 681 688 .build(); 682 689 683 690 } 684 691 Number groupId; … … 692 699 space = RegistrySpace.GROUP; 693 700 } 694 701 695 702 updateDescription(desc, name, description, domainName, group); 696 703 ComponentRegistry cr = this.getRegistry(space, groupId); … … 709 716 return Response.serverError().status(Status.INTERNAL_SERVER_ERROR) 710 717 .build(); 711 718 712 719 } catch (UserUnauthorizedException ex) { 713 720 return Response.status(Status.FORBIDDEN).entity(ex.getMessage()) 714 721 .build(); 715 722 716 723 } catch (ItemNotFoundException ex2) { 717 724 return Response.status(Status.NOT_FOUND).entity(ex2.getMessage()) … … 721 728 .build(); 722 729 } 723 730 724 731 } 725 732 … … 760 767 @FormDataParam(GROUP_FORM_FIELD) String group, 761 768 @FormDataParam(DOMAIN_FORM_FIELD) String domainName) { 762 769 763 770 try { 764 771 Principal principal = checkAndGetUserPrincipal(); … … 801 808 } 802 809 } 803 810 804 811 @Override 805 812 @POST … … 831 838 space = RegistrySpace.GROUP; 832 839 } 833 840 834 841 this.updateDescription(desc, name, description, domainName, group); 835 842 ComponentRegistry cr = this.getRegistry(space, groupId); … … 858 865 .build(); 859 866 } 860 861 } 862 867 868 } 869 863 870 private void updateDescription(BaseDescription desc, String name, 864 871 String description, String domainName, String group) { … … 869 876 desc.setRegistrationDate(new Date()); 870 877 } 871 878 872 879 @Override 873 880 @DELETE … … 909 916 .build(); 910 917 } 911 918 912 919 LOG.info("Component with id: {} deleted.", componentId); 913 920 return Response.ok("Component with id" + componentId + " deleted.").build(); 914 921 } 915 922 916 923 @Override 917 924 @DELETE 918 925 @Path("/profiles/{profileId}") 926 @ApiOperation(value = "Deletes a profile from the registry") 927 @ApiResponses(value = { 928 @ApiResponse(code = 401, message = "User is not logged authenticated"), 929 @ApiResponse(code = 403, message = "Profile is not owned by current user and user is no administrator or profile is published and has been consolidated into the registry"), 930 @ApiResponse(code = 404, message = "Profile does not exist") 931 }) 919 932 public Response deleteRegisteredProfile( 920 933 @PathParam("profileId") String profileId) { … … 950 963 .build(); 951 964 } 952 965 953 966 LOG.info("Profile with id: {} deleted.", profileId); 954 967 return Response.ok().build(); 955 968 } 956 969 957 970 @Override 958 971 @DELETE 959 972 @Path("/profiles/{profileId}/comments/{commentId}") 973 @ApiOperation(value = "Deletes a comment from a profile") 974 @ApiResponses(value = { 975 @ApiResponse(code = 401, message = "User is not authenticated"), 976 @ApiResponse(code = 403, message = "Comment is not owned by current user and user is no administrator"), 977 @ApiResponse(code = 404, message = "Comment does not exist") 978 }) 960 979 public Response deleteCommentFromProfile( 961 980 @PathParam("profileId") String profileId, … … 980 999 .entity("" + e1.getMessage()).build(); 981 1000 } 982 1001 983 1002 } catch (DeleteFailedException e) { 984 1003 LOG.info("Comment with id: {} deletion failed: {}", commentId, … … 1005 1024 .build(); 1006 1025 } 1007 1026 1008 1027 LOG.info("Comment with id: {} deleted.", commentId); 1009 1028 return Response.ok("Comment with id " + commentId + " deleted.").build(); 1010 1029 } 1011 1030 1012 1031 @Override 1013 1032 @DELETE 1014 1033 @Path("/components/{componentId}/comments/{commentId}") 1034 @ApiOperation(value = "Deletes a comment from a component") 1035 @ApiResponses(value = { 1036 @ApiResponse(code = 401, message = "User is not authenticated"), 1037 @ApiResponse(code = 403, message = "Comment is not owned by current user and user is no administrator"), 1038 @ApiResponse(code = 404, message = "Comment does not exist") 1039 }) 1015 1040 public Response deleteCommentFromComponent( 1016 1041 @PathParam("componentId") String componentId, … … 1057 1082 .build(); 1058 1083 } 1059 1084 1060 1085 LOG.info("Comment with id: {} deleted.", commentId); 1061 1086 return Response.ok("Comment with id " + commentId + " deleted.").build(); 1062 1087 } 1063 1088 1064 1089 @Override 1065 1090 @GET … … 1069 1094 @PathParam("profileId") final String profileId, 1070 1095 @PathParam("rawType") String rawType) throws ComponentRegistryException, IllegalArgumentException { 1071 1096 1072 1097 LOG.debug("Profile with id {} and rawType {} is requested.", profileId, 1073 1098 rawType); 1074 1099 try { 1075 1100 final ComponentRegistry registry = this.getBaseRegistry(); 1076 1101 1077 1102 ProfileDescription desc = registry.getProfileDescriptionAccessControlled(profileId); 1078 1103 if (desc == null) { 1079 1104 return Response.status(Status.NOT_FOUND).build(); 1080 1105 } 1081 1106 1082 1107 StreamingOutput result = null; 1083 1108 String fileName = desc.getName() + "." + rawType; … … 1131 1156 .build(); 1132 1157 } 1133 1134 } 1135 1158 1159 } 1160 1136 1161 private Response createDownloadResponse(StreamingOutput result, 1137 1162 String fileName) { … … 1144 1169 .entity(result).build(); 1145 1170 return response; 1146 1147 } 1148 1171 1172 } 1173 1149 1174 @Override 1150 1175 @POST … … 1187 1212 } 1188 1213 } 1189 1214 1190 1215 @Override 1191 1216 @POST … … 1228 1253 } 1229 1254 } 1230 1255 1231 1256 @Override 1232 1257 @POST … … 1241 1266 ComponentRegistry registry = this.getBaseRegistry(); 1242 1267 ComponentDescription description = registry.getComponentDescriptionAccessControlled(componentId); 1243 1268 1244 1269 LOG.debug("Trying to register comment to {}", componentId); 1245 1270 1246 1271 return this.registerComment(input, description, registry); 1247 1272 } catch (AuthenticationRequiredException e) { … … 1273 1298 ProfileDescription description = registry 1274 1299 .getProfileDescriptionAccessControlled(profileId); 1275 1300 1276 1301 LOG.debug("Trying to register comment to {}", profileId); 1277 1302 1278 1303 return this.registerComment(input, description, registry); 1279 1304 } catch (AuthenticationRequiredException e) { … … 1289 1314 } 1290 1315 } 1291 1316 1292 1317 @Override 1293 1318 @GET … … 1316 1341 stillActive)).build(); 1317 1342 } 1318 1343 1319 1344 private Response register(InputStream input, BaseDescription desc, RegisterAction action, ComponentRegistry registry) throws UserUnauthorizedException, AuthenticationRequiredException { 1320 1345 try { 1321 1346 1322 1347 DescriptionValidator descriptionValidator = new DescriptionValidator( 1323 1348 desc); … … 1328 1353 this.validate(response, descriptionValidator, validator); 1329 1354 if (response.getErrors().isEmpty()) { 1330 1355 1331 1356 CMDComponentSpec spec = validator.getCMDComponentSpec(); 1332 1357 … … 1334 1359 // recursion over all the components 1335 1360 setFileNamesFromListToNull(Collections.singletonList(spec.getCMDComponent())); 1336 1361 1337 1362 try { 1338 1363 checkForRecursion(validator, registry, desc); … … 1404 1429 } 1405 1430 } 1406 1431 1407 1432 private Response registerComment(InputStream input, BaseDescription description, ComponentRegistry registry) throws UserUnauthorizedException, AuthenticationRequiredException { 1408 1433 try { 1409 1434 CommentValidator validator = new CommentValidator(input, description, marshaller); 1410 1435 CommentResponse responseLocal = new CommentResponse(); 1411 1436 1412 1437 responseLocal.setIsPrivate(!description.isPublic()); 1413 1438 this.validateComment(responseLocal, validator); … … 1469 1494 } 1470 1495 } 1471 1496 1472 1497 private ComponentDescription createNewComponentDescription() { 1473 1498 ComponentDescription desc = ComponentDescription.createNewDescription(); … … 1475 1500 return desc; 1476 1501 } 1477 1502 1478 1503 private ProfileDescription createNewProfileDescription() { 1479 1504 ProfileDescription desc = ProfileDescription.createNewDescription(); … … 1481 1506 return desc; 1482 1507 } 1483 1508 1484 1509 private String createXlink(String id) { 1485 1510 URI uri = uriInfo.getRequestUriBuilder().path(id).build(); … … 1500 1525 return servletContext.getInitParameter(APPLICATION_BASE_URL_PARAM); 1501 1526 } 1502 1527 1503 1528 private void validate(RegisterResponse response, Validator... validators) throws UserUnauthorizedException { 1504 1529 for (Validator validator : validators) { … … 1510 1535 } 1511 1536 } 1512 1537 1513 1538 private void validateComment(CommentResponse response, 1514 1539 Validator... validators) throws UserUnauthorizedException { … … 1539 1564 public void setFileNamesFromListToNull( 1540 1565 List<CMDComponentType> listofcomponents) { 1541 1566 1542 1567 for (CMDComponentType currentcomponent : listofcomponents) { 1543 1568 setFileNamesToNullCurrent(currentcomponent); 1544 1569 } 1545 1570 1546 1571 } 1547 1572 … … 1555 1580 setFileNamesFromListToNull(currentcomponent.getCMDComponent()); 1556 1581 } 1557 1582 1558 1583 private String helpToMakeTitleForRssDescriptions(String registrySpace, String groupId, String resource, ComponentRegistry cr) throws ItemNotFoundException { 1559 1584 if (registrySpace == null || (registrySpace.equalsIgnoreCase(REGISTRY_SPACE_GROUP) && groupId == null) … … 1567 1592 return "Private " + resource; 1568 1593 } 1569 1594 1570 1595 if (registrySpace.equalsIgnoreCase(REGISTRY_SPACE_GROUP) && groupId != null) { 1571 1596 return resource + " of group " + groupId + " '" + cr.getGroupName(Integer.parseInt(groupId)) + "'"; 1572 1597 } 1573 1598 1574 1599 return "Undefined registry space or uindefined type of resource"; 1575 1600 } … … 1610 1635 return new Rss(); 1611 1636 } 1612 1637 1613 1638 final RssCreatorDescriptions instance = new RssCreatorDescriptions(getApplicationBaseURI(), "components", 1614 1639 Integer.parseInt(limit), components, … … 1651 1676 response.sendError(Status.FORBIDDEN.getStatusCode(), e.toString()); 1652 1677 return new Rss(); 1653 1678 1654 1679 } catch (ItemNotFoundException e) { 1655 1680 response.sendError(Status.NOT_FOUND.getStatusCode(), e.toString()); … … 1664 1689 return rss; 1665 1690 } 1666 1691 1667 1692 private String helpToMakeTitleForRssComments(String itemId, String resource) { 1668 1693 if (itemId == null || resource == null) { … … 1695 1720 ParseException { 1696 1721 try { 1697 1722 1698 1723 ComponentRegistry cr = this.getBaseRegistry(); 1699 1724 1700 1725 final List<Comment> comments = cr.getCommentsInProfile(profileId); 1701 1726 final ProfileDescription pd = cr.getProfileDescriptionAccessControlled(profileId); 1702 1727 final String profileName = pd.getName(); 1703 1728 1704 1729 String title = this.helpToMakeTitleForRssComments(profileId, "profile"); 1705 1730 final RssCreatorComments instance = new RssCreatorComments( … … 1769 1794 return new Rss(); 1770 1795 } 1771 1772 } 1773 1796 1797 } 1798 1774 1799 @Override 1775 1800 @GET … … 1777 1802 @Produces({MediaType.TEXT_XML, MediaType.APPLICATION_XML, 1778 1803 MediaType.APPLICATION_JSON}) 1804 @ApiOperation( 1805 value = "A listing of values that are allowed as element or attribute type by the CMDI schema", 1806 response = AllowedAttributetypesXML.class) 1779 1807 public AllowedAttributetypesXML getAllowedAttributeTypes() 1780 1808 throws ComponentRegistryException, IOException, JAXBException, … … 1782 1810 return (new AllowedAttributetypesXML()); 1783 1811 } 1784 1812 1785 1813 @Override 1786 1814 @GET … … 1796 1824 return groups; 1797 1825 } 1798 1826 1799 1827 @Override 1800 1828 @GET … … 1805 1833 return groupService.getGroupsTheItemIsAMemberOf(itemId); 1806 1834 } 1807 1835 1808 1836 @Override 1809 1837 @POST … … 1821 1849 } 1822 1850 } 1823 1851 1824 1852 @Override 1825 1853 @GET … … 1827 1855 @Produces({MediaType.TEXT_XML, MediaType.APPLICATION_XML, 1828 1856 MediaType.APPLICATION_JSON}) 1857 @ApiOperation(value = "The description (metadata) of a single component or profile item") 1858 @ApiResponses(value = { 1859 @ApiResponse(code = 401, message = "User is not authenticated and authentication is required"), 1860 @ApiResponse(code = 403, message = "Item is not accessible to the current user"), 1861 @ApiResponse(code = 404, message = "Item does not exist") 1862 }) 1829 1863 public BaseDescription getBaseDescription(@PathParam("itemId") String itemId) throws ComponentRegistryException, IOException { 1830 1864 LOG.debug("Item with id: {} is requested.", itemId); … … 1842 1876 response.sendError(Status.BAD_REQUEST.getStatusCode()); 1843 1877 return new BaseDescription(); 1844 1878 1845 1879 } catch (UserUnauthorizedException ex2) { 1846 1880 response.sendError(Status.FORBIDDEN.getStatusCode(), ex2.getMessage()); … … 1854 1888 } 1855 1889 } 1856 1857 // Group Service (added by Olha)1858 @Override1859 @POST1860 @Path("/groups/create")1861 @Produces({MediaType.TEXT_XML, MediaType.APPLICATION_XML,1862 MediaType.APPLICATION_JSON})1863 public Response createNewGroup(@QueryParam("groupName") String groupName) throws IOException {1864 1865 try {1866 Principal principal = this.checkAndGetUserPrincipal();1867 Number id = groupService.createNewGroup(groupName, principal.getName());1868 return Response.ok("Group with the name " + groupName + " is created and given an id " + id).build();1869 } catch (AuthenticationRequiredException e) {1870 return Response.status(Status.UNAUTHORIZED).build();1871 }1872 }1873 1874 @Override1875 @GET1876 @Path("/groups/principal")1877 @Produces({MediaType.TEXT_XML, MediaType.APPLICATION_XML,1878 MediaType.APPLICATION_JSON})1879 public List<Group> getGroupsOwnedByUser(@QueryParam("principalName") String pricipalName) throws IOException {1880 1881 try {1882 Principal principal = this.checkAndGetUserPrincipal();1883 return groupService.getGroupsOwnedByUser(principal.getName());1884 } catch (AuthenticationRequiredException e) {1885 response.sendError(Status.UNAUTHORIZED.getStatusCode());1886 return new ArrayList<Group>();1887 }1888 }1889 1890 @Override1891 @GET1892 @Path("/groups/names")1893 public Response listGroupNames() throws IOException {1894 1895 try {1896 Principal principal = this.checkAndGetUserPrincipal();1897 List<String> result = groupService.listGroupNames();1898 //final GenericEntity<List<String>> entity = new GenericEntity<List<String>>(result){};1899 //return Response.status(Status.OK).entity(entity).build();1900 StringsWrapper ids = new StringsWrapper();1901 ids.setStrings(result);1902 return Response.status(Status.OK).entity(ids).build();1903 } catch (AuthenticationRequiredException e) {1904 return Response.status(Status.UNAUTHORIZED).build();1905 }1906 }1907 1908 @Override1909 @GET1910 @Path("/groups/ownership")1911 public Response isOwner(@QueryParam("groupName") String groupName) throws IOException {1912 1913 try {1914 Principal principal = this.checkAndGetUserPrincipal();1915 Boolean isOwner = groupService.isUserOwnerOfGroup(groupName, principal.getName());1916 return Response.ok(isOwner.toString()).build();1917 } catch (AuthenticationRequiredException e) {1918 return Response.serverError().status(Status.UNAUTHORIZED).build();1919 }1920 }1921 1922 @Override1923 @POST1924 @Path("/groups/makemember")1925 @Produces({MediaType.TEXT_XML, MediaType.APPLICATION_XML,1926 MediaType.APPLICATION_JSON})1927 public Response makeGroupMember(@QueryParam("groupName") String groupName, @QueryParam("principalName") String principalName) throws IOException {1928 try {1929 ComponentRegistry registry = this.getBaseRegistry();1930 Number id = registry.makeGroupMember(principalName, groupName);1931 return Response.ok(id.toString()).build();1932 } catch (UserUnauthorizedException e) {1933 return Response.status(Status.FORBIDDEN).entity(e.getMessage()).build();1934 } catch (ItemNotFoundException e) {1935 return Response.status(Status.NOT_FOUND).entity(e.getMessage()).build();1936 1937 } catch (AuthenticationRequiredException e) {1938 return Response.status(Status.UNAUTHORIZED).build();1939 }1940 }1941 1942 // @Override1943 // @DELETE1944 // @Path("/groups/removemember")1945 // @Produces({MediaType.TEXT_XML, MediaType.APPLICATION_XML,1946 // MediaType.APPLICATION_JSON})1947 // public Response removeGroupMember(@QueryParam("groupName") String groupName, @QueryParam("principalName") String principalName) throws IOException {1948 // try {1949 // ComponentRegistry registry = this.getBaseRegistry();1950 // Number id = registry.removeGroupMember(principalName, groupName);1951 // return Response.ok(id.toString()).build();1952 // } catch (UserUnauthorizedException e) {1953 // return Response.status(Status.FORBIDDEN).entity(e.getMessage()).build();1954 // } catch (ItemNotFoundException e) {1955 // return Response.status(Status.NOT_FOUND).entity(e.getMessage()).build();1956 //1957 // } catch (AuthenticationRequiredException e) {1958 // return Response.status(Status.UNAUTHORIZED).build();1959 // }1960 // }1961 @Override1962 @GET1963 @Path("/groups/profiles")1964 public Response listProfiles(@QueryParam(GROUPID_PARAM) String groupId) throws IOException {1965 1966 try {1967 Principal principal = this.checkAndGetUserPrincipal();1968 List<String> result = groupService.getProfileIdsInGroup(Long.parseLong(groupId));1969 StringsWrapper ids = new StringsWrapper();1970 ids.setStrings(result);1971 return Response.status(Status.OK).entity(ids).build();1972 } catch (AuthenticationRequiredException e) {1973 return Response.status(Status.UNAUTHORIZED).build();1974 }1975 }1976 1977 @Override1978 @GET1979 @Path("/groups/components")1980 public Response listComponents(@QueryParam(GROUPID_PARAM) String groupId) throws IOException {1981 1982 try {1983 Principal principal = this.checkAndGetUserPrincipal();1984 List<String> result = groupService.getComponentIdsInGroup(Long.parseLong(groupId));1985 StringsWrapper ids = new StringsWrapper();1986 ids.setStrings(result);1987 return Response.status(Status.OK).entity(ids).build();1988 } catch (AuthenticationRequiredException e) {1989 response.sendError(Status.UNAUTHORIZED.getStatusCode());1990 return Response.status(Status.UNAUTHORIZED).build();1991 }1992 }1993 1994 @Override1995 @GET1996 @Path("/groups/nameById")1997 public Response getGroupNameById(@QueryParam(GROUPID_PARAM) String groupId) throws IOException {1998 1999 try {2000 Principal principal = this.checkAndGetUserPrincipal();2001 String name = groupService.getGroupNameById(Long.parseLong(groupId));2002 return Response.ok(name).build();2003 } catch (AuthenticationRequiredException e) {2004 return Response.status(Status.UNAUTHORIZED).build();2005 } catch (ItemNotFoundException e) {2006 return Response.status(Status.NOT_FOUND).build();2007 }2008 }2009 2010 @Override2011 @GET2012 @Path("/groups/idByName")2013 public Response getGroupIdByName(@QueryParam("groupName") String groupName) throws IOException {2014 2015 try {2016 Principal principal = this.checkAndGetUserPrincipal();2017 Number id = groupService.getGroupIdByName(groupName);2018 return Response.ok(id.toString()).build();2019 } catch (AuthenticationRequiredException e) {2020 return Response.status(Status.UNAUTHORIZED).build();2021 } catch (ItemNotFoundException e) {2022 return Response.status(Status.NOT_FOUND).build();2023 }2024 }2025 2026 @XmlRootElement(name = "Identifiers")2027 public static class StringsWrapper {2028 2029 @XmlElement(name = "item")2030 List<String> strings = new ArrayList<String>();2031 2032 StringsWrapper() {2033 }2034 2035 public void setStrings(List<String> strings) {2036 this.strings = strings;2037 }2038 }2039 1890 } -
ComponentRegistry/branches/ComponentRegistry-oauth-1.14.0/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/IComponentRegistryRestService.java
r5823 r5834 202 202 Response transferItemOwnershipToGroup(String itemId, long groupId) throws IOException; 203 203 204 // (added by Olha)205 Response createNewGroup(String groupName) throws IOException;206 207 List<Group> getGroupsOwnedByUser(String pricipalName) throws IOException;208 209 Response listGroupNames() throws IOException;210 211 Response isOwner(String groupName) throws IOException;212 213 Response makeGroupMember(String groupName, String principalName) throws IOException;214 215 //Response removeGroupMember(String groupName, String principalName) throws IOException;216 Response listProfiles(String groupId) throws IOException;217 218 Response listComponents(String groupId) throws IOException;219 220 Response getGroupNameById(String groupId) throws IOException;221 222 Response getGroupIdByName(String groupName) throws IOException;223 204 } -
ComponentRegistry/branches/ComponentRegistry-oauth-1.14.0/ComponentRegistry/src/main/webapp/WEB-INF/web-shib.xml
r4109 r5834 2 2 3 3 <!-- 4 5 4 Configuration file for ComponentRegistry in shibbolized context, which 5 any production environment should be. 6 6 --> 7 7 8 8 <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 9 xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">9 xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> 10 10 <display-name>ComponentRegistry</display-name> 11 11 <description>Clarin Metadata Component Registry</description> … … 17 17 </context-param> 18 18 <context-param> 19 20 21 22 19 <param-name>contextConfigLocation</param-name> 20 <param-value>classpath:spring-config/applicationContext.xml,classpath:spring-config/container-environment.xml 21 </param-value> 22 </context-param> 23 23 24 24 <listener> … … 36 36 </init-param> 37 37 </filter> 38 39 40 41 42 43 44 45 38 <filter> 39 <filter-name>NoCachingFilter</filter-name> 40 <filter-class>clarin.cmdi.componentregistry.servlet.DontCacheFilter</filter-class> 41 </filter> 42 <filter-mapping> 43 <filter-name>NoCachingFilter</filter-name> 44 <url-pattern>/rest/registry/*</url-pattern> 45 </filter-mapping> 46 46 47 47 … … 51 51 </filter-mapping> 52 52 53 <!-- Make sure this one is declared before the wicket filter, the order matters. Shibboleth should trigger the login, before continuing with the wicket filter.-->53 <!-- Make sure this one is declared before the wicket filter, the order matters. Shibboleth should trigger the login, before continuing with the wicket filter.--> 54 54 <filter> 55 55 <filter-name>AAIFilter</filter-name> … … 74 74 <init-param> 75 75 <param-name>configuration</param-name> 76 <!-- <param-value>development</param-value>-->76 <!-- <param-value>development</param-value>--> 77 77 <param-value>deployment</param-value> 78 <!-- you can override with -Dwicket.configuration=development -->78 <!-- you can override with -Dwicket.configuration=development --> 79 79 </init-param> 80 80 </filter> … … 83 83 <url-pattern>/admin/*</url-pattern> 84 84 </filter-mapping> 85 <servlet> 86 <servlet-name>ComponentRegistry Web Application</servlet-name> 87 <servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class> 88 <init-param> <param-name>com.sun.jersey.config.property.classnames</param-name> 89 <param-value>com.sun.jersey.multipart.impl.FormDataMultiPartDispatchProvider</param-value> 90 </init-param> 91 <load-on-startup>1</load-on-startup> 92 </servlet> 85 <servlet> 86 <servlet-name>ComponentRegistry Web Application</servlet-name> 87 <servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class> 88 <init-param> 89 <param-name>com.sun.jersey.config.property.classnames</param-name> 90 <param-value>com.sun.jersey.multipart.impl.FormDataMultiPartDispatchProvider</param-value> 91 </init-param> 92 <init-param> 93 <param-name>com.sun.jersey.config.property.packages</param-name> 94 <param-value>com.wordnik.swagger.jersey.listing</param-value> 95 </init-param> 96 <load-on-startup>1</load-on-startup> 97 </servlet> 93 98 <servlet-mapping> 94 99 <servlet-name>ComponentRegistry Web Application</servlet-name> … … 105 110 <url-pattern>/isocat/*</url-pattern> 106 111 </servlet-mapping> 112 <servlet> 113 <servlet-name>JerseyJaxrsConfig</servlet-name> 114 <servlet-class>com.wordnik.swagger.jersey.config.JerseyJaxrsConfig</servlet-class> 115 <init-param> 116 <param-name>api.version</param-name> 117 <param-value>1.0.0</param-value> 118 </init-param> 119 <init-param> 120 <param-name>swagger.api.basepath</param-name> 121 <param-value>https://catalog.clarin.eu/ds/ComponentRegistry/rest</param-value> 122 </init-param> 123 <load-on-startup>2</load-on-startup> 124 </servlet> 107 125 108 126 </web-app> -
ComponentRegistry/branches/ComponentRegistry-oauth-1.14.0/ComponentRegistry/src/main/webapp/WEB-INF/web-test.xml
r4109 r5834 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 2 <!-- Configuration file for ComponentRegistry in NON-SHIBBOLIZED context, 3 3 i.e. development or testing environments. --> 4 4 5 5 <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" 6 7 8 9 10 11 12 13 6 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 7 xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> 8 <display-name>ComponentRegistry</display-name> 9 <description>Clarin Metadata Component Registry</description> 10 <listener> 11 <listener-class>org.springframework.web.context.ContextLoaderListener 12 </listener-class> 13 </listener> 14 14 15 16 17 18 19 15 <context-param> 16 <param-name>contextConfigLocation</param-name> 17 <param-value>classpath:spring-config/applicationContext.xml,classpath:spring-config/container-environment.xml 18 </param-value> 19 </context-param> 20 20 21 <filter> 22 <filter-name>characterEncodingFilter</filter-name> 23 <filter-class>clarin.cmdi.componentregistry.servlet.CharacterEncodingFilter 24 </filter-class> 25 <init-param> 26 <param-name>encoding</param-name> 27 <param-value>UTF-8</param-value> 28 </init-param> 29 </filter> 30 <filter-mapping> 31 <filter-name>characterEncodingFilter</filter-name> 32 <url-pattern>/*</url-pattern> 33 </filter-mapping> 34 <filter> 35 <filter-name>NoCachingFilter</filter-name> 36 <filter-class>clarin.cmdi.componentregistry.servlet.DontCacheFilter</filter-class> 37 </filter> 38 <filter-mapping> 39 <filter-name>NoCachingFilter</filter-name> 40 <url-pattern>/rest/registry/*</url-pattern> 41 </filter-mapping> 42 <filter> 43 <filter-name>wicket.componentregistry</filter-name> 44 <filter-class>org.apache.wicket.protocol.http.WicketFilter 45 </filter-class> 46 <init-param> 47 <param-name>applicationClassName</param-name> 48 <param-value>clarin.cmdi.componentregistry.frontend.AdminApp 49 </param-value> 50 </init-param> 51 <init-param> 52 <param-name>configuration</param-name> 53 <!-- <param-value>development</param-value> --> 54 <param-value>deployment</param-value> 55 <!-- you can override with -Dwicket.configuration=development --> 56 </init-param> 57 </filter> 58 <filter-mapping> 59 <filter-name>wicket.componentregistry</filter-name> 60 <url-pattern>/admin/*</url-pattern> 61 </filter-mapping> 62 <servlet> 63 <servlet-name>ComponentRegistry Web Application</servlet-name> 64 <servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet 65 </servlet-class> 66 <init-param> 67 <param-name>com.sun.jersey.config.property.resourceConfigClass 68 </param-name> 69 <param-value>com.sun.jersey.api.core.ClassNamesResourceConfig 70 </param-value> 71 </init-param> 72 <init-param> 73 <param-name>com.sun.jersey.config.property.classnames</param-name> 74 <param-value>com.sun.jersey.multipart.impl.FormDataMultiPartDispatchProvider;clarin.cmdi.componentregistry.rest.ComponentRegistryRestService 75 </param-value> 76 </init-param> 77 <!-- <init-param> --> 78 <!-- <param-name>com.sun.jersey.config.property.packages</param-name> --> 79 <!-- <param-value>clarin.cmdi.componentregistry.rest</param-value> --> 80 <!-- </init-param> --> 81 <load-on-startup>1</load-on-startup> 82 </servlet> 83 <servlet-mapping> 84 <servlet-name>ComponentRegistry Web Application</servlet-name> 85 <url-pattern>/rest/*</url-pattern> 86 </servlet-mapping> 87 <servlet> 88 <servlet-name>Isocat Servlet</servlet-name> 89 <servlet-class>clarin.cmdi.componentregistry.servlet.IsocatServlet 90 </servlet-class> 91 <load-on-startup>1</load-on-startup> 92 </servlet> 93 <servlet-mapping> 94 <servlet-name>Isocat Servlet</servlet-name> 95 <url-pattern>/isocat/*</url-pattern> 96 </servlet-mapping> 97 <security-constraint> 98 <display-name>ComponentRegistry web service</display-name> 99 <web-resource-collection> 100 <web-resource-name>ComponentRegistry edit</web-resource-name> 101 <description /> 102 <url-pattern>/rest/*</url-pattern> 103 <http-method>DELETE</http-method> 104 <http-method>PUT</http-method> 105 <http-method>POST</http-method> 106 </web-resource-collection> 107 <auth-constraint> 108 <role-name>tomcat</role-name> 109 </auth-constraint> 110 </security-constraint> 111 <security-constraint> 112 <display-name>ComponentRegistry SWF GET</display-name> 113 <web-resource-collection> 114 <web-resource-name>ComponentRegistry access</web-resource-name> 115 <description /> 116 <url-pattern>/*</url-pattern> 117 <http-method>GET</http-method> 118 </web-resource-collection> 119 <auth-constraint> 120 <role-name>tomcat</role-name> 121 </auth-constraint> 122 </security-constraint> 123 <login-config> 124 <auth-method>BASIC</auth-method> 125 </login-config> 126 <security-role> 127 <description> The role that is required to log in to the Application 128 </description> 129 <role-name>tomcat</role-name> 130 </security-role> 21 <filter> 22 <filter-name>characterEncodingFilter</filter-name> 23 <filter-class>clarin.cmdi.componentregistry.servlet.CharacterEncodingFilter 24 </filter-class> 25 <init-param> 26 <param-name>encoding</param-name> 27 <param-value>UTF-8</param-value> 28 </init-param> 29 </filter> 30 <filter> 31 <filter-name>NoCachingFilter</filter-name> 32 <filter-class>clarin.cmdi.componentregistry.servlet.DontCacheFilter</filter-class> 33 </filter> 34 <filter-mapping> 35 <filter-name>NoCachingFilter</filter-name> 36 <url-pattern>/rest/registry/*</url-pattern> 37 </filter-mapping> 38 <filter-mapping> 39 <filter-name>characterEncodingFilter</filter-name> 40 <url-pattern>/*</url-pattern> 41 </filter-mapping> 42 <filter> 43 <filter-name>wicket.componentregistry</filter-name> 44 <filter-class>org.apache.wicket.protocol.http.WicketFilter 45 </filter-class> 46 <init-param> 47 <param-name>applicationClassName</param-name> 48 <param-value>clarin.cmdi.componentregistry.frontend.AdminApp 49 </param-value> 50 </init-param> 51 <init-param> 52 <param-name>configuration</param-name> 53 <!-- <param-value>development</param-value> --> 54 <param-value>deployment</param-value> 55 <!-- you can override with -Dwicket.configuration=development --> 56 </init-param> 57 </filter> 58 <filter-mapping> 59 <filter-name>wicket.componentregistry</filter-name> 60 <url-pattern>/admin/*</url-pattern> 61 </filter-mapping> 62 <servlet> 63 <servlet-name>ComponentRegistry Web Application</servlet-name> 64 <servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class> 65 <init-param> 66 <param-name>com.sun.jersey.config.property.classnames</param-name> 67 <param-value>com.sun.jersey.multipart.impl.FormDataMultiPartDispatchProvider</param-value> 68 </init-param> 69 <init-param> 70 <param-name>com.sun.jersey.config.property.packages</param-name> 71 <param-value>com.wordnik.swagger.jersey.listing</param-value> 72 </init-param> 73 <load-on-startup>1</load-on-startup> 74 </servlet> 75 <servlet-mapping> 76 <servlet-name>ComponentRegistry Web Application</servlet-name> 77 <url-pattern>/rest/*</url-pattern> 78 </servlet-mapping> 79 <servlet> 80 <servlet-name>Isocat Servlet</servlet-name> 81 <servlet-class>clarin.cmdi.componentregistry.servlet.IsocatServlet 82 </servlet-class> 83 <load-on-startup>1</load-on-startup> 84 </servlet> 85 <servlet-mapping> 86 <servlet-name>Isocat Servlet</servlet-name> 87 <url-pattern>/isocat/*</url-pattern> 88 </servlet-mapping> 89 <servlet> 90 <servlet-name>JerseyJaxrsConfig</servlet-name> 91 <servlet-class>com.wordnik.swagger.jersey.config.JerseyJaxrsConfig</servlet-class> 92 <init-param> 93 <param-name>api.version</param-name> 94 <param-value>1.0.0</param-value> 95 </init-param> 96 <init-param> 97 <param-name>swagger.api.basepath</param-name> 98 <param-value>http://localhost:8080/ComponentRegistry/rest</param-value> 99 </init-param> 100 <load-on-startup>2</load-on-startup> 101 </servlet> 102 <security-constraint> 103 <display-name>ComponentRegistry web service</display-name> 104 <web-resource-collection> 105 <web-resource-name>ComponentRegistry edit</web-resource-name> 106 <description /> 107 <url-pattern>/rest/*</url-pattern> 108 <http-method>DELETE</http-method> 109 <http-method>PUT</http-method> 110 <http-method>POST</http-method> 111 </web-resource-collection> 112 <auth-constraint> 113 <role-name>tomcat</role-name> 114 </auth-constraint> 115 </security-constraint> 116 <security-constraint> 117 <display-name>ComponentRegistry SWF GET</display-name> 118 <web-resource-collection> 119 <web-resource-name>ComponentRegistry access</web-resource-name> 120 <description /> 121 <url-pattern>/*</url-pattern> 122 <http-method>GET</http-method> 123 </web-resource-collection> 124 <auth-constraint> 125 <role-name>tomcat</role-name> 126 </auth-constraint> 127 </security-constraint> 128 <login-config> 129 <auth-method>BASIC</auth-method> 130 </login-config> 131 <security-role> 132 <description> The role that is required to log in to the Application 133 </description> 134 <role-name>tomcat</role-name> 135 </security-role> 131 136 132 133 134 137 <welcome-file-list> 138 <welcome-file>index.jsp</welcome-file> 139 </welcome-file-list> 135 140 136 141 </web-app> -
ComponentRegistry/branches/ComponentRegistry-oauth-1.14.0/ComponentRegistry/src/main/webapp/WEB-INF/web.xml
r5807 r5834 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 2 <!-- Configuration file for ComponentRegistry in NON-SHIBBOLIZED context, 3 3 i.e. development or testing environments. --> 4 4 5 5 <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" 6 7 8 9 10 11 12 13 6 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 7 xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> 8 <display-name>ComponentRegistry</display-name> 9 <description>Clarin Metadata Component Registry</description> 10 <listener> 11 <listener-class>org.springframework.web.context.ContextLoaderListener 12 </listener-class> 13 </listener> 14 14 15 16 17 18 19 15 <context-param> 16 <param-name>contextConfigLocation</param-name> 17 <param-value>classpath:spring-config/applicationContext.xml,classpath:spring-config/container-environment.xml 18 </param-value> 19 </context-param> 20 20 21 <filter> 22 <filter-name>characterEncodingFilter</filter-name> 23 <filter-class>clarin.cmdi.componentregistry.servlet.CharacterEncodingFilter 24 </filter-class> 25 <init-param> 26 <param-name>encoding</param-name> 27 <param-value>UTF-8</param-value> 28 </init-param> 29 </filter> 30 <filter> 31 <filter-name>NoCachingFilter</filter-name> 32 <filter-class>clarin.cmdi.componentregistry.servlet.DontCacheFilter</filter-class> 33 </filter> 34 <filter-mapping> 35 <filter-name>NoCachingFilter</filter-name> 36 <url-pattern>/rest/registry/*</url-pattern> 37 </filter-mapping> 38 <filter-mapping> 39 <filter-name>characterEncodingFilter</filter-name> 40 <url-pattern>/*</url-pattern> 41 </filter-mapping> 42 <filter> 43 <filter-name>wicket.componentregistry</filter-name> 44 <filter-class>org.apache.wicket.protocol.http.WicketFilter 45 </filter-class> 46 <init-param> 47 <param-name>applicationClassName</param-name> 48 <param-value>clarin.cmdi.componentregistry.frontend.AdminApp 49 </param-value> 50 </init-param> 51 <init-param> 52 <param-name>configuration</param-name> 53 <!-- <param-value>development</param-value> --> 54 <param-value>deployment</param-value> 55 <!-- you can override with -Dwicket.configuration=development --> 56 </init-param> 57 </filter> 58 <filter-mapping> 59 <filter-name>wicket.componentregistry</filter-name> 60 <url-pattern>/admin/*</url-pattern> 61 </filter-mapping> 62 <servlet> 63 <servlet-name>ComponentRegistry Web Application</servlet-name> 64 <servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class> 65 <init-param> <param-name>com.sun.jersey.config.property.classnames</param-name> 66 <param-value>com.sun.jersey.multipart.impl.FormDataMultiPartDispatchProvider</param-value> 67 </init-param> 68 <load-on-startup>1</load-on-startup> 69 </servlet> 70 <servlet-mapping> 71 <servlet-name>ComponentRegistry Web Application</servlet-name> 72 <url-pattern>/rest/*</url-pattern> 73 </servlet-mapping> 74 <servlet> 75 <servlet-name>Isocat Servlet</servlet-name> 76 <servlet-class>clarin.cmdi.componentregistry.servlet.IsocatServlet 77 </servlet-class> 78 <load-on-startup>1</load-on-startup> 79 </servlet> 80 <servlet-mapping> 81 <servlet-name>Isocat Servlet</servlet-name> 82 <url-pattern>/isocat/*</url-pattern> 83 </servlet-mapping> 84 <security-constraint> 85 <display-name>ComponentRegistry web service</display-name> 86 <web-resource-collection> 87 <web-resource-name>ComponentRegistry edit</web-resource-name> 88 <description /> 89 <url-pattern>/rest/*</url-pattern> 90 <http-method>DELETE</http-method> 91 <http-method>PUT</http-method> 92 <http-method>POST</http-method> 93 </web-resource-collection> 94 <auth-constraint> 95 <role-name>tomcat</role-name> 96 </auth-constraint> 97 </security-constraint> 98 <security-constraint> 99 <display-name>ComponentRegistry SWF GET</display-name> 100 <web-resource-collection> 101 <web-resource-name>ComponentRegistry access</web-resource-name> 102 <description /> 103 <url-pattern>/*</url-pattern> 104 <http-method>GET</http-method> 105 </web-resource-collection> 106 <auth-constraint> 107 <role-name>tomcat</role-name> 108 </auth-constraint> 109 </security-constraint> 110 <login-config> 111 <auth-method>BASIC</auth-method> 112 </login-config> 113 <security-role> 114 <description> The role that is required to log in to the Application 115 </description> 116 <role-name>tomcat</role-name> 117 </security-role> 21 <filter> 22 <filter-name>characterEncodingFilter</filter-name> 23 <filter-class>clarin.cmdi.componentregistry.servlet.CharacterEncodingFilter 24 </filter-class> 25 <init-param> 26 <param-name>encoding</param-name> 27 <param-value>UTF-8</param-value> 28 </init-param> 29 </filter> 30 <filter> 31 <filter-name>NoCachingFilter</filter-name> 32 <filter-class>clarin.cmdi.componentregistry.servlet.DontCacheFilter</filter-class> 33 </filter> 34 <filter-mapping> 35 <filter-name>NoCachingFilter</filter-name> 36 <url-pattern>/rest/registry/*</url-pattern> 37 </filter-mapping> 38 <filter-mapping> 39 <filter-name>characterEncodingFilter</filter-name> 40 <url-pattern>/*</url-pattern> 41 </filter-mapping> 42 <filter> 43 <filter-name>wicket.componentregistry</filter-name> 44 <filter-class>org.apache.wicket.protocol.http.WicketFilter 45 </filter-class> 46 <init-param> 47 <param-name>applicationClassName</param-name> 48 <param-value>clarin.cmdi.componentregistry.frontend.AdminApp 49 </param-value> 50 </init-param> 51 <init-param> 52 <param-name>configuration</param-name> 53 <!-- <param-value>development</param-value> --> 54 <param-value>deployment</param-value> 55 <!-- you can override with -Dwicket.configuration=development --> 56 </init-param> 57 </filter> 58 <filter-mapping> 59 <filter-name>wicket.componentregistry</filter-name> 60 <url-pattern>/admin/*</url-pattern> 61 </filter-mapping> 62 <servlet> 63 <servlet-name>ComponentRegistry Web Application</servlet-name> 64 <servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class> 65 <init-param> 66 <param-name>com.sun.jersey.config.property.classnames</param-name> 67 <param-value>com.sun.jersey.multipart.impl.FormDataMultiPartDispatchProvider</param-value> 68 </init-param> 69 <init-param> 70 <param-name>com.sun.jersey.config.property.packages</param-name> 71 <param-value>com.wordnik.swagger.jersey.listing</param-value> 72 </init-param> 73 <load-on-startup>1</load-on-startup> 74 </servlet> 75 <servlet-mapping> 76 <servlet-name>ComponentRegistry Web Application</servlet-name> 77 <url-pattern>/rest/*</url-pattern> 78 </servlet-mapping> 79 <servlet> 80 <servlet-name>Isocat Servlet</servlet-name> 81 <servlet-class>clarin.cmdi.componentregistry.servlet.IsocatServlet 82 </servlet-class> 83 <load-on-startup>1</load-on-startup> 84 </servlet> 85 <servlet-mapping> 86 <servlet-name>Isocat Servlet</servlet-name> 87 <url-pattern>/isocat/*</url-pattern> 88 </servlet-mapping> 89 <servlet> 90 <servlet-name>JerseyJaxrsConfig</servlet-name> 91 <servlet-class>com.wordnik.swagger.jersey.config.JerseyJaxrsConfig</servlet-class> 92 <init-param> 93 <param-name>api.version</param-name> 94 <param-value>1.0.0</param-value> 95 </init-param> 96 <init-param> 97 <param-name>swagger.api.basepath</param-name> 98 <param-value>http://localhost:8080/ComponentRegistry/rest</param-value> 99 </init-param> 100 <load-on-startup>2</load-on-startup> 101 </servlet> 102 <security-constraint> 103 <display-name>ComponentRegistry web service</display-name> 104 <web-resource-collection> 105 <web-resource-name>ComponentRegistry edit</web-resource-name> 106 <description /> 107 <url-pattern>/rest/*</url-pattern> 108 <http-method>DELETE</http-method> 109 <http-method>PUT</http-method> 110 <http-method>POST</http-method> 111 </web-resource-collection> 112 <auth-constraint> 113 <role-name>tomcat</role-name> 114 </auth-constraint> 115 </security-constraint> 116 <security-constraint> 117 <display-name>ComponentRegistry SWF GET</display-name> 118 <web-resource-collection> 119 <web-resource-name>ComponentRegistry access</web-resource-name> 120 <description /> 121 <url-pattern>/*</url-pattern> 122 <http-method>GET</http-method> 123 </web-resource-collection> 124 <auth-constraint> 125 <role-name>tomcat</role-name> 126 </auth-constraint> 127 </security-constraint> 128 <login-config> 129 <auth-method>BASIC</auth-method> 130 </login-config> 131 <security-role> 132 <description> The role that is required to log in to the Application 133 </description> 134 <role-name>tomcat</role-name> 135 </security-role> 118 136 119 120 121 137 <welcome-file-list> 138 <welcome-file>index.jsp</welcome-file> 139 </welcome-file-list> 122 140 123 141 </web-app> -
ComponentRegistry/branches/ComponentRegistry-oauth-1.14.0/ComponentRegistry/src/test/java
- Property svn:mergeinfo changed
/ComponentRegistry/trunk/ComponentRegistry/src/test/java (added) merged: 5828,5832
- Property svn:mergeinfo changed
-
ComponentRegistry/branches/ComponentRegistry-oauth-1.14.0/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/RestGroupServiceTest.java
r5823 r5834 51 51 * 52 52 * B 53 * Owner: Dummy53 * Owner: anotherPrincipal 54 54 * Members: Dummy 55 55 * Items: Bprofile-1, Bcomponent-1, Bcomponent-2 … … 220 220 } 221 221 222 // Response createNewGroup(String groupName) throws IOException;223 @Test224 public void testCreateNewGroup() {225 System.out.println("test createNewGroup");226 ClientResponse cr = this.getAuthenticatedResource(getResource()227 .path("/registry/groups/create").queryParam("groupName", "newGroup"))228 .accept(MediaType.TEXT_XML).post(ClientResponse.class);229 assertEquals(200, cr.getStatus());230 assertEquals("Group with the name newGroup is created and given an id 1", cr.getEntity(String.class));231 }232 233 // List<Group> getGroupsOwnedByUser(String pricipalName) throws IOException;234 @Test235 public void testGetGroupsOwnedByUser() {236 System.out.println("test GetGroupsOwnedByUser");237 ClientResponse cr = this.getAuthenticatedResource(getResource()238 .path("/registry/groups/create").queryParam("groupName", "newGroup1"))239 .accept(MediaType.TEXT_XML).post(ClientResponse.class);240 assertEquals(200, cr.getStatus());241 ClientResponse cr1 = this.getAuthenticatedResource(getResource()242 .path("/registry/groups/create").queryParam("groupName", "newGroup2"))243 .accept(MediaType.TEXT_XML).post(ClientResponse.class);244 assertEquals(200, cr1.getStatus());245 246 // test itself247 List<Group> result = this.getAuthenticatedResource(getResource()248 .path("/registry/groups/principal").queryParam("principalName", DummyPrincipal.DUMMY_PRINCIPAL.getName()))249 .accept(MediaType.APPLICATION_XML).get(GROUP_LIST_GENERICTYPE);250 251 assertEquals(2, result.size());252 assertEquals("newGroup1", result.get(0).getName());253 assertEquals("newGroup2", result.get(1).getName());254 }255 222 256 223 // List<Group> getGroupsTheCurrentUserIsAMemberOf(); … … 270 237 assertEquals("group B", result.get(0).getName()); 271 238 } 272 //273 // List<Group> getGroupsTheItemIsAMemberOf(String itemId);274 275 @Test276 public void testGetGroupsTheItemIsAMemberOf() throws ParseException, JAXBException, ItemNotFoundException {277 System.out.println("test getGroupsTheItemIsAMemberOf");278 279 fillUpGroupA();280 fillUpGroupB();281 // test itself282 283 List<Group> result = this.getAuthenticatedResource(getResource()284 .path("/registry/items/" + ComponentDescription.COMPONENT_PREFIX + "component-1/groups"))285 .accept(MediaType.APPLICATION_XML).get(GROUP_LIST_GENERICTYPE);286 287 assertEquals(1, result.size());288 assertEquals("group A", result.get(0).getName());289 290 result = this.getAuthenticatedResource(getResource()291 .path("/registry/items/" + ComponentDescription.COMPONENT_PREFIX + "Bcomponent-1/groups"))292 .accept(MediaType.APPLICATION_XML).get(GROUP_LIST_GENERICTYPE);293 294 assertEquals(1, result.size());295 assertEquals("group B", result.get(0).getName());296 297 result = this.getAuthenticatedResource(getResource()298 .path("/registry/items/" + ProfileDescription.PROFILE_PREFIX + "Bprofile-1/groups"))299 .accept(MediaType.APPLICATION_XML).get(GROUP_LIST_GENERICTYPE);300 301 assertEquals(1, result.size());302 assertEquals("group B", result.get(0).getName());303 304 result = this.getAuthenticatedResource(getResource()305 .path("/registry/items/" + ProfileDescription.PROFILE_PREFIX + "profile-1/groups"))306 .accept(MediaType.APPLICATION_XML).get(GROUP_LIST_GENERICTYPE);307 308 assertEquals(1, result.size());309 assertEquals("group A", result.get(0).getName());310 }311 312 @Test313 public void testListGroupNames() throws ItemNotFoundException {314 System.out.println("test listGroupNames");315 316 MakeGroupA();317 MakeGroupB();318 319 // test itself320 ClientResponse cr = this.getAuthenticatedResource(getResource()321 .path("/registry/groups/names")).accept(MediaType.APPLICATION_XML).get(ClientResponse.class);322 assertEquals(200, cr.getStatus());323 List<String> result = cr.getEntity(ComponentRegistryRestService.StringsWrapper.class).strings;324 assertEquals(2, result.size());325 assertEquals("group A", result.get(0));326 assertEquals("group B", result.get(1));327 }328 329 //330 // Response isOwner(String groupName) throws IOException;331 @Test332 public void testIsOwner() throws ItemNotFoundException {333 System.out.println("test isOwner");334 335 MakeGroupA();336 MakeGroupB();337 338 // test itself339 ClientResponse cr = this.getAuthenticatedResource(getResource()340 .path("/registry/groups/ownership").queryParam("groupName", "group A")).accept(MediaType.APPLICATION_XML).get(ClientResponse.class);341 assertEquals(200, cr.getStatus());342 String result = cr.getEntity(String.class);343 assertEquals("true", result);344 345 cr = this.getAuthenticatedResource(getResource()346 .path("/registry/groups/ownership").queryParam("groupName", "group B")).accept(MediaType.APPLICATION_XML).get(ClientResponse.class);347 assertEquals(200, cr.getStatus());348 result = cr.getEntity(String.class);349 assertEquals("false", result);350 }351 352 //353 // Response makeGroupMember(String groupName, String principalName) throws IOException;354 @Test355 public void testMakeGroupMember() throws ItemNotFoundException {356 System.out.println("test makeGroupMember");357 358 MakeGroupA();359 MakeGroupB();360 // test itself361 362 //MultivaluedMap<String, String> params = new MultivaluedHashMap<String, String>();363 ClientResponse cr = this.getAuthenticatedResource(getResource()364 .path("/registry/groups/makemember").queryParam("groupName", "group A").queryParam("principalName", "anotherPrincipal")).accept(MediaType.APPLICATION_XML).post(ClientResponse.class);365 assertEquals(200, cr.getStatus());366 367 assertTrue(groupService.userGroupMember("anotherPrincipal", 1));368 ;369 cr = this.getAuthenticatedResource(getResource()370 .path("/registry/groups/makemember").queryParam("groupName", "group B").queryParam("principalName", "anotherPrincipal")).accept(MediaType.APPLICATION_XML).post(ClientResponse.class);371 assertEquals(403, cr.getStatus());372 }373 374 //375 // Response listProfiles(String groupId) throws IOException;376 @Test377 public void testListProfilesAndComponents() throws Exception {378 System.out.println("test listProfilesAndComponents");379 380 fillUpGroupA();381 382 // test itself383 ClientResponse cr = this.getAuthenticatedResource(getResource()384 .path("/registry/groups/profiles").queryParam("groupId", "1")).accept(MediaType.APPLICATION_XML).get(ClientResponse.class);385 assertEquals(200, cr.getStatus());386 List<String> result = cr.getEntity(ComponentRegistryRestService.StringsWrapper.class).strings;387 assertEquals(1, result.size());388 assertEquals(ProfileDescription.PROFILE_PREFIX + "profile-1", result.get(0));389 390 cr = this.getAuthenticatedResource(getResource()391 .path("/registry/groups/components").queryParam("groupId", "1")).accept(MediaType.APPLICATION_XML).get(ClientResponse.class);392 assertEquals(200, cr.getStatus());393 result = cr.getEntity(ComponentRegistryRestService.StringsWrapper.class).strings;394 assertEquals(2, result.size());395 assertEquals(ComponentDescription.COMPONENT_PREFIX + "component-1", result.get(0));396 assertEquals(ComponentDescription.COMPONENT_PREFIX + "component-2", result.get(1));397 }398 399 //400 // Response getGroupNameById(String groupId) throws IOException;401 @Test402 public void testGetGroupNamebyId() throws Exception {403 System.out.println("test getGroupNamebyId");404 405 MakeGroupA();406 MakeGroupB();407 // test itself408 409 ClientResponse cr = this.getAuthenticatedResource(getResource()410 .path("/registry/groups/nameById").queryParam("groupId", "1")).accept(MediaType.APPLICATION_XML).get(ClientResponse.class);411 assertEquals(200, cr.getStatus());412 String result = cr.getEntity(String.class);413 assertEquals("group A", result);414 415 cr = this.getAuthenticatedResource(getResource()416 .path("/registry/groups/nameById").queryParam("groupId", "2")).accept(MediaType.APPLICATION_XML).get(ClientResponse.class);417 assertEquals(200, cr.getStatus());418 result = cr.getEntity(String.class);419 assertEquals("group B", result);420 }421 422 //423 // Response getGroupIdByName(String groupName) throws IOException;424 @Test425 public void testGetIdByGroupName() throws Exception {426 System.out.println("test getIdByGroupName");427 428 MakeGroupA();429 MakeGroupB();430 // test itself431 432 ClientResponse cr = this.getAuthenticatedResource(getResource()433 .path("/registry/groups/idByName").queryParam("groupName", "group B")).accept(MediaType.APPLICATION_XML).get(ClientResponse.class);434 assertEquals(200, cr.getStatus());435 String result = cr.getEntity(String.class);436 assertEquals("2", result);437 438 cr = this.getAuthenticatedResource(getResource()439 .path("/registry/groups/idByName").queryParam("groupName", "group A")).accept(MediaType.APPLICATION_XML).get(ClientResponse.class);440 assertEquals(200, cr.getStatus());441 result = cr.getEntity(String.class);442 assertEquals("1", result);443 }444 445 239 // Response transferItemOwnershipToGroup(String itemId, long groupId) throws IOException; 446 240 // -
ComponentRegistry/branches/ComponentRegistry-oauth-1.14.0/docs
- Property svn:mergeinfo changed
/ComponentRegistry/trunk/docs (added) merged: 5831,5833
- Property svn:mergeinfo changed
Note: See TracChangeset
for help on using the changeset viewer.