Changeset 2563


Ignore:
Timestamp:
02/11/13 10:33:01 (11 years ago)
Author:
twagoo
Message:

Changed log levels in REST service: all retrieval requests are logged as DEBUG, all create,update, delete are logged as INFO.

Location:
ComponentRegistry/trunk/ComponentRegistry/src/main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/ComponentRegistryRestService.java

    r2561 r2563  
    145145        long start = System.currentTimeMillis();
    146146        List<ComponentDescription> components = getRegistry(getStatus(userspace)).getComponentDescriptions();
    147         LOG.info("Releasing {} registered components into the world ({} millisecs)", components.size(), (System.currentTimeMillis() - start));
     147        LOG.debug("Releasing {} registered components into the world ({} millisecs)", components.size(), (System.currentTimeMillis() - start));
    148148        return components;
    149149    }
     
    163163        }
    164164
    165         LOG.info("Releasing {} registered profiles into the world ({} millisecs)", profiles.size(), (System.currentTimeMillis() - start));
     165        LOG.debug("Releasing {} registered profiles into the world ({} millisecs)", profiles.size(), (System.currentTimeMillis() - start));
    166166        return profiles;
    167167    }
     
    172172    public Response getRegisteredComponent(@PathParam("componentId") String componentId,
    173173            @QueryParam(USERSPACE_PARAM) @DefaultValue("false") boolean userspace) throws ComponentRegistryException {
    174         LOG.info("Component with id: {} is requested.", componentId);
     174        LOG.debug("Component with id: {} is requested.", componentId);
    175175        CMDComponentSpec mdComponent = getRegistry(getStatus(userspace)).getMDComponent(componentId);
    176176        if (mdComponent == null) {
     
    185185    @Produces({MediaType.TEXT_XML, MediaType.APPLICATION_XML})
    186186    public Response getRegisteredComponentRawType(@PathParam("componentId") final String componentId, @PathParam("rawType") String rawType) {
    187         LOG.info("Component with id: {} and rawType: {} is requested.", componentId, rawType);
     187        LOG.debug("Component with id: {} and rawType: {} is requested.", componentId, rawType);
    188188        StreamingOutput result = null;
    189189        try {
     
    256256    public Response getRegisteredProfile(@PathParam("profileId") String profileId,
    257257            @QueryParam(USERSPACE_PARAM) @DefaultValue("false") boolean userspace) throws ComponentRegistryException {
    258         LOG.info("Profile with id {} is requested.", profileId);
     258        LOG.debug("Profile with id {} is requested.", profileId);
    259259        CMDComponentSpec mdProfile = getRegistry(getStatus(userspace)).getMDProfile(profileId);
    260260        if (mdProfile == null) {
     
    275275            List<ProfileDescription> profiles = registry.getUsageInProfiles(componentId);
    276276
    277             LOG.info("Found {} components and {} profiles that use component {} ({} millisecs)",
     277            LOG.debug("Found {} components and {} profiles that use component {} ({} millisecs)",
    278278                    components.size(), profiles.size(), componentId, (System.currentTimeMillis() - start));
    279279
     
    297297        final Principal principal = security.getUserPrincipal();
    298298        List<Comment> comments = getRegistry(getStatus(userspace)).getCommentsInProfile(profileId, principal);
    299         LOG.info("Releasing {} registered comments in profile into the world ({} millisecs)", comments.size(), (System.currentTimeMillis() - start));
     299        LOG.debug("Releasing {} registered comments in profile into the world ({} millisecs)", comments.size(), (System.currentTimeMillis() - start));
    300300        return comments;
    301301    }
     
    308308        final Principal principal = security.getUserPrincipal();
    309309        List<Comment> comments = getRegistry(getStatus(userspace)).getCommentsInComponent(componentId, principal);
    310         LOG.info("Releasing {} registered comments in Component into the world ({} millisecs)", comments.size(), (System.currentTimeMillis() - start));
     310        LOG.debug("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 profile with id {} are requested.", commentId);
     318        LOG.debug("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 {} are requested.", commentId);
     327        LOG.debug("Comments of component with id {} are requested.", commentId);
    328328        final Principal principal = security.getUserPrincipal();
    329329        return getRegistry(getStatus(userspace)).getSpecifiedCommentInComponent(componentId, commentId, principal);
     
    513513            Principal principal = checkAndGetUserPrincipal();
    514514            ComponentRegistry registry = getRegistry(getStatus(userspace));
    515             LOG.info("Component with id {} set for deletion.", componentId);
     515            LOG.debug("Component with id {} set for deletion.", componentId);
    516516            registry.deleteMDComponent(componentId, principal, false);
    517517        } catch (DeleteFailedException e) {
     
    540540        try {
    541541            Principal principal = checkAndGetUserPrincipal();
    542             LOG.info("Profile with id: {} set for deletion.", profileId);
     542            LOG.debug("Profile with id: {} set for deletion.", profileId);
    543543            getRegistry(getStatus(userspace)).deleteMDProfile(profileId, principal);
    544544        } catch (DeleteFailedException e) {
     
    570570            final Comment comment = registry.getSpecifiedCommentInProfile(profileId, commentId, principal);
    571571            if (comment != null && profileId.equals(comment.getProfileDescriptionId())) {
    572                 LOG.info("Comment with id: {} set for deletion.", commentId);
     572                LOG.debug("Comment with id: {} set for deletion.", commentId);
    573573                registry.deleteComment(commentId, principal);
    574574            } else {
     
    603603            final Comment comment = registry.getSpecifiedCommentInComponent(componentId, commentId, principal);
    604604            if (comment != null && componentId.equals(comment.getComponentDescriptionId())) {
    605                 LOG.info("Comment with id: {} set for deletion.", commentId);
     605                LOG.debug("Comment with id: {} set for deletion.", commentId);
    606606                registry.deleteComment(commentId, principal);
    607607            } else {
     
    631631    @Produces({MediaType.TEXT_XML, MediaType.APPLICATION_XML})
    632632    public Response getRegisteredProfileRawType(@PathParam("profileId") final String profileId, @PathParam("rawType") String rawType) {
    633         LOG.info("Profile with id {} and rawType {} is requested.", profileId, rawType);
     633        LOG.debug("Profile with id {} and rawType {} is requested.", profileId, rawType);
    634634        StreamingOutput result = null;
    635635        try {
     
    711711            desc.setGroupName(group);
    712712            desc.setDomainName(domainName);
    713             LOG.info("Trying to register Profile: {}", desc);
     713            LOG.debug("Trying to register Profile: {}", desc);
    714714            return register(input, desc, userCredentials, userspace, new NewAction());
    715715        } catch (UserUnauthorizedException ex) {
     
    735735            desc.setGroupName(group);
    736736            desc.setDomainName(domainName);
    737             LOG.info("Trying to register Component: {}", desc);
     737            LOG.debug("Trying to register Component: {}", desc);
    738738            return register(input, desc, userCredentials, userspace, new NewAction());
    739739        } catch (UserUnauthorizedException ex) {
     
    758758            ComponentDescription description = registry.getComponentDescription(componentId);
    759759            if (description != null) {
    760                 LOG.info("Trying to register comment to {}", componentId);
     760                LOG.debug("Trying to register comment to {}", componentId);
    761761                return registerComment(input, registry, userspace, description, principal, userCredentials);
    762762            } else {
     
    785785            ProfileDescription description = registry.getProfileDescription(profileId);
    786786            if (description != null) {
    787                 LOG.info("Trying to register comment to {}", profileId);
     787                LOG.debug("Trying to register comment to {}", profileId);
    788788                return registerComment(input, registry, userspace, description, principal, userCredentials);
    789789            } else {
     
    803803        Principal userPrincipal = security.getUserPrincipal();
    804804        if (LOG.isInfoEnabled()) {
    805             LOG.info("ping by <{}>", (userPrincipal == null ? "unauthorized user" : userPrincipal.getName()));
     805            LOG.debug("ping by <{}>", (userPrincipal == null ? "unauthorized user" : userPrincipal.getName()));
    806806        }
    807807        if (request != null) {
     
    848848                }
    849849            } else {
    850                 LOG.info("Registration failed with validation errors: {}", Arrays.toString(response.getErrors().toArray()));
     850                LOG.warn("Registration failed with validation errors: {}", Arrays.toString(response.getErrors().toArray()));
    851851                response.setRegistered(false);
    852852            }
     853            LOG.info("Registered new {} {}", desc.isProfile() ? "profile" : "component", desc);
    853854            response.setIsProfile(desc.isProfile());
    854855            return Response.ok(response).build();
     
    906907                } else {
    907908                    response.setRegistered(false);
    908                     response.addError("Unable to register at this moment. Internal server error.");
     909                    response.addError("Unable to post at this moment. Internal server error.");
     910                }
     911                if (com.getComponentDescriptionId() != null) {
     912                    LOG.info("Posted new comment on component {}", com.getComponentDescriptionId());
     913                } else {
     914                    LOG.info("Posted new comment on profile {}", com.getProfileDescriptionId());
    909915                }
    910916            } else {
    911                 LOG.info("Registration failed with validation errors: {}", Arrays.toString(response.getErrors().toArray()));
     917                LOG.warn("Posting of comment failed with validation errors: {}", Arrays.toString(response.getErrors().toArray()));
    912918                response.setRegistered(false);
    913919            }
     
    938944    }
    939945
    940     private Comment createNewComment() {
    941         Comment com = Comment.createANewComment();
    942         return com;
    943     }
    944 
    945946    private String createXlink(String id) {
    946947        URI uri = uriInfo.getRequestUriBuilder().path(id).build();
     
    10251026        final RssCreatorDescriptions instance = new RssCreatorDescriptions(userspace, getApplicationBaseURI(), "components", Integer.parseInt(limit), components, AbstractDescription.COMPARE_ON_DATE);
    10261027        final Rss rss = instance.getRss();
    1027         LOG.info("Releasing RSS of {} most recently registered components", limit);
     1028        LOG.debug("Releasing RSS of {} most recently registered components", limit);
    10281029        return rss;
    10291030    }
     
    10441045        final RssCreatorDescriptions instance = new RssCreatorDescriptions(userspace, getApplicationBaseURI(), "profiles", Integer.parseInt(limit), profiles, AbstractDescription.COMPARE_ON_DATE);
    10451046        final Rss rss = instance.getRss();
    1046         LOG.info("Releasing RSS of {} most recently registered profiles", limit);
     1047        LOG.debug("Releasing RSS of {} most recently registered profiles", limit);
    10471048        return rss;
    10481049    }
     
    10681069        final RssCreatorComments instance = new RssCreatorComments(userspace, getApplicationBaseURI(), Integer.parseInt(limit), profileId, profileName, "profile", comments, Comment.COMPARE_ON_DATE);
    10691070        final Rss rss = instance.getRss();
    1070         LOG.info("Releasing RSS of {} most recent post on profile {}", limit, profileId);
     1071        LOG.debug("Releasing RSS of {} most recent post on profile {}", limit, profileId);
    10711072        return rss;
    10721073    }
     
    10921093        final RssCreatorComments instance = new RssCreatorComments(userspace, getApplicationBaseURI(), Integer.parseInt(limit), componentId, componentName, "component", comments, Comment.COMPARE_ON_DATE);
    10931094        final Rss rss = instance.getRss();
    1094         LOG.info("Releasing RSS of {} most recent post on component {}", limit, componentId);
     1095        LOG.debug("Releasing RSS of {} most recent post on component {}", limit, componentId);
    10951096        return rss;
    10961097    }
  • ComponentRegistry/trunk/ComponentRegistry/src/main/resources/log4j.properties

    r2562 r2563  
    1010log4j.rootLogger=WARN,ROOT
    1111
    12 log4j.logger.clarin.cmdi.componentregistry=WARN
    13 log4j.logger.clarin.cmdi.componentregistry.rest=WARN
     12log4j.logger.clarin.cmdi.componentregistry.rest=INFO
    1413log4j.logger.clarin.cmdi.componentregistry.impl.database=WARN
    1514log4j.logger.clarin.cmdi.componentregistry.servlet.IsocatServlet=WARN
Note: See TracChangeset for help on using the changeset viewer.