@Test public void testHandleMessageMergeTags() throws Exception { message.setMergeTags(true); handler.handleMessage(message); Assert.assertEquals(existingTagsAmount + newTagsAmount, blogManagementMock.getBlogTO().getTags().size()); }
@Override public CommunoteReplyMessage handleMessage(EditTopicMessage message) throws Exception { try { LOG.debug("Message is received by EditTopicMessageHandler."); validateMessage(message); Blog existingTopic = getExistingTopic(message.getTopic(), message.isUpdateAlias()); if (existingTopic == null) { LOG.error("There exists no topic with id == " + message.getTopic().getTopicId() + " or alias == " + message.getTopic().getTopicAlias()); throw new BlogNotFoundException("No Topic was found", message .getTopic().getTopicId(), message.getTopic() .getTopicAlias()); } BlogTO topicTO = createTopicTO(message, existingTopic); Blog updatedTopic = getTopicManagement().updateBlog(existingTopic.getId(), topicTO); Topic mqTopic = message.getTopic(); if (message.isUpdateTopicRights() && mqTopic.getTopicRights() != null) { getTopicRightsManagement().setAllCanReadAllCanWrite(existingTopic.getId(), mqTopic.getTopicRights().isAllCanRead(), mqTopic.getTopicRights().isAllCanWrite()); } ExternalObjectManagement externalObjectManagement = getExternalObjectManagement(); TopicMessageHandlerUtils.updateExternalObjects(updatedTopic.getId(), message.getExternalSystemId(), message.getTopic().getExternalObjects(), getExternalObjectExtractionPolicy(message), externalObjectManagement); LOG.debug("Blog was successfully updated"); TopicReplyMessage replyMessage = new TopicReplyMessage(); updatedTopic = getTopicManagement().getBlogById(updatedTopic.getId(), true); replyMessage .setTopic(new TopicConverter(getPropertyManagement()).convertBlogToTopic( updatedTopic, externalObjectManagement.getExternalObjects(updatedTopic.getId()))); return replyMessage; } catch (NonUniqueBlogIdentifierException e) { LOG.error("Alias " + message.getTopic().getTopicAlias() + " cannot be used, since it already exists"); throw e; } catch (BlogIdentifierValidationException e) { LOG.error("Alias " + message.getTopic().getTopicAlias() + " is not valid"); throw e; } catch (BlogAccessException e) { LOG.error(e.getMessage(), e); throw e; } }
EditTopicMessageHandler extends
        CommunoteMessageHandler<EditTopicMessage> { @Override public CommunoteReplyMessage handleMessage(EditTopicMessage message) throws Exception { try { LOG.debug("Message is received by EditTopicMessageHandler."); validateMessage(message); Blog existingTopic = getExistingTopic(message.getTopic(), message.isUpdateAlias()); if (existingTopic == null) { LOG.error("There exists no topic with id == " + message.getTopic().getTopicId() + " or alias == " + message.getTopic().getTopicAlias()); throw new BlogNotFoundException("No Topic was found", message .getTopic().getTopicId(), message.getTopic() .getTopicAlias()); } BlogTO topicTO = createTopicTO(message, existingTopic); Blog updatedTopic = getTopicManagement().updateBlog(existingTopic.getId(), topicTO); Topic mqTopic = message.getTopic(); if (message.isUpdateTopicRights() && mqTopic.getTopicRights() != null) { getTopicRightsManagement().setAllCanReadAllCanWrite(existingTopic.getId(), mqTopic.getTopicRights().isAllCanRead(), mqTopic.getTopicRights().isAllCanWrite()); } ExternalObjectManagement externalObjectManagement = getExternalObjectManagement(); TopicMessageHandlerUtils.updateExternalObjects(updatedTopic.getId(), message.getExternalSystemId(), message.getTopic().getExternalObjects(), getExternalObjectExtractionPolicy(message), externalObjectManagement); LOG.debug("Blog was successfully updated"); TopicReplyMessage replyMessage = new TopicReplyMessage(); updatedTopic = getTopicManagement().getBlogById(updatedTopic.getId(), true); replyMessage .setTopic(new TopicConverter(getPropertyManagement()).convertBlogToTopic( updatedTopic, externalObjectManagement.getExternalObjects(updatedTopic.getId()))); return replyMessage; } catch (NonUniqueBlogIdentifierException e) { LOG.error("Alias " + message.getTopic().getTopicAlias() + " cannot be used, since it already exists"); throw e; } catch (BlogIdentifierValidationException e) { LOG.error("Alias " + message.getTopic().getTopicAlias() + " is not valid"); throw e; } catch (BlogAccessException e) { LOG.error(e.getMessage(), e); throw e; } } }
