private CreateContentCommand createCreateContentCommand(
     String categoryName, ContentData contentData, String creatorUid) {
   CreateContentCommand createContentCommand = new CreateContentCommand();
   createContentCommand.setCategory(fixture.findCategoryByName(categoryName));
   createContentCommand.setCreator(fixture.findUserByName(creatorUid).getKey());
   createContentCommand.setLanguage(fixture.findLanguageByCode("en"));
   createContentCommand.setStatus(ContentStatus.APPROVED);
   createContentCommand.setPriority(0);
   createContentCommand.setAccessRightsStrategy(
       CreateContentCommand.AccessRightsStrategy.INHERIT_FROM_CATEGORY);
   createContentCommand.setContentData(contentData);
   createContentCommand.setAvailableFrom(DATE_TIME_2010_01_01.toDate());
   createContentCommand.setAvailableTo(null);
   createContentCommand.setContentName("testcontent");
   return createContentCommand;
 }
コード例 #2
0
  private ContentKey createImageContent(
      String name,
      int contentStatus,
      byte[] bytes,
      String categoryName,
      DateTime availableFrom,
      DateTime availableTo)
      throws IOException {
    ImageContentDataInput imageContentDataInput = new ImageContentDataInput();
    imageContentDataInput.name = new ImageNameInput(name);
    imageContentDataInput.binary = new ImageBinaryInput(bytes, name);

    CreateImageContentParams params = new CreateImageContentParams();
    params.categoryKey = fixture.findCategoryByName(categoryName).getKey().toInt();
    params.publishFrom = availableFrom != null ? availableFrom.toDate() : null;
    params.publishTo = availableTo != null ? availableTo.toDate() : null;
    params.status = contentStatus;
    params.contentData = imageContentDataInput;

    return new ContentKey(internalClientContentService.createImageContent(params));
  }