Example usage for com.liferay.portal.kernel.repository.model Folder getFolderId

List of usage examples for com.liferay.portal.kernel.repository.model Folder getFolderId

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.repository.model Folder getFolderId.

Prototype

public long getFolderId();

Source Link

Usage

From source file:com.liferay.document.library.internal.repository.capabilities.TemporaryFileEntriesCapabilityImpl.java

License:Open Source License

protected Folder addFolders(long userId, long folderId, String folderPath, ServiceContext serviceContext)
        throws PortalException {

    Folder folder = null;

    String[] folderNames = StringUtil.split(folderPath, StringPool.SLASH);

    for (String folderName : folderNames) {
        folder = addFolder(userId, folderId, folderName, serviceContext);

        folderId = folder.getFolderId();
    }//from  www.ja  v a  2s. c  om

    return folder;
}

From source file:com.liferay.document.library.internal.repository.capabilities.TemporaryFileEntriesCapabilityImpl.java

License:Open Source License

protected Folder getDeepestFolder(long parentFolderId, String folderPath) throws PortalException {

    Folder folder = null;

    String[] folderNames = StringUtil.split(folderPath, StringPool.SLASH);

    for (String folderName : folderNames) {
        folder = _documentRepository.getFolder(parentFolderId, folderName);

        parentFolderId = folder.getFolderId();
    }// w w w.jav  a 2  s  .c om

    return folder;
}

From source file:com.liferay.document.library.internal.service.DLFileRankDLAppHelperLocalServiceWrapper.java

License:Open Source License

@Override
public Folder moveFolderFromTrash(long userId, Folder folder, long parentFolderId,
        ServiceContext serviceContext) throws PortalException {

    Folder curFolder = super.moveFolderFromTrash(userId, folder, parentFolderId, serviceContext);

    DLFolder dlFolder = (DLFolder) folder.getModel();

    if (dlFolder.isInTrashExplicitly()) {
        return curFolder;
    }/* w w  w  .  j  av  a  2 s.  c o  m*/

    _dlFileRankLocalService.enableFileRanksByFolderId(folder.getFolderId());

    return curFolder;
}

From source file:com.liferay.document.library.internal.service.DLFileRankDLAppHelperLocalServiceWrapper.java

License:Open Source License

@Override
public Folder moveFolderToTrash(long userId, Folder folder) throws PortalException {

    Folder curFolder = super.moveFolderToTrash(userId, folder);

    _dlFileRankLocalService.disableFileRanksByFolderId(folder.getFolderId());

    return curFolder;
}

From source file:com.liferay.document.library.internal.service.DLFileRankDLAppHelperLocalServiceWrapper.java

License:Open Source License

@Override
public void restoreFolderFromTrash(long userId, Folder folder) throws PortalException {

    super.restoreFolderFromTrash(userId, folder);

    _dlFileRankLocalService.enableFileRanksByFolderId(folder.getFolderId());
}

From source file:com.liferay.document.library.internal.service.SubscriptionDLAppHelperLocalServiceWrapper.java

License:Open Source License

@Override
public void deleteFolder(Folder folder) throws PortalException {
    if (!_isEnabled(folder)) {
        return;//from   ww  w. java 2  s  . c  o  m
    }

    super.deleteFolder(folder);

    _subscriptionLocalService.deleteSubscriptions(folder.getCompanyId(), DLFolderConstants.getClassName(),
            folder.getFolderId());
}

From source file:com.liferay.document.library.internal.service.SubscriptionDLAppHelperLocalServiceWrapper.java

License:Open Source License

