Exemplo n.º 1
0
  //	@Transactional(TransactionPropagationType.REQUIRED)
  //	@TransactionAttribute(TransactionAttributeType.REQUIRED)
  public void updateTextContentItem(ContentItemI item, String content) {

    ContentItem _item = item.getDelegate();

    if (renderingPipeline.renderEditor(_item, currentUser).equals(content)) {
      log.error("!!!!!!!!!!!!!!!!! renderingPipeline fails");
      return;
      // throw new TextContentNotChangedException("Could not create TextContentUpdate for an
      // unchanged text content");
    }
    StoringService storingPipeline = (StoringService) Component.getInstance("storingPipeline");

    TextContent tc = new TextContent(_item);
    tc.setXmlString(storingPipeline.processHtmlSource(_item.getResource(), content));
    tc = storingPipeline.processTextContent(_item.getResource(), tc);

    entityManager.persist(tc);

    // TODO: check whether content has changed and create version
    // TODO: maybe we can check this even before the pipeline runs?
    UpdateTextContentService utcs =
        (UpdateTextContentService) Component.getInstance("updateTextContentService");
    if (content != null) {
      utcs.updateTextContent(_item, tc);
    }

    _item.setTextContent(tc);

    Events.instance().raiseEvent(KiWiEvents.ACTIVITY_EDITCONTENTITEM, currentUser, _item);
    Events.instance().raiseTransactionSuccessEvent(KiWiEvents.CONTENT_UPDATED, _item);
  }
Exemplo n.º 2
0
  //	@Transactional(TransactionPropagationType.REQUIRED)
  //	@TransactionAttribute(TransactionAttributeType.REQUIRED)
  public void updateTextContentWithoutStoringPipeline(ContentItemI item, String content)
      throws TextContentNotChangedException {

    ContentItem _item = item.getDelegate();

    if (renderingPipeline.renderEditor(_item, currentUser).equals(content)) {
      log.error("!!!!!!!!!!!!!!!!! renderingPipeline fails");
      throw new TextContentNotChangedException(
          "Could not create TextContentUpdate for an unchanged text content");
    }

    TextContent tc = new TextContent(_item);
    // TODO: can this cause some damage? Maybe we should at least do some regex checking
    tc.setXmlString(content);

    // TODO: check whether content has changed and create version
    UpdateTextContentService utcs =
        (UpdateTextContentService) Component.getInstance("updateTextContentService");
    if (content != null) {
      utcs.updateTextContent(_item, tc);
    }

    _item.setTextContent(tc);

    Events.instance().raiseEvent(KiWiEvents.ACTIVITY_EDITCONTENTITEM, currentUser, _item);
    Events.instance().raiseTransactionSuccessEvent(KiWiEvents.CONTENT_UPDATED, _item);
  }
Exemplo n.º 3
0
  //	@Transactional(TransactionPropagationType.REQUIRED)
  //	@TransactionAttribute(TransactionAttributeType.REQUIRED)
  public void updateTextContentItem(ContentItemI item, Document content) {
    ContentItem _item = item.getDelegate();

    TextContent tc = new TextContent(_item);
    tc.setXmlDocument(content);

    // To check if the content has changed, check whether both contents produce the same output for
    // the editor
    if (_item.getTextContent() != null
        && _item.getTextContent().getXmlString(true).equals(tc.getXmlString(true))) {
      log.error("!!!!!!!!!!!!!!!!! renderingPipeline fails");
      return;
      // throw new TextContentNotChangedException("Could not create TextContentUpdate for an
      // unchanged text content");
    }
    entityManager.persist(tc);

    // TODO: check whether content has changed and create version
    UpdateTextContentService utcs =
        (UpdateTextContentService) Component.getInstance("updateTextContentService");
    if (content != null) {
      utcs.updateTextContent(_item, tc);
    }

    _item.setTextContent(tc);

    Events.instance().raiseEvent(KiWiEvents.ACTIVITY_EDITCONTENTITEM, currentUser, _item);
    Events.instance().raiseTransactionSuccessEvent(KiWiEvents.CONTENT_UPDATED, _item);
  }
Exemplo n.º 4
0
  //	@Transactional(TransactionPropagationType.REQUIRED)
  //	@TransactionAttribute(TransactionAttributeType.REQUIRED)
  @Override
  public ContentItem createTextContentItem(String content) {
    ContentItem item = createContentItem();

    StoringService storingPipeline = (StoringService) Component.getInstance("storingPipeline");

    TextContent tc = new TextContent(item);
    tc.setXmlString(storingPipeline.processHtmlSource(item.getResource(), content));
    tc = storingPipeline.processTextContent(item.getResource(), tc);
    entityManager.persist(tc);

    UpdateTextContentService utcs =
        (UpdateTextContentService) Component.getInstance("updateTextContentService");
    if (content != null) {
      utcs.updateTextContent(item, tc);
    }

    item.setTextContent(tc);

    Events.instance().raiseEvent(KiWiEvents.ACTIVITY_EDITCONTENTITEM, currentUser, item);
    Events.instance().raiseTransactionSuccessEvent(KiWiEvents.CONTENT_UPDATED, item);
    return item;
  }