EditTopicMessageHandler extends
        CommunoteMessageHandler<EditTopicMessage> { @Override public CommunoteReplyMessage handleMessage(EditTopicMessage message) throws Exception { try { LOG.debug("Message is received by EditTopicMessageHandler."); validateMessage(message); Blog existingTopic = getExistingTopic(message.getTopic(), message.isUpdateAlias()); if (existingTopic == null) { LOG.error("There exists no topic with id == " + message.getTopic().getTopicId() + " or alias == " + message.getTopic().getTopicAlias()); throw new BlogNotFoundException("No Topic was found", message .getTopic().getTopicId(), message.getTopic() .getTopicAlias()); } BlogTO topicTO = createTopicTO(message, existingTopic); Blog updatedTopic = getTopicManagement().updateBlog(existingTopic.getId(), topicTO); Topic mqTopic = message.getTopic(); if (message.isUpdateTopicRights() && mqTopic.getTopicRights() != null) { getTopicRightsManagement().setAllCanReadAllCanWrite(existingTopic.getId(), mqTopic.getTopicRights().isAllCanRead(), mqTopic.getTopicRights().isAllCanWrite()); } ExternalObjectManagement externalObjectManagement = getExternalObjectManagement(); TopicMessageHandlerUtils.updateExternalObjects(updatedTopic.getId(), message.getExternalSystemId(), message.getTopic().getExternalObjects(), getExternalObjectExtractionPolicy(message), externalObjectManagement); LOG.debug("Blog was successfully updated"); TopicReplyMessage replyMessage = new TopicReplyMessage(); updatedTopic = getTopicManagement().getBlogById(updatedTopic.getId(), true); replyMessage .setTopic(new TopicConverter(getPropertyManagement()).convertBlogToTopic( updatedTopic, externalObjectManagement.getExternalObjects(updatedTopic.getId()))); return replyMessage; } catch (NonUniqueBlogIdentifierException e) { LOG.error("Alias " + message.getTopic().getTopicAlias() + " cannot be used, since it already exists"); throw e; } catch (BlogIdentifierValidationException e) { LOG.error("Alias " + message.getTopic().getTopicAlias() + " is not valid"); throw e; } catch (BlogAccessException e) { LOG.error(e.getMessage(), e); throw e; } }  }
