Changeset 2561
- Timestamp:
- 02/11/13 08:41:33 (11 years ago)
- Location:
- ComponentRegistry/trunk/ComponentRegistry/src/main
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/CMDComponentSpecExpander.java
r2347 r2561 12 12 13 13 /** 14 * 14 * 15 15 * @author Twan Goosen <twan.goosen@mpi.nl> 16 16 */ 17 17 public abstract class CMDComponentSpecExpander { 18 18 19 19 private final static Logger LOG = LoggerFactory.getLogger(CMDComponentSpecExpander.class); 20 20 protected final ComponentRegistry registry; 21 21 22 22 public CMDComponentSpecExpander(ComponentRegistry registry) { 23 23 this.registry = registry; 24 24 } 25 25 26 26 public void expandNestedComponent(List<CMDComponentType> cmdComponents, String id) throws ComponentRegistryException { 27 27 expandNestedComponent(cmdComponents, new HashSet<String>(Collections.singleton(id))); 28 28 } 29 29 30 30 private void expandNestedComponent(List<CMDComponentType> cmdComponents, Collection<String> path) throws ComponentRegistryException { 31 31 List<CMDComponentType> expanded = new ArrayList<CMDComponentType>(); … … 33 33 String componentId = cmdComponentType.getComponentId(); 34 34 if (componentId != null) { 35 if (LOG.isDebugEnabled()) { 36 LOG.debug("[Level {}] Expanding {}", path.size(), componentId); 37 } 35 38 if (path.contains(componentId)) { 36 39 throw new ComponentRegistryException("Detected recursion in component specification: " + path.toString() + " already contains " + componentId); … … 61 64 cmdComponents.addAll(expanded); 62 65 } 63 66 64 67 private CMDComponentType getComponentTypeOfAComponent(CMDComponentSpec result) { 65 68 List<CMDComponentType> cmdComponents = result.getCMDComponent(); … … 88 91 nested.setComponentId(referenceDeclaration.getComponentId()); // Setting componentId for better xsd generation. 89 92 } 90 93 91 94 protected CMDComponentSpec expandComponent(String componentId) throws ComponentRegistryException { 92 95 // Use uncached components and profiles, because we expand and thus change them this change should not be in the cache. … … 96 99 return result; 97 100 } 98 101 99 102 protected CMDComponentSpec expandProfile(String profileId) throws ComponentRegistryException { 100 103 // Use uncached components and profiles, because we expand and thus change them this change should not be in the cache. … … 113 116 /** 114 117 * Get uncached component from "this" registry and possibly from public registry. Note: "this" registry can be a user registry. 118 * 115 119 * @param componentId 116 120 */ 117 121 protected abstract CMDComponentSpec getUncachedComponent(String componentId) throws ComponentRegistryException; 118 122 119 123 protected abstract CMDComponentSpec getUncachedProfile(String profileId) throws ComponentRegistryException; 120 124 // protected abstract CMDComponentSpec getUncachedComment(String commentId) throws ComponentRegistryException; -
ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/Configuration.java
r1816 r2561 80 80 81 81 /** 82 * 82 * 83 83 * @param adminUsers Whitespace-separated list of admin users 84 84 */ 85 85 public void setAdminUsersList(String adminUsersList) { 86 LOG.debug("Setting adminUsersList to {}", adminUsersList);87 86 String[] adminUsersArray = adminUsersList.trim().split("\\s+"); 87 if (LOG.isDebugEnabled()) { 88 LOG.info("Setting adminUsersList to {}", Arrays.toString(adminUsersArray)); 89 } 88 90 setAdminUsers(Arrays.asList(adminUsersArray)); 89 91 } 90 92 91 93 public void setComponent2SchemaXsl(String component2SchemaXsl) { 92 LOG. debug("Setting component2SchemaXsl to {}", component2SchemaXsl);94 LOG.info("Setting component2SchemaXsl to {}", component2SchemaXsl); 93 95 this.component2SchemaXsl = component2SchemaXsl; 94 96 } 95 97 96 98 public void setComponentSpecSchemaLocation(String componentSpecSchemaLocation) { 97 LOG. debug("Setting componentSpecSchemaLocation to {}", componentSpecSchemaLocation);99 LOG.info("Setting componentSpecSchemaLocation to {}", componentSpecSchemaLocation); 98 100 schemaLocations.put(CMDComponentSpec.class.getName(), componentSpecSchemaLocation); 99 101 } 100 102 101 103 public void setDisplayNameShibbolethKeys(List<String> displayNameShibbolethKeys) { 102 LOG. debug("Setting displayNameShibbolethKeys to {}", displayNameShibbolethKeys);104 LOG.info("Setting displayNameShibbolethKeys to {}", displayNameShibbolethKeys); 103 105 this.displayNameShibbolethKeys = displayNameShibbolethKeys; 104 106 } 105 107 106 108 public void setGeneralComponentSchema(String generalComponentSchema) { 107 LOG. debug("Setting generalComponentSchema to {}", generalComponentSchema);109 LOG.info("Setting generalComponentSchema to {}", generalComponentSchema); 108 110 this.generalComponentSchema = generalComponentSchema; 109 111 } 110 112 111 113 public void setIsocatRestUrl(String isocatRestUrl) { 112 LOG. debug("Setting isocatRestUrl to {}", isocatRestUrl);114 LOG.info("Setting isocatRestUrl to {}", isocatRestUrl); 113 115 this.isocatRestUrl = isocatRestUrl; 114 116 } -
ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/impl/ComponentRegistryImplBase.java
r2556 r2561 28 28 */ 29 29 public abstract class ComponentRegistryImplBase implements ComponentRegistry { 30 30 31 31 private final static Logger LOG = LoggerFactory.getLogger(ComponentRegistryImplBase.class); 32 32 33 33 @Override 34 34 public List<ComponentDescription> getUsageInComponents(String componentId) throws ComponentRegistryException { 35 LOG.debug("Checking usage of component {} in components", componentId); 35 36 List<ComponentDescription> result = new ArrayList<ComponentDescription>(); 36 37 List<ComponentDescription> descs = getComponentDescriptions(); … … 38 39 CMDComponentSpec spec = getMDComponent(desc.getId()); 39 40 if (spec != null && findComponentId(componentId, spec.getCMDComponent())) { 41 LOG.debug("Component {} used in component {}", componentId, spec.getHeader().getID()); 40 42 result.add(desc); 41 43 } … … 43 45 return result; 44 46 } 45 47 46 48 @Override 47 49 public List<ProfileDescription> getUsageInProfiles(String componentId) throws ComponentRegistryException { 50 LOG.debug("Checking usage of component {} in profiles", componentId); 48 51 List<ProfileDescription> result = new ArrayList<ProfileDescription>(); 49 52 for (ProfileDescription profileDescription : getProfileDescriptions()) { 50 53 CMDComponentSpec profile = getMDProfile(profileDescription.getId()); 51 54 if (profile != null && findComponentId(componentId, profile.getCMDComponent())) { 55 LOG.debug("Component {} used in profile {}", componentId, profile.getHeader().getID()); 52 56 result.add(profileDescription); 53 57 } … … 82 86 return StringUtils.removeStart(id, ComponentRegistry.REGISTRY_ID); 83 87 } 84 88 85 89 protected static void enrichSpecHeader(CMDComponentSpec spec, AbstractDescription description) { 86 90 Header header = spec.getHeader(); … … 93 97 } 94 98 } 95 99 96 100 protected static boolean findComponentId(String componentId, List<CMDComponentType> componentReferences) { 97 101 for (CMDComponentType cmdComponent : componentReferences) { … … 104 108 return false; 105 109 } 106 110 107 111 protected static void writeXsd(CMDComponentSpec expandedSpec, OutputStream outputStream) { 108 112 MDMarshaller.generateXsd(expandedSpec, outputStream); 109 113 } 110 114 111 115 protected static void writeXml(CMDComponentSpec spec, OutputStream outputStream) { 112 116 try { … … 118 122 } 119 123 } 120 124 121 125 protected void checkStillUsed(String componentId) throws DeleteFailedException, ComponentRegistryException { 122 126 for (ProfileDescription profileDescription : getProfileDescriptions()) { 123 127 CMDComponentSpec spec = getMDProfile(profileDescription.getId()); 124 128 if (spec != null && findComponentId(componentId, spec.getCMDComponent())) { 129 LOG.warn("Cannot delete component {}, still used in profile {} and possibly other profiles and/or components", componentId, spec.getHeader().getID()); 125 130 // Profile match - throw 126 131 throw new DeleteFailedException("Component is still in use by other components or profiles. Request component usage for details."); 127 132 } 128 133 } 129 134 135 LOG.debug("Component {} is not used in any profiles", componentId); 136 130 137 for (ComponentDescription desc : getComponentDescriptions()) { 131 138 CMDComponentSpec spec = getMDComponent(desc.getId()); 132 139 if (spec != null && findComponentId(componentId, spec.getCMDComponent())) { 140 LOG.warn("Cannot delete component {}, still used in component {} and possibly other components", componentId, spec.getHeader().getID()); 133 141 // Component match -> throw 134 142 throw new DeleteFailedException("Component is still in use by one or more other components. Request component usage for details."); -
ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/impl/database/ComponentRegistryDbImpl.java
r2068 r2561 614 614 615 615 } catch (JAXBException ex) { 616 LOG.error( null, ex);616 LOG.error("Error while unmarshalling", ex); 617 617 } catch (UnsupportedEncodingException ex) { 618 LOG.error( null, ex);618 LOG.error("Exception while reading XML from database", ex); 619 619 } 620 620 } -
ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/impl/database/ComponentRegistryFactoryDbImpl.java
r2490 r2561 103 103 result = getNewComponentRegistryForUser(user.getId()); 104 104 } else { 105 LOG.info( adminPrincipal.getName() + " not found in list of " +configuration.getAdminUsersArray().length);105 LOG.info("{} not found in list of {}", adminPrincipal.getName(), configuration.getAdminUsersArray().length); 106 106 throw new IllegalArgumentException("User " + adminPrincipal.getName() + " is not admin user cannot load userspace."); 107 107 } -
ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/ComponentRegistryRestService.java
r2556 r2561 59 59 public class ComponentRegistryRestService { 60 60 61 private final static Logger LOG = LoggerFactory.getLogger(ComponentRegistryRestService.class); 61 62 public static final String APPLICATION_BASE_URL_PARAM = "eu.clarin.cmdi.componentregistry.serviceRootUrl"; 62 63 @Context … … 68 69 @Context 69 70 private ServletContext servletContext; 70 private final static Logger LOG = LoggerFactory.getLogger(ComponentRegistryRestService.class);71 71 public static final String DATA_FORM_FIELD = "data"; 72 72 public static final String NAME_FORM_FIELD = "name"; … … 145 145 long start = System.currentTimeMillis(); 146 146 List<ComponentDescription> components = getRegistry(getStatus(userspace)).getComponentDescriptions(); 147 LOG.info("Releasing " + components.size() + " registered components into the world (" + (System.currentTimeMillis() - start) 148 + " millisecs)"); 147 LOG.info("Releasing {} registered components into the world ({} millisecs)", components.size(), (System.currentTimeMillis() - start)); 149 148 return components; 150 149 } … … 164 163 } 165 164 166 LOG.info("Releasing " + profiles.size() + " registered profiles into the world (" + (System.currentTimeMillis() - start) 167 + " millisecs)"); 165 LOG.info("Releasing {} registered profiles into the world ({} millisecs)", profiles.size(), (System.currentTimeMillis() - start)); 168 166 return profiles; 169 167 } … … 174 172 public Response getRegisteredComponent(@PathParam("componentId") String componentId, 175 173 @QueryParam(USERSPACE_PARAM) @DefaultValue("false") boolean userspace) throws ComponentRegistryException { 176 LOG.info("Component with id: " + componentId + " is requested.");174 LOG.info("Component with id: {} is requested.", componentId); 177 175 CMDComponentSpec mdComponent = getRegistry(getStatus(userspace)).getMDComponent(componentId); 178 176 if (mdComponent == null) { … … 187 185 @Produces({MediaType.TEXT_XML, MediaType.APPLICATION_XML}) 188 186 public Response getRegisteredComponentRawType(@PathParam("componentId") final String componentId, @PathParam("rawType") String rawType) { 189 LOG.info("Component with id: " + componentId + " and rawType:" + rawType + " is requested.");187 LOG.info("Component with id: {} and rawType: {} is requested.", componentId, rawType); 190 188 StreamingOutput result = null; 191 189 try { … … 204 202 registry.getMDComponentAsXml(componentId, output); 205 203 } catch (ComponentRegistryException e) { 206 LOG.info("Could not retrieve component", e); 204 LOG.warn("Could not retrieve component {}", componentId); 205 LOG.debug("Details", e); 207 206 throw new WebApplicationException(e, Response.serverError().status(Status.INTERNAL_SERVER_ERROR).build()); 208 207 } … … 216 215 registry.getMDComponentAsXsd(componentId, output); 217 216 } catch (ComponentRegistryException e) { 218 LOG.info("Could not retrieve component", e); 217 LOG.warn("Could not retrieve component {}", componentId); 218 LOG.debug("Details", e); 219 219 throw new WebApplicationException(e, Response.serverError().status(Status.INTERNAL_SERVER_ERROR).build()); 220 220 } … … 228 228 return createDownloadResponse(result, fileName); 229 229 } catch (ComponentRegistryException e) { 230 LOG.info("Could not retrieve component", e); 230 LOG.warn("Could not retrieve component {}", componentId); 231 LOG.debug("Details", e); 231 232 return Response.serverError().status(Status.INTERNAL_SERVER_ERROR).build(); 232 233 } … … 255 256 public Response getRegisteredProfile(@PathParam("profileId") String profileId, 256 257 @QueryParam(USERSPACE_PARAM) @DefaultValue("false") boolean userspace) throws ComponentRegistryException { 257 LOG.info("Profile with id : " + profileId + " is requested.");258 LOG.info("Profile with id {} is requested.", profileId); 258 259 CMDComponentSpec mdProfile = getRegistry(getStatus(userspace)).getMDProfile(profileId); 259 260 if (mdProfile == null) { … … 274 275 List<ProfileDescription> profiles = registry.getUsageInProfiles(componentId); 275 276 276 LOG.info("Found " + components.size() + " components and " + profiles.size() + " profiles that use component " + componentId277 + " (" + (System.currentTimeMillis() - start) + " millisecs)");277 LOG.info("Found {} components and {} profiles that use component {} ({} millisecs)", 278 components.size(), profiles.size(), componentId, (System.currentTimeMillis() - start)); 278 279 279 280 List<AbstractDescription> usages = new ArrayList<AbstractDescription>(components.size() + profiles.size()); … … 283 284 return usages; 284 285 } catch (ComponentRegistryException e) { 285 LOG.info("Could not retrieve profile usage", e); 286 LOG.warn("Could not retrieve profile usage {}", componentId); 287 LOG.debug("Details", e); 286 288 throw e; 287 289 } … … 295 297 final Principal principal = security.getUserPrincipal(); 296 298 List<Comment> comments = getRegistry(getStatus(userspace)).getCommentsInProfile(profileId, principal); 297 LOG.info("Releasing " + comments.size() + " registered comments in Profile into the world (" + (System.currentTimeMillis() - start) 298 + " millisecs)"); 299 LOG.info("Releasing {} registered comments in profile into the world ({} millisecs)", comments.size(), (System.currentTimeMillis() - start)); 299 300 return comments; 300 301 } … … 307 308 final Principal principal = security.getUserPrincipal(); 308 309 List<Comment> comments = getRegistry(getStatus(userspace)).getCommentsInComponent(componentId, principal); 309 LOG.info("Releasing " + comments.size() + " registered comments in Component into the world (" + (System.currentTimeMillis() - start) 310 + " millisecs)"); 310 LOG.info("Releasing {} registered comments in Component into the world ({} millisecs)", comments.size(), (System.currentTimeMillis() - start)); 311 311 return comments; 312 312 } … … 316 316 @Produces({MediaType.TEXT_XML, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) 317 317 public Comment getSpecifiedCommentFromProfile(@PathParam("profileId") String profileId, @PathParam("commentId") String commentId, @QueryParam(USERSPACE_PARAM) @DefaultValue("false") boolean userspace) throws ComponentRegistryException { 318 LOG.info(" Comments of component with id" + commentId + " are requested.");318 LOG.info("Comments of profile with id {} are requested.", commentId); 319 319 final Principal principal = security.getUserPrincipal(); 320 320 return getRegistry(getStatus(userspace)).getSpecifiedCommentInProfile(profileId, commentId, principal); … … 325 325 @Produces({MediaType.TEXT_XML, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) 326 326 public Comment getSpecifiedCommentFromComponent(@PathParam("componentId") String componentId, @PathParam("commentId") String commentId, @QueryParam(USERSPACE_PARAM) @DefaultValue("false") boolean userspace) throws ComponentRegistryException { 327 LOG.info(" Comments of component with id" + commentId + " are requested.");327 LOG.info("Comments of component with id {} are requested.", commentId); 328 328 final Principal principal = security.getUserPrincipal(); 329 329 return getRegistry(getStatus(userspace)).getSpecifiedCommentInComponent(componentId, commentId, principal); … … 385 385 return register(input, desc, getUserCredentials(principal), true, new PublishAction(principal)); 386 386 } else { 387 LOG.error("Update of nonexistent id (" + profileId + ") failed.");387 LOG.error("Update of nonexistent profile {} failed.", profileId); 388 388 return Response.serverError().entity("Invalid id, cannot update nonexistent profile").build(); 389 389 } 390 390 } catch (ComponentRegistryException e) { 391 LOG.info("Could not retrieve component", e); 391 LOG.warn("Could not retrieve profile {}", profileId); 392 LOG.debug("Details", e); 392 393 return Response.serverError().status(Status.INTERNAL_SERVER_ERROR).build(); 393 394 } catch (UserUnauthorizedException ex) { … … 415 416 } 416 417 } catch (ComponentRegistryException e) { 417 LOG.info("Could not retrieve component", e); 418 LOG.warn("Could not retrieve profile {}", profileId); 419 LOG.debug("Details", e); 418 420 return Response.serverError().status(Status.INTERNAL_SERVER_ERROR).build(); 419 421 } catch (UserUnauthorizedException ex) { … … 462 464 } 463 465 } catch (ComponentRegistryException e) { 464 LOG.info("Could not retrieve component", e); 466 LOG.warn("Could not retrieve component {}", componentId); 467 LOG.debug("Details", e); 465 468 return Response.serverError().status(Status.INTERNAL_SERVER_ERROR).build(); 466 469 } catch (UserUnauthorizedException ex) { … … 487 490 } 488 491 } catch (ComponentRegistryException e) { 489 LOG.info("Could not retrieve component", e); 492 LOG.warn("Could not retrieve component {}", componentId); 493 LOG.debug("Details", e); 490 494 return Response.serverError().status(Status.INTERNAL_SERVER_ERROR).build(); 491 495 } catch (UserUnauthorizedException ex) { … … 509 513 Principal principal = checkAndGetUserPrincipal(); 510 514 ComponentRegistry registry = getRegistry(getStatus(userspace)); 511 LOG.info("Component with id : " + componentId + " set for deletion.");515 LOG.info("Component with id {} set for deletion.", componentId); 512 516 registry.deleteMDComponent(componentId, principal, false); 513 517 } catch (DeleteFailedException e) { 514 LOG.info("Component with id : " + componentId + " deletion failed. Reason: " +e.getMessage());518 LOG.info("Component with id {} deletion failed. Reason: {}", componentId, e.getMessage()); 515 519 LOG.debug("Deletion failure details:", e); 516 520 return Response.status(Status.FORBIDDEN).entity("" + e.getMessage()).build(); 517 521 } catch (ComponentRegistryException e) { 518 LOG. info("Component with id:" + componentId + " deletion failed.", e);522 LOG.warn("Component with id " + componentId + " deletion failed.", e); 519 523 return Response.serverError().status(Status.INTERNAL_SERVER_ERROR).build(); 520 524 } catch (IOException e) { 521 LOG. info("Component with id:" + componentId + " deletion failed.", e);525 LOG.error("Component with id " + componentId + " deletion failed.", e); 522 526 return Response.serverError().status(Status.INTERNAL_SERVER_ERROR).build(); 523 527 } catch (UserUnauthorizedException e) { 524 LOG.info("Component with id : " + componentId + " deletion failed: " +e.getMessage());528 LOG.info("Component with id {} deletion failed: {}", componentId, e.getMessage()); 525 529 LOG.debug("Deletion failure details:", e); 526 530 return Response.serverError().status(Status.UNAUTHORIZED).entity("" + e.getMessage()).build(); 527 531 } 528 LOG.info("Component with id: " + componentId + " deleted.");532 LOG.info("Component with id: {} deleted.", componentId); 529 533 return Response.ok().build(); 530 534 } … … 536 540 try { 537 541 Principal principal = checkAndGetUserPrincipal(); 538 LOG.info("Profile with id: " + profileId + " set for deletion.");542 LOG.info("Profile with id: {} set for deletion.", profileId); 539 543 getRegistry(getStatus(userspace)).deleteMDProfile(profileId, principal); 540 544 } catch (DeleteFailedException e) { 541 LOG.info("Profile with id: " + profileId + " deletion failed: " + e.getMessage()); 545 LOG.info("Profile with id: {} deletion failed: {}", profileId, e.getMessage()); 546 LOG.debug("Deletion failure details:", e); 542 547 return Response.serverError().status(Status.FORBIDDEN).entity("" + e.getMessage()).build(); 543 548 } catch (ComponentRegistryException e) { 544 LOG. info("Could not retrieve component", e);549 LOG.warn("Could not retrieve component", e); 545 550 return Response.serverError().status(Status.INTERNAL_SERVER_ERROR).build(); 546 551 } catch (IOException e) { 547 LOG. info("Profile with id: " + profileId + " deletion failed.", e);552 LOG.error("Profile with id: " + profileId + " deletion failed.", e); 548 553 return Response.serverError().status(Status.INTERNAL_SERVER_ERROR).build(); 549 554 } catch (UserUnauthorizedException e) { 550 LOG.info("Profile with id: " + profileId + " deletion failed: " + e.getMessage()); 555 LOG.info("Profile with id: {} deletion failed: {}", profileId, e.getMessage()); 556 LOG.debug("Deletion failure details:", e); 551 557 return Response.serverError().status(Status.UNAUTHORIZED).entity("" + e.getMessage()).build(); 552 558 } 553 LOG.info("Profile with id: " + profileId + " deleted.");559 LOG.info("Profile with id: {} deleted.", profileId); 554 560 return Response.ok().build(); 555 561 } … … 564 570 final Comment comment = registry.getSpecifiedCommentInProfile(profileId, commentId, principal); 565 571 if (comment != null && profileId.equals(comment.getProfileDescriptionId())) { 566 LOG.info("Comment with id: " + commentId + " set for deletion.");572 LOG.info("Comment with id: {} set for deletion.", commentId); 567 573 registry.deleteComment(commentId, principal); 568 574 } else { … … 570 576 } 571 577 } catch (DeleteFailedException e) { 572 LOG.info("Comment with id: " + commentId + " deletion failed: " + e.getMessage()); 578 LOG.info("Comment with id: {} deletion failed: {}", commentId, e.getMessage()); 579 LOG.debug("Deletion failure details:", e); 573 580 return Response.serverError().status(Status.FORBIDDEN).entity("" + e.getMessage()).build(); 574 581 } catch (ComponentRegistryException e) { … … 576 583 return Response.serverError().status(Status.INTERNAL_SERVER_ERROR).build(); 577 584 } catch (IOException e) { 578 LOG. info("Comment with id: " + commentId + " deletion failed.", e);585 LOG.error("Comment with id: " + commentId + " deletion failed.", e); 579 586 return Response.serverError().status(Status.INTERNAL_SERVER_ERROR).build(); 580 587 } catch (UserUnauthorizedException e) { 581 LOG.info("Comment with id: " + commentId + " deletion failed: " + e.getMessage()); 588 LOG.info("Comment with id: {} deletion failed: {}", commentId, e.getMessage()); 589 LOG.debug("Deletion failure details:", e); 582 590 return Response.serverError().status(Status.UNAUTHORIZED).entity("" + e.getMessage()).build(); 583 591 } 584 LOG.info("Comment with id: " + commentId + " deleted.");592 LOG.info("Comment with id: {} deleted.", commentId); 585 593 return Response.ok().build(); 586 594 } … … 595 603 final Comment comment = registry.getSpecifiedCommentInComponent(componentId, commentId, principal); 596 604 if (comment != null && componentId.equals(comment.getComponentDescriptionId())) { 597 LOG.info("Comment with id: " + commentId + " set for deletion.");605 LOG.info("Comment with id: {} set for deletion.", commentId); 598 606 registry.deleteComment(commentId, principal); 599 607 } else { … … 601 609 } 602 610 } catch (DeleteFailedException e) { 603 LOG.info("Comment with id: " + commentId + " deletion failed: " + e.getMessage()); 611 LOG.info("Comment with id: {} deletion failed: {}", commentId, e.getMessage()); 612 LOG.debug("Deletion failure details:", e); 604 613 return Response.serverError().status(Status.FORBIDDEN).entity("" + e.getMessage()).build(); 605 614 } catch (ComponentRegistryException e) { … … 607 616 return Response.serverError().status(Status.INTERNAL_SERVER_ERROR).build(); 608 617 } catch (IOException e) { 609 LOG. info("Comment with id: " + commentId + " deletion failed.", e);618 LOG.error("Comment with id: " + commentId + " deletion failed.", e); 610 619 return Response.serverError().status(Status.INTERNAL_SERVER_ERROR).build(); 611 620 } catch (UserUnauthorizedException e) { 612 LOG.info("Comment with id: " + commentId + " deletion failed: " + e.getMessage()); 621 LOG.info("Comment with id: {} deletion failed: {}", commentId, e.getMessage()); 622 LOG.debug("Deletion failure details:", e); 613 623 return Response.serverError().status(Status.UNAUTHORIZED).entity("" + e.getMessage()).build(); 614 624 } 615 LOG.info("Comment with id: " + commentId + " deleted.");625 LOG.info("Comment with id: {} deleted.", commentId); 616 626 return Response.ok().build(); 617 627 } … … 621 631 @Produces({MediaType.TEXT_XML, MediaType.APPLICATION_XML}) 622 632 public Response getRegisteredProfileRawType(@PathParam("profileId") final String profileId, @PathParam("rawType") String rawType) { 623 LOG.info("Profile with id : " + profileId + " and rawType:" + rawType + " is requested.");633 LOG.info("Profile with id {} and rawType {} is requested.", profileId, rawType); 624 634 StreamingOutput result = null; 625 635 try { … … 639 649 registry.getMDProfileAsXml(profileId, output); 640 650 } catch (ComponentRegistryException e) { 641 LOG.warn("Could not retrieve component", e); 651 LOG.warn("Could not retrieve component {}", profileId); 652 LOG.debug("Details", e); 642 653 throw new WebApplicationException(e, Response.serverError().status(Status.INTERNAL_SERVER_ERROR).build()); 643 654 } … … 651 662 registry.getMDProfileAsXsd(profileId, output); 652 663 } catch (ComponentRegistryException e) { 653 LOG.warn("Could not retrieve component", e); 664 LOG.warn("Could not retrieve component {}", profileId); 665 LOG.debug("Details", e); 654 666 throw new WebApplicationException(e, Response.serverError().status(Status.INTERNAL_SERVER_ERROR).build()); 655 667 } … … 662 674 return createDownloadResponse(result, fileName); 663 675 } catch (ComponentRegistryException e) { 664 LOG.info("Could not retrieve component", e); 676 LOG.warn("Could not retrieve component {}", profileId); 677 LOG.debug("Details", e); 665 678 return Response.serverError().status(Status.INTERNAL_SERVER_ERROR).build(); 666 679 } … … 698 711 desc.setGroupName(group); 699 712 desc.setDomainName(domainName); 700 LOG.info("Trying to register Profile: " +desc);713 LOG.info("Trying to register Profile: {}", desc); 701 714 return register(input, desc, userCredentials, userspace, new NewAction()); 702 715 } catch (UserUnauthorizedException ex) { … … 722 735 desc.setGroupName(group); 723 736 desc.setDomainName(domainName); 724 LOG.info("Trying to register Component: " +desc);737 LOG.info("Trying to register Component: {}", desc); 725 738 return register(input, desc, userCredentials, userspace, new NewAction()); 726 739 } catch (UserUnauthorizedException ex) { … … 745 758 ComponentDescription description = registry.getComponentDescription(componentId); 746 759 if (description != null) { 747 LOG.info("Trying to register comment to " +componentId);760 LOG.info("Trying to register comment to {}", componentId); 748 761 return registerComment(input, registry, userspace, description, principal, userCredentials); 749 762 } else { 750 LOG. error("Attempt to post comment on nonexistent component id (" + componentId + ") failed.");763 LOG.warn("Attempt to post comment on nonexistent component id {} failed.", componentId); 751 764 return Response.serverError().entity("Invalid id, cannot comment on nonexistent component").build(); 752 765 } … … 772 785 ProfileDescription description = registry.getProfileDescription(profileId); 773 786 if (description != null) { 774 LOG.info("Trying to register comment to " +profileId);787 LOG.info("Trying to register comment to {}", profileId); 775 788 return registerComment(input, registry, userspace, description, principal, userCredentials); 776 789 } else { 777 LOG. error("Attempt to post comment on nonexistent profile id (" + profileId + ") failed.");790 LOG.warn("Attempt to post comment on nonexistent profile id {} failed.", profileId); 778 791 return Response.serverError().entity("Invalid id, cannot comment on nonexistent profile").build(); 779 792 } … … 789 802 boolean stillActive = false; 790 803 Principal userPrincipal = security.getUserPrincipal(); 791 LOG.info("ping by user: " + (userPrincipal == null ? "null" : userPrincipal.getName())); 804 if (LOG.isInfoEnabled()) { 805 LOG.info("ping by <{}>", (userPrincipal == null ? "unauthorized user" : userPrincipal.getName())); 806 } 792 807 if (request != null) { 793 808 if (userPrincipal != null && !ComponentRegistryFactory.ANONYMOUS_USER.equals(userPrincipal.getName())) { … … 795 810 } 796 811 } 797 return Response.ok().entity( "<session stillActive=\"" + stillActive + "\"/>").build();812 return Response.ok().entity(String.format("<session stillActive=\"%s\"/>", stillActive)).build(); 798 813 } 799 814 … … 833 848 } 834 849 } else { 835 LOG.info("Registration failed with validation errors: " +Arrays.toString(response.getErrors().toArray()));850 LOG.info("Registration failed with validation errors: {}", Arrays.toString(response.getErrors().toArray())); 836 851 response.setRegistered(false); 837 852 } … … 894 909 } 895 910 } else { 896 LOG.info("Registration failed with validation errors: " +Arrays.toString(response.getErrors().toArray()));911 LOG.info("Registration failed with validation errors: {}", Arrays.toString(response.getErrors().toArray())); 897 912 response.setRegistered(false); 898 913 } … … 1010 1025 final RssCreatorDescriptions instance = new RssCreatorDescriptions(userspace, getApplicationBaseURI(), "components", Integer.parseInt(limit), components, AbstractDescription.COMPARE_ON_DATE); 1011 1026 final Rss rss = instance.getRss(); 1012 LOG.info("Releasing RSS of " + limit + " most recently registered components");1027 LOG.info("Releasing RSS of {} most recently registered components", limit); 1013 1028 return rss; 1014 1029 } … … 1029 1044 final RssCreatorDescriptions instance = new RssCreatorDescriptions(userspace, getApplicationBaseURI(), "profiles", Integer.parseInt(limit), profiles, AbstractDescription.COMPARE_ON_DATE); 1030 1045 final Rss rss = instance.getRss(); 1031 LOG.info("Releasing RSS of " + limit + " most recently registered profiles");1046 LOG.info("Releasing RSS of {} most recently registered profiles", limit); 1032 1047 return rss; 1033 1048 } … … 1053 1068 final RssCreatorComments instance = new RssCreatorComments(userspace, getApplicationBaseURI(), Integer.parseInt(limit), profileId, profileName, "profile", comments, Comment.COMPARE_ON_DATE); 1054 1069 final Rss rss = instance.getRss(); 1070 LOG.info("Releasing RSS of {} most recent post on profile {}", limit, profileId); 1055 1071 return rss; 1056 1072 } … … 1076 1092 final RssCreatorComments instance = new RssCreatorComments(userspace, getApplicationBaseURI(), Integer.parseInt(limit), componentId, componentName, "component", comments, Comment.COMPARE_ON_DATE); 1077 1093 final Rss rss = instance.getRss(); 1094 LOG.info("Releasing RSS of {} most recent post on component {}", limit, componentId); 1078 1095 return rss; 1079 1096 } -
ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/MDValidator.java
r2347 r2561 96 96 } 97 97 } catch (MalformedURLException e) { 98 errorMessages.add(SCHEMA_ERROR + e); 98 errorMessages.add(SCHEMA_ERROR + e.getMessage()); 99 LOG.error(SCHEMA_ERROR, e); 99 100 } catch (JAXBException e) { 100 errorMessages.add(PARSE_ERROR + e); 101 errorMessages.add(PARSE_ERROR + e.getMessage()); 102 LOG.error(PARSE_ERROR, e); 101 103 } catch (ValidatorException e) { 102 errorMessages.add(PARSE_ERROR + e); 104 errorMessages.add(PARSE_ERROR + e.getMessage()); 105 LOG.error(PARSE_ERROR, e); 103 106 } catch (IOException e) { 104 errorMessages.add(IO_ERROR + e );107 errorMessages.add(IO_ERROR + e.getMessage()); 105 108 LOG.error(IO_ERROR, e); 106 109 } -
ComponentRegistry/trunk/ComponentRegistry/src/main/resources/log4j.properties
r2539 r2561 8 8 #log4j.appender.Stdout.layout.conversionPattern=%d %p [%c{1}#%M:%L] - %m%n 9 9 10 log4j.rootLogger= INFO,ROOT10 log4j.rootLogger=WARN,ROOT 11 11 12 log4j.logger.org.apache.wicket=ERROR 13 log4j.logger.org.apache.wicket.protocol.http.HttpSessionStore=ERROR 14 log4j.logger.org.apache.wicket.version=ERROR 15 log4j.logger.org.apache.wicket.RequestCycle=ERROR 12 log4j.logger.clarin.cmdi.componentregistry=WARN 13 log4j.logger.clarin.cmdi.componentregistry.rest=WARN 14 log4j.logger.clarin.cmdi.componentregistry.impl.database=WARN 16 15 17 log4j.logger.org.springframework=WARN, ROOT 18 log4j.logger.com.sun.jersey=WARN, ROOT 16 # Logging for initialization 17 log4j.logger.org.springframework.web.context.ContextLoader=INFO 18 log4j.logger.clarin.cmdi.componentregistry.Configuration=INFO 19 20 # Frameworks 21 log4j.logger.org.springframework=WARN 22 log4j.logger.org.apache.wicket=WARN 23 log4j.logger.com.sun.jersey=WARN
Note: See TracChangeset
for help on using the changeset viewer.