protected void notifySubscribers(long userId, FileVersion fileVersion, String entryURL,
        ServiceContext serviceContext) throws PortalException {

    if (!fileVersion.isApproved() || Validator.isNull(entryURL)) {
        return;/*from   www. j a v  a  2s.  c  om*/
    }

    DLGroupServiceSettings dlGroupServiceSettings = DLGroupServiceSettings
            .getInstance(fileVersion.getGroupId());

    boolean commandUpdate = false;

    if (serviceContext.isCommandUpdate() || Constants.CHECKIN.equals(serviceContext.getCommand())) {

        commandUpdate = true;
    }

    if (serviceContext.isCommandAdd() && dlGroupServiceSettings.isEmailFileEntryAddedEnabled()) {
    } else if (commandUpdate && dlGroupServiceSettings.isEmailFileEntryUpdatedEnabled()) {
    } else {
        return;
    }

    String entryTitle = fileVersion.getTitle();

    String fromName = dlGroupServiceSettings.getEmailFromName();
    String fromAddress = dlGroupServiceSettings.getEmailFromAddress();

    LocalizedValuesMap subjectLocalizedValuesMap = null;
    LocalizedValuesMap bodyLocalizedValuesMap = null;

    if (commandUpdate) {
        subjectLocalizedValuesMap = dlGroupServiceSettings.getEmailFileEntryUpdatedSubject();
        bodyLocalizedValuesMap = dlGroupServiceSettings.getEmailFileEntryUpdatedBody();
    } else {
        subjectLocalizedValuesMap = dlGroupServiceSettings.getEmailFileEntryAddedSubject();
        bodyLocalizedValuesMap = dlGroupServiceSettings.getEmailFileEntryAddedBody();
    }

    FileEntry fileEntry = fileVersion.getFileEntry();

    Folder folder = null;

    long folderId = fileEntry.getFolderId();

    if (folderId != DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
        folder = _dlAppLocalService.getFolder(folderId);
    }

    SubscriptionSender subscriptionSender = new GroupSubscriptionCheckSubscriptionSender(
            DLPermission.RESOURCE_NAME);

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

    DLFileEntryType dlFileEntryType = _dlFileEntryTypeLocalService
            .getDLFileEntryType(dlFileEntry.getFileEntryTypeId());

    subscriptionSender.setClassPK(fileVersion.getFileEntryId());
    subscriptionSender.setClassName(DLFileEntryConstants.getClassName());
    subscriptionSender.setCompanyId(fileVersion.getCompanyId());

    if (folder != null) {
        subscriptionSender.setContextAttribute("[$FOLDER_NAME$]", folder.getName(), true);
    } else {
        subscriptionSender.setLocalizedContextAttribute("[$FOLDER_NAME$]",
                new EscapableLocalizableFunction(locale -> LanguageUtil.get(locale, "home")));
    }

    subscriptionSender.setContextAttributes("[$DOCUMENT_STATUS_BY_USER_NAME$]",
            fileVersion.getStatusByUserName(), "[$DOCUMENT_TITLE$]", entryTitle, "[$DOCUMENT_URL$]", entryURL);
    subscriptionSender.setContextCreatorUserPrefix("DOCUMENT");
    subscriptionSender.setCreatorUserId(fileVersion.getUserId());
    subscriptionSender.setCurrentUserId(userId);
    subscriptionSender.setEntryTitle(entryTitle);
    subscriptionSender.setEntryURL(entryURL);
    subscriptionSender.setFrom(fromAddress, fromName);
    subscriptionSender.setHtmlFormat(true);
    subscriptionSender.setLocalizedBodyMap(LocalizationUtil.getMap(bodyLocalizedValuesMap));
    subscriptionSender.setLocalizedContextAttribute("[$DOCUMENT_TYPE$]",
            new EscapableLocalizableFunction(locale -> dlFileEntryType.getName(locale)));
    subscriptionSender.setLocalizedSubjectMap(LocalizationUtil.getMap(subjectLocalizedValuesMap));
    subscriptionSender.setMailId("file_entry", fileVersion.getFileEntryId());

    int notificationType = UserNotificationDefinition.NOTIFICATION_TYPE_ADD_ENTRY;

    if (commandUpdate) {
        notificationType = UserNotificationDefinition.NOTIFICATION_TYPE_UPDATE_ENTRY;
    }

    subscriptionSender.setNotificationType(notificationType);

    String portletId = PortletProviderUtil.getPortletId(FileEntry.class.getName(), PortletProvider.Action.VIEW);

    subscriptionSender.setPortletId(portletId);

    subscriptionSender.setReplyToAddress(fromAddress);
    subscriptionSender.setScopeGroupId(fileVersion.getGroupId());
    subscriptionSender.setServiceContext(serviceContext);

    subscriptionSender.addPersistedSubscribers(DLFolder.class.getName(), fileVersion.getGroupId());

    if (folder != null) {
        subscriptionSender.addPersistedSubscribers(DLFolder.class.getName(), folder.getFolderId());

        for (Long ancestorFolderId : folder.getAncestorFolderIds()) {
            subscriptionSender.addPersistedSubscribers(DLFolder.class.getName(), ancestorFolderId);
        }
    }

    if (dlFileEntryType.getFileEntryTypeId() == DLFileEntryTypeConstants.FILE_ENTRY_TYPE_ID_BASIC_DOCUMENT) {

        subscriptionSender.addPersistedSubscribers(DLFileEntryType.class.getName(), fileVersion.getGroupId());
    } else {
        subscriptionSender.addPersistedSubscribers(DLFileEntryType.class.getName(),
                dlFileEntryType.getFileEntryTypeId());
    }

    subscriptionSender.addPersistedSubscribers(DLFileEntry.class.getName(), fileEntry.getFileEntryId());

    subscriptionSender.flushNotificationsAsync();
}