EditTopicMessageHandler extends
        CommunoteMessageHandler<EditTopicMessage> { @Override public CommunoteReplyMessage handleMessage(EditTopicMessage message) throws Exception { try { LOG.debug("Message is received by EditTopicMessageHandler."); validateMessage(message); Blog existingTopic = getExistingTopic(message.getTopic(), message.isUpdateAlias()); if (existingTopic == null) { LOG.error("There exists no topic with id == " + message.getTopic().getTopicId() + " or alias == " + message.getTopic().getTopicAlias()); throw new BlogNotFoundException("No Topic was found", message .getTopic().getTopicId(), message.getTopic() .getTopicAlias()); } BlogTO topicTO = createTopicTO(message, existingTopic); Blog updatedTopic = getTopicManagement().updateBlog(existingTopic.getId(), topicTO); Topic mqTopic = message.getTopic(); if (message.isUpdateTopicRights() && mqTopic.getTopicRights() != null) { getTopicRightsManagement().setAllCanReadAllCanWrite(existingTopic.getId(), mqTopic.getTopicRights().isAllCanRead(), mqTopic.getTopicRights().isAllCanWrite()); } ExternalObjectManagement externalObjectManagement = getExternalObjectManagement(); TopicMessageHandlerUtils.updateExternalObjects(updatedTopic.getId(), message.getExternalSystemId(), message.getTopic().getExternalObjects(), getExternalObjectExtractionPolicy(message), externalObjectManagement); LOG.debug("Blog was successfully updated"); TopicReplyMessage replyMessage = new TopicReplyMessage(); updatedTopic = getTopicManagement().getBlogById(updatedTopic.getId(), true); replyMessage .setTopic(new TopicConverter(getPropertyManagement()).convertBlogToTopic( updatedTopic, externalObjectManagement.getExternalObjects(updatedTopic.getId()))); return replyMessage; } catch (NonUniqueBlogIdentifierException e) { LOG.error("Alias " + message.getTopic().getTopicAlias() + " cannot be used, since it already exists"); throw e; } catch (BlogIdentifierValidationException e) { LOG.error("Alias " + message.getTopic().getTopicAlias() + " is not valid"); throw e; } catch (BlogAccessException e) { LOG.error(e.getMessage(), e); throw e; } }  ExternalObjectManagement getExternalObjectManagement(); @Override Class<EditTopicMessage> getHandledMessageClass(); @Override String getVersion(); @Override CommunoteReplyMessage handleMessage(EditTopicMessage message); @Validate void init(); void setExternalObjectManagement(ExternalObjectManagement externalObjectManagement); void setPropertyManagement(PropertyManagement propertyManagement); void validateMessage(EditTopicMessage message); }
EditTopicMessageHandler extends
        CommunoteMessageHandler<EditTopicMessage> { @Override public CommunoteReplyMessage handleMessage(EditTopicMessage message) throws Exception { try { LOG.debug("Message is received by EditTopicMessageHandler."); validateMessage(message); Blog existingTopic = getExistingTopic(message.getTopic(), message.isUpdateAlias()); if (existingTopic == null) { LOG.error("There exists no topic with id == " + message.getTopic().getTopicId() + " or alias == " + message.getTopic().getTopicAlias()); throw new BlogNotFoundException("No Topic was found", message .getTopic().getTopicId(), message.getTopic() .getTopicAlias()); } BlogTO topicTO = createTopicTO(message, existingTopic); Blog updatedTopic = getTopicManagement().updateBlog(existingTopic.getId(), topicTO); Topic mqTopic = message.getTopic(); if (message.isUpdateTopicRights() && mqTopic.getTopicRights() != null) { getTopicRightsManagement().setAllCanReadAllCanWrite(existingTopic.getId(), mqTopic.getTopicRights().isAllCanRead(), mqTopic.getTopicRights().isAllCanWrite()); } ExternalObjectManagement externalObjectManagement = getExternalObjectManagement(); TopicMessageHandlerUtils.updateExternalObjects(updatedTopic.getId(), message.getExternalSystemId(), message.getTopic().getExternalObjects(), getExternalObjectExtractionPolicy(message), externalObjectManagement); LOG.debug("Blog was successfully updated"); TopicReplyMessage replyMessage = new TopicReplyMessage(); updatedTopic = getTopicManagement().getBlogById(updatedTopic.getId(), true); replyMessage .setTopic(new TopicConverter(getPropertyManagement()).convertBlogToTopic( updatedTopic, externalObjectManagement.getExternalObjects(updatedTopic.getId()))); return replyMessage; } catch (NonUniqueBlogIdentifierException e) { LOG.error("Alias " + message.getTopic().getTopicAlias() + " cannot be used, since it already exists"); throw e; } catch (BlogIdentifierValidationException e) { LOG.error("Alias " + message.getTopic().getTopicAlias() + " is not valid"); throw e; } catch (BlogAccessException e) { LOG.error(e.getMessage(), e); throw e; } }  ExternalObjectManagement getExternalObjectManagement(); @Override Class<EditTopicMessage> getHandledMessageClass(); @Override String getVersion(); @Override CommunoteReplyMessage handleMessage(EditTopicMessage message); @Validate void init(); void setExternalObjectManagement(ExternalObjectManagement externalObjectManagement); void setPropertyManagement(PropertyManagement propertyManagement); void validateMessage(EditTopicMessage message);  }