protected void checkPopulatedServiceContext(
      ServiceContext serviceContext, WikiPage page, boolean hasExpandoValues) throws Exception {

    long[] assetCategoryIds =
        AssetCategoryLocalServiceUtil.getCategoryIds(
            WikiPage.class.getName(), page.getResourcePrimKey());

    Assert.assertArrayEquals(serviceContext.getAssetCategoryIds(), assetCategoryIds);

    AssetEntry assetEntry =
        AssetEntryLocalServiceUtil.getEntry(WikiPage.class.getName(), page.getResourcePrimKey());

    List<AssetLink> assetLinks = AssetLinkLocalServiceUtil.getLinks(assetEntry.getEntryId());

    long[] assetLinkEntryIds = ListUtil.toLongArray(assetLinks, AssetLink.ENTRY_ID2_ACCESSOR);

    Assert.assertArrayEquals(serviceContext.getAssetLinkEntryIds(), assetLinkEntryIds);

    String[] assetTagNames =
        AssetTagLocalServiceUtil.getTagNames(WikiPage.class.getName(), page.getResourcePrimKey());

    Assert.assertArrayEquals(serviceContext.getAssetTagNames(), assetTagNames);

    if (hasExpandoValues) {
      ExpandoBridge expandoBridge = page.getExpandoBridge();

      AssertUtils.assertEquals(
          expandoBridge.getAttributes(), serviceContext.getExpandoBridgeAttributes());
    }
  }
Esempio n. 2
0
  public void addAssetTags(Class<?> clazz, long classPK) throws SystemException {

    String[] tagNames = AssetTagLocalServiceUtil.getTagNames(clazz.getName(), classPK);

    if (tagNames.length == 0) {
      return;
    }

    _assetTagNamesMap.put(getPrimaryKeyString(clazz, classPK), tagNames);
  }
Esempio n. 3
0
  @Override
  protected Document doGetDocument(Object obj) throws Exception {
    DLFileEntry dlFileEntry = (DLFileEntry) obj;

    FileModel fileModel = new FileModel();

    long[] assetCategoryIds =
        AssetCategoryLocalServiceUtil.getCategoryIds(
            DLFileEntry.class.getName(), dlFileEntry.getFileEntryId());

    fileModel.setAssetCategoryIds(assetCategoryIds);

    String[] assetCategoryNames =
        AssetCategoryLocalServiceUtil.getCategoryNames(
            DLFileEntry.class.getName(), dlFileEntry.getFileEntryId());

    fileModel.setAssetCategoryNames(assetCategoryNames);

    String[] assetTagNames =
        AssetTagLocalServiceUtil.getTagNames(
            DLFileEntry.class.getName(), dlFileEntry.getFileEntryId());

    fileModel.setAssetTagNames(assetTagNames);

    fileModel.setCompanyId(dlFileEntry.getCompanyId());
    fileModel.setCreateDate(dlFileEntry.getCreateDate());
    fileModel.setFileEntryId(dlFileEntry.getFileEntryId());
    fileModel.setFileName(dlFileEntry.getName());
    fileModel.setGroupId(dlFileEntry.getGroupId());
    fileModel.setModifiedDate(dlFileEntry.getModifiedDate());
    fileModel.setPortletId(PORTLET_ID);
    fileModel.setProperties(dlFileEntry.getLuceneProperties());
    fileModel.setRepositoryId(dlFileEntry.getDataRepositoryId());
    fileModel.setUserId(dlFileEntry.getUserId());
    fileModel.setUserName(dlFileEntry.getUserName());
    fileModel.setUserUuid(dlFileEntry.getUserUuid());

    Indexer indexer = IndexerRegistryUtil.getIndexer(FileModel.class);

    return indexer.getDocument(fileModel);
  }
 @Override
 public String[] getAssetTagNames() throws SystemException {
   return AssetTagLocalServiceUtil.getTagNames(MBMessage.class.getName(), getMessageId());
 }
Esempio n. 5
0
  public int putResource(WebDAVRequest webDavRequest) throws WebDAVException {
    File file = null;

    try {
      HttpServletRequest request = webDavRequest.getHttpServletRequest();

      String[] pathArray = webDavRequest.getPathArray();

      long companyId = webDavRequest.getCompanyId();
      long groupId = webDavRequest.getGroupId();
      long parentFolderId = getParentFolderId(companyId, pathArray);
      String name = WebDAVUtil.getResourceName(pathArray);
      String description = StringPool.BLANK;

      file = FileUtil.createTempFile(FileUtil.getExtension(name));

      FileUtil.write(file, request.getInputStream());

      String contentType = MimeTypesUtil.getContentType(name);

      ServiceContext serviceContext = new ServiceContext();

      serviceContext.setAddCommunityPermissions(isAddCommunityPermissions(groupId));
      serviceContext.setAddGuestPermissions(true);

      try {
        IGImage image =
            IGImageServiceUtil.getImageByFolderIdAndNameWithExtension(
                groupId, parentFolderId, name);

        long imageId = image.getImageId();

        description = image.getDescription();

        String[] assetTagNames =
            AssetTagLocalServiceUtil.getTagNames(IGImage.class.getName(), imageId);

        serviceContext.setAssetTagNames(assetTagNames);

        IGImageServiceUtil.updateImage(
            imageId, groupId, parentFolderId, name, description, file, contentType, serviceContext);
      } catch (NoSuchImageException nsie) {
        IGImageServiceUtil.addImage(
            groupId, parentFolderId, name, description, file, contentType, serviceContext);
      }

      return HttpServletResponse.SC_CREATED;
    } catch (PrincipalException pe) {
      return HttpServletResponse.SC_FORBIDDEN;
    } catch (PortalException pe) {
      if (_log.isWarnEnabled()) {
        _log.warn(pe, pe);
      }

      return HttpServletResponse.SC_CONFLICT;
    } catch (Exception e) {
      throw new WebDAVException(e);
    } finally {
      if (file != null) {
        file.delete();
      }
    }
  }