Пример #1
0
  //	@Transactional(TransactionPropagationType.REQUIRED)
  //	@TransactionAttribute(TransactionAttributeType.REQUIRED)
  @Override
  public ContentItem createMediaContentItem(byte[] data, String mimeType, String fileName) {

    ContentItem contentItem = createContentItem();

    UpdateMediaContentService updateMediaContentService =
        (UpdateMediaContentService) Component.getInstance("updateMediaContentService");

    MediaContent mediaContent = new MediaContent(contentItem);
    mediaContent.setData(data);
    mediaContent.setMimeType(mimeType);
    mediaContent.setFileName(fileName);
    entityManager.persist(mediaContent);

    updateMediaContentService.createMediaContentUpdate(contentItem, mediaContent);
    //		entityManager.persist(mediaContent);
    //
    //		contentItem.setMediaContent(mediaContent);
    //
    saveContentItem(contentItem);

    Events.instance().raiseEvent(KiWiEvents.ACTIVITY_EDITCONTENTITEM, currentUser, contentItem);
    Events.instance().raiseTransactionSuccessEvent(KiWiEvents.CONTENT_UPDATED, contentItem);
    return contentItem;
  }
Пример #2
0
  /**
   * Update the multimedia content of the item passed as argument, using the data, mime type and
   * filename provided. The method persists the updated content item and media content and creates a
   * new revision for the content item.
   *
   * @param item the content item containing the media data
   * @param data the data as byte array
   * @param mimeType the mime type in string format
   * @param fileName the file name of the media content (for downloading)
   */
  @Override
  public void updateMediaContentItem(
      ContentItem item, byte[] data, String mimeType, String fileName) {

    UpdateMediaContentService updateMediaContentService =
        (UpdateMediaContentService) Component.getInstance("updateMediaContentService");

    MediaContent mediaContent = new MediaContent(item);
    mediaContent.setData(data);
    mediaContent.setMimeType(mimeType);
    mediaContent.setFileName(fileName);
    entityManager.persist(mediaContent);

    updateMediaContentService.createMediaContentUpdate(item, mediaContent);

    saveContentItem(item);

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