Example usage for com.liferay.portal.kernel.service ServiceContext setAssetLinkEntryIds

List of usage examples for com.liferay.portal.kernel.service ServiceContext setAssetLinkEntryIds

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.service ServiceContext setAssetLinkEntryIds.

Prototype

public void setAssetLinkEntryIds(long[] assetLinkEntryIds) 

Source Link

Document

Sets an array of the primary keys of asset entries to be linked to an asset entry if this service context is being passed as a parameter to a method which manipulates the asset entry.

Usage

From source file:com.liferay.document.library.web.internal.webdav.DLWebDAVStorageImpl.java

License:Open Source License

protected void populateServiceContext(ServiceContext serviceContext, FileEntry fileEntry)
        throws PortalException {

    serviceContext.setScopeGroupId(fileEntry.getGroupId());

    String className = DLFileEntryConstants.getClassName();

    long[] assetCategoryIds = _assetCategoryLocalService.getCategoryIds(className, fileEntry.getFileEntryId());

    serviceContext.setAssetCategoryIds(assetCategoryIds);

    AssetEntry assetEntry = _assetEntryLocalService.fetchEntry(className, fileEntry.getFileEntryId());

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

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

    serviceContext.setAssetLinkEntryIds(assetLinkEntryIds);

    String[] assetTagNames = _assetTagLocalService.getTagNames(className, fileEntry.getFileEntryId());

    serviceContext.setAssetTagNames(assetTagNames);

    ExpandoBridge expandoBridge = fileEntry.getExpandoBridge();

    serviceContext.setExpandoBridgeAttributes(expandoBridge.getAttributes());

    DLFileEntry dlFileEntry = (DLFileEntry) fileEntry.getModel();

    long fileEntryTypeId = dlFileEntry.getFileEntryTypeId();

    if (fileEntryTypeId > 0) {
        serviceContext.setAttribute("fileEntryTypeId", dlFileEntry.getFileEntryTypeId());

        DLFileVersion dlFileVersion = _dlFileVersionLocalService
                .getLatestFileVersion(fileEntry.getFileEntryId(), !dlFileEntry.isCheckedOut());

        DLFileEntryType dlFileEntryType = _dlFileEntryTypeLocalService.getFileEntryType(fileEntryTypeId);

        List<DDMStructure> ddmStructures = dlFileEntryType.getDDMStructures();

        for (DDMStructure ddmStructure : ddmStructures) {
            DLFileEntryMetadata dlFileEntryMetadata = _dlFileEntryMetadataLocalService
                    .fetchFileEntryMetadata(ddmStructure.getStructureId(), dlFileVersion.getFileVersionId());

            if (dlFileEntryMetadata == null) {
                continue;
            }//w ww  .j  a  v  a2s  .  c  o  m

            DDMFormValues ddmFormValues = StorageEngineManagerUtil
                    .getDDMFormValues(dlFileEntryMetadata.getDDMStorageId());

            serviceContext.setAttribute(
                    DDMFormValues.class.getName() + StringPool.POUND + ddmStructure.getStructureId(),
                    ddmFormValues);
        }
    }
}

From source file:com.liferay.document.library.web.webdav.DLWebDAVStorageImpl.java

License:Open Source License

protected void populateServiceContext(ServiceContext serviceContext, FileEntry fileEntry) {

    serviceContext.setScopeGroupId(fileEntry.getGroupId());

    String className = DLFileEntryConstants.getClassName();

    long[] assetCategoryIds = _assetCategoryLocalService.getCategoryIds(className, fileEntry.getFileEntryId());

    serviceContext.setAssetCategoryIds(assetCategoryIds);

    AssetEntry assetEntry = _assetEntryLocalService.fetchEntry(className, fileEntry.getFileEntryId());

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

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

    serviceContext.setAssetLinkEntryIds(assetLinkEntryIds);

    String[] assetTagNames = _assetTagLocalService.getTagNames(className, fileEntry.getFileEntryId());

    serviceContext.setAssetTagNames(assetTagNames);

    ExpandoBridge expandoBridge = fileEntry.getExpandoBridge();

    serviceContext.setExpandoBridgeAttributes(expandoBridge.getAttributes());
}

From source file:com.liferay.wiki.service.impl.WikiPageLocalServiceImpl.java

License:Open Source License

protected void populateServiceContext(ServiceContext serviceContext, WikiPage page) throws PortalException {

    long[] assetCategoryIds = assetCategoryLocalService.getCategoryIds(WikiPage.class.getName(),
            page.getResourcePrimKey());/*w  w w  .j av  a2s .  c  o m*/

    serviceContext.setAssetCategoryIds(assetCategoryIds);

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

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

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

    serviceContext.setAssetLinkEntryIds(assetLinkEntryIds);

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

    serviceContext.setAssetTagNames(assetTagNames);

    ExpandoBridge expandoBridge = page.getExpandoBridge();

    serviceContext.setExpandoBridgeAttributes(expandoBridge.getAttributes());
}