Esempio n. 1
0
 @Override
 @HasPermission(action = UGC_UPDATE, type = SocialPermission.class)
 public void setAttributes(
     @SecuredObject final String ugcId, final String contextId, final Map attributes)
     throws SocialException, UGCNotFound {
   log.debug("logging.ugc.addingAttributes", attributes, ugcId, contextId);
   try {
     T toUpdate = (T) ugcRepository.findUGC(contextId, ugcId);
     if (toUpdate == null) {
       throw new UGCNotFound("Unable to found ugc with id " + ugcId);
     }
     final Map attrs = toUpdate.getAttributes();
     attrs.putAll(attrs);
     ugcRepository.setAttributes(ugcId, contextId, attrs);
     final SocialEvent<T> event =
         new SocialEvent<T>(
             ugcId,
             attributes,
             SocialSecurityUtils.getCurrentProfile().getId().toString(),
             UGCEvent.UPDATE_ATTRIBUTES);
     event.setAttribute("baseUrl", calculateBaseUrl());
     reactor.notify(UGCEvent.UPDATE_ATTRIBUTES.getName(), Event.wrap(event));
   } catch (MongoDataException ex) {
     log.debug("logging.ugc.unableToAddAttrs", ex, attributes, ugcId, contextId);
     throw new UGCException("Unable to add Attributes to UGC", ex);
   }
 }