From source file:com.liferay.document.library.jaxrs.FolderRepr.java

License:Open Source License

public static FolderRepr fromFolder(Folder folder, List<RepositoryContentObject> repositoryContentObjects,
        UriBuilder uriBuilder) {/*  w  ww  .j  a  v a 2  s.c  o  m*/

    String url = uriBuilder.build(Long.toString(folder.getFolderId())).toString();

    return new FolderRepr(folder.getRepositoryId(), folder.getFolderId(), folder.getDescription(),
            folder.getCreateDate(), folder.getName(), repositoryContentObjects, url);
}

From source file:com.liferay.document.library.jaxrs.FolderResource.java

License:Open Source License

public FolderResource(DLAppService dlAppService, final Folder folder, UriBuilder folderUriBuilder,
        UriBuilder fileUriBuilder) {/*from   w w  w.  j  a v a  2s  . c  om*/

    _dlAppService = dlAppService;
    _folderUriBuilder = folderUriBuilder;
    _fileUriBuilder = fileUriBuilder;
    _folderId = folder.getFolderId();

    _repositoryId = folder.getRepositoryId();
    _folderReprFunction = contents -> FolderRepr.fromFolder(folder, contents, _folderUriBuilder);
}

From source file:com.liferay.document.library.jaxrs.FolderResource.java

License:Open Source License

protected RepositoryContentObject toObjectRepository(Object rco) {
    if (rco instanceof FileEntry) {
        FileEntry fileEntry = (FileEntry) rco;

        String url = _fileUriBuilder.build(fileEntry.getFileEntryId()).toString();

        return new RepositoryContentObject(fileEntry.getFileEntryId(), fileEntry.getTitle(), url,
                RepositoryContentObject.RepositoryContentType.FILE, fileEntry.getCreateDate(),
                fileEntry.getModifiedDate());
    } else if (rco instanceof Folder) {
        Folder folder = (Folder) rco;

        String url = _folderUriBuilder.build(Long.toString(folder.getFolderId())).toString();

        return new RepositoryContentObject(folder.getFolderId(), folder.getName(), url,
                RepositoryContentObject.RepositoryContentType.FOLDER, folder.getCreateDate(),
                folder.getModifiedDate());
    } else if (rco instanceof FileShortcut) {
        FileShortcut fileShortcut = (FileShortcut) rco;

        String url = _fileUriBuilder.build(Long.toString(fileShortcut.getToFileEntryId())).toString();

        return new RepositoryContentObject(fileShortcut.getFileShortcutId(), fileShortcut.getToTitle(), url,
                RepositoryContentObject.RepositoryContentType.SHORTCUT, fileShortcut.getCreateDate(),
                fileShortcut.getModifiedDate());
    } else {//from w  w  w .  j a  v a 2s .  co  m
        throw new IllegalArgumentException(
                "Object must be an instance of FileEntry, Folder of " + "FileShortcut");
    }
}