Changeset 2561


Ignore:
Timestamp:
02/11/13 08:41:33 (11 years ago)
Author:
twagoo
Message:

Improved logging & logging config for REST application

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  
    1212
    1313/**
    14  * 
     14 *
    1515 * @author Twan Goosen <twan.goosen@mpi.nl>
    1616 */
    1717public abstract class CMDComponentSpecExpander {
    18 
     18   
    1919    private final static Logger LOG = LoggerFactory.getLogger(CMDComponentSpecExpander.class);
    2020    protected final ComponentRegistry registry;
    21 
     21   
    2222    public CMDComponentSpecExpander(ComponentRegistry registry) {
    2323        this.registry = registry;
    2424    }
    25 
     25   
    2626    public void expandNestedComponent(List<CMDComponentType> cmdComponents, String id) throws ComponentRegistryException {
    2727        expandNestedComponent(cmdComponents, new HashSet<String>(Collections.singleton(id)));
    2828    }
    29 
     29   
    3030    private void expandNestedComponent(List<CMDComponentType> cmdComponents, Collection<String> path) throws ComponentRegistryException {
    3131        List<CMDComponentType> expanded = new ArrayList<CMDComponentType>();
     
    3333            String componentId = cmdComponentType.getComponentId();
    3434            if (componentId != null) {
     35                if (LOG.isDebugEnabled()) {
     36                    LOG.debug("[Level {}] Expanding {}", path.size(), componentId);
     37                }
    3538                if (path.contains(componentId)) {
    3639                    throw new ComponentRegistryException("Detected recursion in component specification: " + path.toString() + " already contains " + componentId);
     
    6164        cmdComponents.addAll(expanded);
    6265    }
    63 
     66   
    6467    private CMDComponentType getComponentTypeOfAComponent(CMDComponentSpec result) {
    6568        List<CMDComponentType> cmdComponents = result.getCMDComponent();
     
    8891        nested.setComponentId(referenceDeclaration.getComponentId()); // Setting componentId for better xsd generation.
    8992    }
    90 
     93   
    9194    protected CMDComponentSpec expandComponent(String componentId) throws ComponentRegistryException {
    9295        // Use uncached components and profiles, because we expand and thus change them this change should not be in the cache.
     
    9699        return result;
    97100    }
    98 
     101   
    99102    protected CMDComponentSpec expandProfile(String profileId) throws ComponentRegistryException {
    100103        // Use uncached components and profiles, because we expand and thus change them this change should not be in the cache.
     
    113116    /**
    114117     * Get uncached component from "this" registry and possibly from public registry. Note: "this" registry can be a user registry.
     118     *
    115119     * @param componentId
    116120     */
    117121    protected abstract CMDComponentSpec getUncachedComponent(String componentId) throws ComponentRegistryException;
    118 
     122   
    119123    protected abstract CMDComponentSpec getUncachedProfile(String profileId) throws ComponentRegistryException;
    120124//    protected abstract CMDComponentSpec getUncachedComment(String commentId) throws ComponentRegistryException;
  • ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/Configuration.java

    r1816 r2561  
    8080
    8181    /**
    82      * 
     82     *
    8383     * @param adminUsers Whitespace-separated list of admin users
    8484     */
    8585    public void setAdminUsersList(String adminUsersList) {
    86         LOG.debug("Setting adminUsersList to {}", adminUsersList);
    8786        String[] adminUsersArray = adminUsersList.trim().split("\\s+");
     87        if (LOG.isDebugEnabled()) {
     88            LOG.info("Setting adminUsersList to {}", Arrays.toString(adminUsersArray));
     89        }
    8890        setAdminUsers(Arrays.asList(adminUsersArray));
    8991    }
    9092
    9193    public void setComponent2SchemaXsl(String component2SchemaXsl) {
    92         LOG.debug("Setting component2SchemaXsl to {}", component2SchemaXsl);
     94        LOG.info("Setting component2SchemaXsl to {}", component2SchemaXsl);
    9395        this.component2SchemaXsl = component2SchemaXsl;
    9496    }
    9597
    9698    public void setComponentSpecSchemaLocation(String componentSpecSchemaLocation) {
    97         LOG.debug("Setting componentSpecSchemaLocation to {}", componentSpecSchemaLocation);
     99        LOG.info("Setting componentSpecSchemaLocation to {}", componentSpecSchemaLocation);
    98100        schemaLocations.put(CMDComponentSpec.class.getName(), componentSpecSchemaLocation);
    99101    }
    100102
    101103    public void setDisplayNameShibbolethKeys(List<String> displayNameShibbolethKeys) {
    102         LOG.debug("Setting displayNameShibbolethKeys to {}", displayNameShibbolethKeys);
     104        LOG.info("Setting displayNameShibbolethKeys to {}", displayNameShibbolethKeys);
    103105        this.displayNameShibbolethKeys = displayNameShibbolethKeys;
    104106    }
    105107
    106108    public void setGeneralComponentSchema(String generalComponentSchema) {
    107         LOG.debug("Setting generalComponentSchema to {}", generalComponentSchema);
     109        LOG.info("Setting generalComponentSchema to {}", generalComponentSchema);
    108110        this.generalComponentSchema = generalComponentSchema;
    109111    }
    110112
    111113    public void setIsocatRestUrl(String isocatRestUrl) {
    112         LOG.debug("Setting isocatRestUrl to {}", isocatRestUrl);
     114        LOG.info("Setting isocatRestUrl to {}", isocatRestUrl);
    113115        this.isocatRestUrl = isocatRestUrl;
    114116    }
  • ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/impl/ComponentRegistryImplBase.java

    r2556 r2561  
    2828 */
    2929public abstract class ComponentRegistryImplBase implements ComponentRegistry {
    30 
     30   
    3131    private final static Logger LOG = LoggerFactory.getLogger(ComponentRegistryImplBase.class);
    32 
     32   
    3333    @Override
    3434    public List<ComponentDescription> getUsageInComponents(String componentId) throws ComponentRegistryException {
     35        LOG.debug("Checking usage of component {} in components", componentId);
    3536        List<ComponentDescription> result = new ArrayList<ComponentDescription>();
    3637        List<ComponentDescription> descs = getComponentDescriptions();
     
    3839            CMDComponentSpec spec = getMDComponent(desc.getId());
    3940            if (spec != null && findComponentId(componentId, spec.getCMDComponent())) {
     41                LOG.debug("Component {} used in component {}", componentId, spec.getHeader().getID());
    4042                result.add(desc);
    4143            }
     
    4345        return result;
    4446    }
    45 
     47   
    4648    @Override
    4749    public List<ProfileDescription> getUsageInProfiles(String componentId) throws ComponentRegistryException {
     50        LOG.debug("Checking usage of component {} in profiles", componentId);
    4851        List<ProfileDescription> result = new ArrayList<ProfileDescription>();
    4952        for (ProfileDescription profileDescription : getProfileDescriptions()) {
    5053            CMDComponentSpec profile = getMDProfile(profileDescription.getId());
    5154            if (profile != null && findComponentId(componentId, profile.getCMDComponent())) {
     55                LOG.debug("Component {} used in profile {}", componentId, profile.getHeader().getID());
    5256                result.add(profileDescription);
    5357            }
     
    8286        return StringUtils.removeStart(id, ComponentRegistry.REGISTRY_ID);
    8387    }
    84 
     88   
    8589    protected static void enrichSpecHeader(CMDComponentSpec spec, AbstractDescription description) {
    8690        Header header = spec.getHeader();
     
    9397        }
    9498    }
    95 
     99   
    96100    protected static boolean findComponentId(String componentId, List<CMDComponentType> componentReferences) {
    97101        for (CMDComponentType cmdComponent : componentReferences) {
     
    104108        return false;
    105109    }
    106 
     110   
    107111    protected static void writeXsd(CMDComponentSpec expandedSpec, OutputStream outputStream) {
    108112        MDMarshaller.generateXsd(expandedSpec, outputStream);
    109113    }
    110 
     114   
    111115    protected static void writeXml(CMDComponentSpec spec, OutputStream outputStream) {
    112116        try {
     
    118122        }
    119123    }
    120 
     124   
    121125    protected void checkStillUsed(String componentId) throws DeleteFailedException, ComponentRegistryException {
    122126        for (ProfileDescription profileDescription : getProfileDescriptions()) {
    123127            CMDComponentSpec spec = getMDProfile(profileDescription.getId());
    124128            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());
    125130                // Profile match - throw
    126131                throw new DeleteFailedException("Component is still in use by other components or profiles. Request component usage for details.");
    127132            }
    128133        }
    129 
     134       
     135        LOG.debug("Component {} is not used in any profiles", componentId);
     136       
    130137        for (ComponentDescription desc : getComponentDescriptions()) {
    131138            CMDComponentSpec spec = getMDComponent(desc.getId());
    132139            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());
    133141                // Component match -> throw
    134142                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  
    614614
    615615            } catch (JAXBException ex) {
    616                 LOG.error(null, ex);
     616                LOG.error("Error while unmarshalling", ex);
    617617            } catch (UnsupportedEncodingException ex) {
    618                 LOG.error(null, ex);
     618                LOG.error("Exception while reading XML from database", ex);
    619619            }
    620620        }
  • ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/impl/database/ComponentRegistryFactoryDbImpl.java

    r2490 r2561  
    103103                    result = getNewComponentRegistryForUser(user.getId());
    104104                } 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);
    106106                    throw new IllegalArgumentException("User " + adminPrincipal.getName() + " is not admin user cannot load userspace.");
    107107                }
  • ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/ComponentRegistryRestService.java

    r2556 r2561  
    5959public class ComponentRegistryRestService {
    6060
     61    private final static Logger LOG = LoggerFactory.getLogger(ComponentRegistryRestService.class);
    6162    public static final String APPLICATION_BASE_URL_PARAM = "eu.clarin.cmdi.componentregistry.serviceRootUrl";
    6263    @Context
     
    6869    @Context
    6970    private ServletContext servletContext;
    70     private final static Logger LOG = LoggerFactory.getLogger(ComponentRegistryRestService.class);
    7171    public static final String DATA_FORM_FIELD = "data";
    7272    public static final String NAME_FORM_FIELD = "name";
     
    145145        long start = System.currentTimeMillis();
    146146        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));
    149148        return components;
    150149    }
     
    164163        }
    165164
    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));
    168166        return profiles;
    169167    }
     
    174172    public Response getRegisteredComponent(@PathParam("componentId") String componentId,
    175173            @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);
    177175        CMDComponentSpec mdComponent = getRegistry(getStatus(userspace)).getMDComponent(componentId);
    178176        if (mdComponent == null) {
     
    187185    @Produces({MediaType.TEXT_XML, MediaType.APPLICATION_XML})
    188186    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);
    190188        StreamingOutput result = null;
    191189        try {
     
    204202                            registry.getMDComponentAsXml(componentId, output);
    205203                        } catch (ComponentRegistryException e) {
    206                             LOG.info("Could not retrieve component", e);
     204                            LOG.warn("Could not retrieve component {}", componentId);
     205                            LOG.debug("Details", e);
    207206                            throw new WebApplicationException(e, Response.serverError().status(Status.INTERNAL_SERVER_ERROR).build());
    208207                        }
     
    216215                            registry.getMDComponentAsXsd(componentId, output);
    217216                        } catch (ComponentRegistryException e) {
    218                             LOG.info("Could not retrieve component", e);
     217                            LOG.warn("Could not retrieve component {}", componentId);
     218                            LOG.debug("Details", e);
    219219                            throw new WebApplicationException(e, Response.serverError().status(Status.INTERNAL_SERVER_ERROR).build());
    220220                        }
     
    228228            return createDownloadResponse(result, fileName);
    229229        } catch (ComponentRegistryException e) {
    230             LOG.info("Could not retrieve component", e);
     230            LOG.warn("Could not retrieve component {}", componentId);
     231            LOG.debug("Details", e);
    231232            return Response.serverError().status(Status.INTERNAL_SERVER_ERROR).build();
    232233        }
     
    255256    public Response getRegisteredProfile(@PathParam("profileId") String profileId,
    256257            @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);
    258259        CMDComponentSpec mdProfile = getRegistry(getStatus(userspace)).getMDProfile(profileId);
    259260        if (mdProfile == null) {
     
    274275            List<ProfileDescription> profiles = registry.getUsageInProfiles(componentId);
    275276
    276             LOG.info("Found " + components.size() + " components and " + profiles.size() + " profiles that use component " + componentId
    277                     + " (" + (System.currentTimeMillis() - start) + " millisecs)");
     277            LOG.info("Found {} components and {} profiles that use component {} ({} millisecs)",
     278                    components.size(), profiles.size(), componentId, (System.currentTimeMillis() - start));
    278279
    279280            List<AbstractDescription> usages = new ArrayList<AbstractDescription>(components.size() + profiles.size());
     
    283284            return usages;
    284285        } 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);
    286288            throw e;
    287289        }
     
    295297        final Principal principal = security.getUserPrincipal();
    296298        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));
    299300        return comments;
    300301    }
     
    307308        final Principal principal = security.getUserPrincipal();
    308309        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));
    311311        return comments;
    312312    }
     
    316316    @Produces({MediaType.TEXT_XML, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
    317317    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);
    319319        final Principal principal = security.getUserPrincipal();
    320320        return getRegistry(getStatus(userspace)).getSpecifiedCommentInProfile(profileId, commentId, principal);
     
    325325    @Produces({MediaType.TEXT_XML, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
    326326    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);
    328328        final Principal principal = security.getUserPrincipal();
    329329        return getRegistry(getStatus(userspace)).getSpecifiedCommentInComponent(componentId, commentId, principal);
     
    385385                return register(input, desc, getUserCredentials(principal), true, new PublishAction(principal));
    386386            } else {
    387                 LOG.error("Update of nonexistent id (" + profileId + ") failed.");
     387                LOG.error("Update of nonexistent profile {} failed.", profileId);
    388388                return Response.serverError().entity("Invalid id, cannot update nonexistent profile").build();
    389389            }
    390390        } catch (ComponentRegistryException e) {
    391             LOG.info("Could not retrieve component", e);
     391            LOG.warn("Could not retrieve profile {}", profileId);
     392            LOG.debug("Details", e);
    392393            return Response.serverError().status(Status.INTERNAL_SERVER_ERROR).build();
    393394        } catch (UserUnauthorizedException ex) {
     
    415416            }
    416417        } catch (ComponentRegistryException e) {
    417             LOG.info("Could not retrieve component", e);
     418            LOG.warn("Could not retrieve profile {}", profileId);
     419            LOG.debug("Details", e);
    418420            return Response.serverError().status(Status.INTERNAL_SERVER_ERROR).build();
    419421        } catch (UserUnauthorizedException ex) {
     
    462464            }
    463465        } catch (ComponentRegistryException e) {
    464             LOG.info("Could not retrieve component", e);
     466            LOG.warn("Could not retrieve component {}", componentId);
     467            LOG.debug("Details", e);
    465468            return Response.serverError().status(Status.INTERNAL_SERVER_ERROR).build();
    466469        } catch (UserUnauthorizedException ex) {
     
    487490            }
    488491        } catch (ComponentRegistryException e) {
    489             LOG.info("Could not retrieve component", e);
     492            LOG.warn("Could not retrieve component {}", componentId);
     493            LOG.debug("Details", e);
    490494            return Response.serverError().status(Status.INTERNAL_SERVER_ERROR).build();
    491495        } catch (UserUnauthorizedException ex) {
     
    509513            Principal principal = checkAndGetUserPrincipal();
    510514            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);
    512516            registry.deleteMDComponent(componentId, principal, false);
    513517        } 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());
    515519            LOG.debug("Deletion failure details:", e);
    516520            return Response.status(Status.FORBIDDEN).entity("" + e.getMessage()).build();
    517521        } catch (ComponentRegistryException e) {
    518             LOG.info("Component with id: " + componentId + " deletion failed.", e);
     522            LOG.warn("Component with id " + componentId + " deletion failed.", e);
    519523            return Response.serverError().status(Status.INTERNAL_SERVER_ERROR).build();
    520524        } catch (IOException e) {
    521             LOG.info("Component with id: " + componentId + " deletion failed.", e);
     525            LOG.error("Component with id " + componentId + " deletion failed.", e);
    522526            return Response.serverError().status(Status.INTERNAL_SERVER_ERROR).build();
    523527        } 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());
    525529            LOG.debug("Deletion failure details:", e);
    526530            return Response.serverError().status(Status.UNAUTHORIZED).entity("" + e.getMessage()).build();
    527531        }
    528         LOG.info("Component with id: " + componentId + " deleted.");
     532        LOG.info("Component with id: {} deleted.", componentId);
    529533        return Response.ok().build();
    530534    }
     
    536540        try {
    537541            Principal principal = checkAndGetUserPrincipal();
    538             LOG.info("Profile with id: " + profileId + " set for deletion.");
     542            LOG.info("Profile with id: {} set for deletion.", profileId);
    539543            getRegistry(getStatus(userspace)).deleteMDProfile(profileId, principal);
    540544        } 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);
    542547            return Response.serverError().status(Status.FORBIDDEN).entity("" + e.getMessage()).build();
    543548        } catch (ComponentRegistryException e) {
    544             LOG.info("Could not retrieve component", e);
     549            LOG.warn("Could not retrieve component", e);
    545550            return Response.serverError().status(Status.INTERNAL_SERVER_ERROR).build();
    546551        } catch (IOException e) {
    547             LOG.info("Profile with id: " + profileId + " deletion failed.", e);
     552            LOG.error("Profile with id: " + profileId + " deletion failed.", e);
    548553            return Response.serverError().status(Status.INTERNAL_SERVER_ERROR).build();
    549554        } 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);
    551557            return Response.serverError().status(Status.UNAUTHORIZED).entity("" + e.getMessage()).build();
    552558        }
    553         LOG.info("Profile with id: " + profileId + " deleted.");
     559        LOG.info("Profile with id: {} deleted.", profileId);
    554560        return Response.ok().build();
    555561    }
     
    564570            final Comment comment = registry.getSpecifiedCommentInProfile(profileId, commentId, principal);
    565571            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);
    567573                registry.deleteComment(commentId, principal);
    568574            } else {
     
    570576            }
    571577        } 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);
    573580            return Response.serverError().status(Status.FORBIDDEN).entity("" + e.getMessage()).build();
    574581        } catch (ComponentRegistryException e) {
     
    576583            return Response.serverError().status(Status.INTERNAL_SERVER_ERROR).build();
    577584        } catch (IOException e) {
    578             LOG.info("Comment with id: " + commentId + " deletion failed.", e);
     585            LOG.error("Comment with id: " + commentId + " deletion failed.", e);
    579586            return Response.serverError().status(Status.INTERNAL_SERVER_ERROR).build();
    580587        } 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);
    582590            return Response.serverError().status(Status.UNAUTHORIZED).entity("" + e.getMessage()).build();
    583591        }
    584         LOG.info("Comment with id: " + commentId + " deleted.");
     592        LOG.info("Comment with id: {} deleted.", commentId);
    585593        return Response.ok().build();
    586594    }
     
    595603            final Comment comment = registry.getSpecifiedCommentInComponent(componentId, commentId, principal);
    596604            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);
    598606                registry.deleteComment(commentId, principal);
    599607            } else {
     
    601609            }
    602610        } 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);
    604613            return Response.serverError().status(Status.FORBIDDEN).entity("" + e.getMessage()).build();
    605614        } catch (ComponentRegistryException e) {
     
    607616            return Response.serverError().status(Status.INTERNAL_SERVER_ERROR).build();
    608617        } catch (IOException e) {
    609             LOG.info("Comment with id: " + commentId + " deletion failed.", e);
     618            LOG.error("Comment with id: " + commentId + " deletion failed.", e);
    610619            return Response.serverError().status(Status.INTERNAL_SERVER_ERROR).build();
    611620        } 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);
    613623            return Response.serverError().status(Status.UNAUTHORIZED).entity("" + e.getMessage()).build();
    614624        }
    615         LOG.info("Comment with id: " + commentId + " deleted.");
     625        LOG.info("Comment with id: {} deleted.", commentId);
    616626        return Response.ok().build();
    617627    }
     
    621631    @Produces({MediaType.TEXT_XML, MediaType.APPLICATION_XML})
    622632    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);
    624634        StreamingOutput result = null;
    625635        try {
     
    639649                            registry.getMDProfileAsXml(profileId, output);
    640650                        } catch (ComponentRegistryException e) {
    641                             LOG.warn("Could not retrieve component", e);
     651                            LOG.warn("Could not retrieve component {}", profileId);
     652                            LOG.debug("Details", e);
    642653                            throw new WebApplicationException(e, Response.serverError().status(Status.INTERNAL_SERVER_ERROR).build());
    643654                        }
     
    651662                            registry.getMDProfileAsXsd(profileId, output);
    652663                        } catch (ComponentRegistryException e) {
    653                             LOG.warn("Could not retrieve component", e);
     664                            LOG.warn("Could not retrieve component {}", profileId);
     665                            LOG.debug("Details", e);
    654666                            throw new WebApplicationException(e, Response.serverError().status(Status.INTERNAL_SERVER_ERROR).build());
    655667                        }
     
    662674            return createDownloadResponse(result, fileName);
    663675        } catch (ComponentRegistryException e) {
    664             LOG.info("Could not retrieve component", e);
     676            LOG.warn("Could not retrieve component {}", profileId);
     677            LOG.debug("Details", e);
    665678            return Response.serverError().status(Status.INTERNAL_SERVER_ERROR).build();
    666679        }
     
    698711            desc.setGroupName(group);
    699712            desc.setDomainName(domainName);
    700             LOG.info("Trying to register Profile: " + desc);
     713            LOG.info("Trying to register Profile: {}", desc);
    701714            return register(input, desc, userCredentials, userspace, new NewAction());
    702715        } catch (UserUnauthorizedException ex) {
     
    722735            desc.setGroupName(group);
    723736            desc.setDomainName(domainName);
    724             LOG.info("Trying to register Component: " + desc);
     737            LOG.info("Trying to register Component: {}", desc);
    725738            return register(input, desc, userCredentials, userspace, new NewAction());
    726739        } catch (UserUnauthorizedException ex) {
     
    745758            ComponentDescription description = registry.getComponentDescription(componentId);
    746759            if (description != null) {
    747                 LOG.info("Trying to register comment to " + componentId);
     760                LOG.info("Trying to register comment to {}", componentId);
    748761                return registerComment(input, registry, userspace, description, principal, userCredentials);
    749762            } 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);
    751764                return Response.serverError().entity("Invalid id, cannot comment on nonexistent component").build();
    752765            }
     
    772785            ProfileDescription description = registry.getProfileDescription(profileId);
    773786            if (description != null) {
    774                 LOG.info("Trying to register comment to " + profileId);
     787                LOG.info("Trying to register comment to {}", profileId);
    775788                return registerComment(input, registry, userspace, description, principal, userCredentials);
    776789            } 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);
    778791                return Response.serverError().entity("Invalid id, cannot comment on nonexistent profile").build();
    779792            }
     
    789802        boolean stillActive = false;
    790803        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        }
    792807        if (request != null) {
    793808            if (userPrincipal != null && !ComponentRegistryFactory.ANONYMOUS_USER.equals(userPrincipal.getName())) {
     
    795810            }
    796811        }
    797         return Response.ok().entity("<session stillActive=\"" + stillActive + "\"/>").build();
     812        return Response.ok().entity(String.format("<session stillActive=\"%s\"/>", stillActive)).build();
    798813    }
    799814
     
    833848                }
    834849            } 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()));
    836851                response.setRegistered(false);
    837852            }
     
    894909                }
    895910            } 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()));
    897912                response.setRegistered(false);
    898913            }
     
    10101025        final RssCreatorDescriptions instance = new RssCreatorDescriptions(userspace, getApplicationBaseURI(), "components", Integer.parseInt(limit), components, AbstractDescription.COMPARE_ON_DATE);
    10111026        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);
    10131028        return rss;
    10141029    }
     
    10291044        final RssCreatorDescriptions instance = new RssCreatorDescriptions(userspace, getApplicationBaseURI(), "profiles", Integer.parseInt(limit), profiles, AbstractDescription.COMPARE_ON_DATE);
    10301045        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);
    10321047        return rss;
    10331048    }
     
    10531068        final RssCreatorComments instance = new RssCreatorComments(userspace, getApplicationBaseURI(), Integer.parseInt(limit), profileId, profileName, "profile", comments, Comment.COMPARE_ON_DATE);
    10541069        final Rss rss = instance.getRss();
     1070        LOG.info("Releasing RSS of {} most recent post on profile {}", limit, profileId);
    10551071        return rss;
    10561072    }
     
    10761092        final RssCreatorComments instance = new RssCreatorComments(userspace, getApplicationBaseURI(), Integer.parseInt(limit), componentId, componentName, "component", comments, Comment.COMPARE_ON_DATE);
    10771093        final Rss rss = instance.getRss();
     1094        LOG.info("Releasing RSS of {} most recent post on component {}", limit, componentId);
    10781095        return rss;
    10791096    }
  • ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/MDValidator.java

    r2347 r2561  
    9696            }
    9797        } catch (MalformedURLException e) {
    98             errorMessages.add(SCHEMA_ERROR + e);
     98            errorMessages.add(SCHEMA_ERROR + e.getMessage());
     99            LOG.error(SCHEMA_ERROR, e);
    99100        } catch (JAXBException e) {
    100             errorMessages.add(PARSE_ERROR + e);
     101            errorMessages.add(PARSE_ERROR + e.getMessage());
     102            LOG.error(PARSE_ERROR, e);
    101103        } catch (ValidatorException e) {
    102             errorMessages.add(PARSE_ERROR + e);
     104            errorMessages.add(PARSE_ERROR + e.getMessage());
     105            LOG.error(PARSE_ERROR, e);
    103106        } catch (IOException e) {
    104             errorMessages.add(IO_ERROR + e);
     107            errorMessages.add(IO_ERROR + e.getMessage());
    105108            LOG.error(IO_ERROR, e);
    106109        }
  • ComponentRegistry/trunk/ComponentRegistry/src/main/resources/log4j.properties

    r2539 r2561  
    88#log4j.appender.Stdout.layout.conversionPattern=%d %p [%c{1}#%M:%L] - %m%n
    99
    10 log4j.rootLogger=INFO,ROOT
     10log4j.rootLogger=WARN,ROOT
    1111
    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
     12log4j.logger.clarin.cmdi.componentregistry=WARN
     13log4j.logger.clarin.cmdi.componentregistry.rest=WARN
     14log4j.logger.clarin.cmdi.componentregistry.impl.database=WARN
    1615
    17 log4j.logger.org.springframework=WARN, ROOT
    18 log4j.logger.com.sun.jersey=WARN, ROOT
     16# Logging for initialization
     17log4j.logger.org.springframework.web.context.ContextLoader=INFO
     18log4j.logger.clarin.cmdi.componentregistry.Configuration=INFO
     19
     20# Frameworks
     21log4j.logger.org.springframework=WARN
     22log4j.logger.org.apache.wicket=WARN
     23log4j.logger.com.sun.jersey=WARN
Note: See TracChangeset for help on using the changeset viewer.