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

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

Introduction

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

Prototype

public long getRepositoryId();

Source Link

Usage

From source file:com.liferay.portlet.documentlibrary.webdav.DLWebDAVStorageImpl.java

License:Open Source License

protected long getFolderId(long companyId, String[] pathArray, boolean parent) throws Exception {

    long folderId = DLFolderConstants.DEFAULT_PARENT_FOLDER_ID;

    if (pathArray.length <= 1) {
        return folderId;
    } else {/*w ww .j a  v  a 2 s  .c  o  m*/
        long groupId = WebDAVUtil.getGroupId(companyId, pathArray);

        int x = pathArray.length;

        if (parent) {
            x--;
        }

        for (int i = 2; i < x; i++) {
            String name = pathArray[i];

            Folder folder = DLAppServiceUtil.getFolder(groupId, folderId, name);

            if (groupId == folder.getRepositoryId()) {
                folderId = folder.getFolderId();
            }
        }
    }

    return folderId;
}

From source file:com.liferay.sync.messaging.SyncMessageListener.java

License:Open Source License

protected void addSyncDLObject(long modifiedTime, String event, String type, long typePK) throws Exception {

    if (event.equals(DLSyncConstants.EVENT_DELETE)) {
        SyncDLObjectLocalServiceUtil.addSyncDLObject(0, modifiedTime, 0, 0, StringPool.BLANK, StringPool.BLANK,
                StringPool.BLANK, StringPool.BLANK, StringPool.BLANK, StringPool.BLANK, StringPool.BLANK, 0,
                StringPool.BLANK, event, null, 0, StringPool.BLANK, type, typePK, StringPool.BLANK);
    } else if (type.equals(DLSyncConstants.TYPE_FILE)) {
        FileEntry fileEntry = null;/*w w w  .j  av a2s .c  o  m*/

        try {
            fileEntry = DLAppLocalServiceUtil.getFileEntry(typePK);
        } catch (NoSuchFileEntryException nsfee) {
            return;
        }

        Date lockExpirationDate = null;
        long lockUserId = 0;
        String lockUserName = StringPool.BLANK;

        Lock lock = fileEntry.getLock();

        if (lock != null) {
            lockExpirationDate = lock.getExpirationDate();
            lockUserId = lock.getUserId();
            lockUserName = lock.getUserName();
        }

        DLFileVersion dlFileVersion = DLFileVersionLocalServiceUtil
                .getLatestFileVersion(fileEntry.getFileEntryId(), false);

        SyncDLObjectLocalServiceUtil.addSyncDLObject(dlFileVersion.getCompanyId(), modifiedTime,
                dlFileVersion.getRepositoryId(), fileEntry.getFolderId(), dlFileVersion.getTitle(),
                dlFileVersion.getExtension(), dlFileVersion.getMimeType(), dlFileVersion.getDescription(),
                dlFileVersion.getChangeLog(), dlFileVersion.getExtraSettings(), dlFileVersion.getVersion(),
                dlFileVersion.getSize(), SyncUtil.getChecksum(dlFileVersion), event, lockExpirationDate,
                lockUserId, lockUserName, type, fileEntry.getFileEntryId(), fileEntry.getUuid());
    } else {
        Folder folder = null;

        try {
            folder = DLAppLocalServiceUtil.getFolder(typePK);
        } catch (NoSuchFolderException nsfe) {
            return;
        }

        SyncDLObjectLocalServiceUtil.addSyncDLObject(folder.getCompanyId(), modifiedTime,
                folder.getRepositoryId(), folder.getParentFolderId(), folder.getName(), StringPool.BLANK,
                StringPool.BLANK, folder.getDescription(), StringPool.BLANK, StringPool.BLANK, "-1", 0,
                StringPool.BLANK, event, null, 0, StringPool.BLANK, type, folder.getFolderId(),
                folder.getUuid());
    }
}

From source file:com.liferay.testopensocialoauthconsumer.messaging.TestOpenSocialOAuthConsumerHotDeployMessageListener.java

License:Open Source License

protected void setupGadget() throws Exception {
    Class<?> clazz = getClass();

    ClassLoader classLoader = clazz.getClassLoader();

    long companyId = PortalUtil.getDefaultCompanyId();

    User user = UserLocalServiceUtil.getDefaultUser(companyId);
    Group group = GroupLocalServiceUtil.getCompanyGroup(companyId);

    Folder gadgetEditorRootFolder = getGadgetEditorRootFolder(user.getUserId(), group.getGroupId());

    FileEntry fileEntry = null;/*from  w w  w. j  a  v a 2s .c om*/

    try {
        fileEntry = DLAppLocalServiceUtil.getFileEntry(group.getGroupId(), gadgetEditorRootFolder.getFolderId(),
                _GADGET_FILE_NAME);
    } catch (NoSuchFileEntryException nsfee) {
        InputStream inputStream = classLoader
                .getResourceAsStream("/resources/gadgets/".concat(_GADGET_FILE_NAME));

        String xml = new String(FileUtil.getBytes(inputStream));

        xml = StringUtil.replace(xml,
                new String[] { "[$ACCESS_URL$]", "[$AUTHORIZATION_URL$]", "[$FOLDER_ID$]", "[$PORTAL_URL$]",
                        "[$REPOSITORY_ID$]", "[$REQUEST_URL$]" },
                new String[] { "/c/portal/oauth/access_token", "/c/portal/oauth/authorize",
                        String.valueOf(gadgetEditorRootFolder.getFolderId()), "http://localhost:8080",
                        String.valueOf(group.getGroupId()), "/c/portal/oauth/request_token" });

        ServiceContext serviceContext = new ServiceContext();

        serviceContext.setAddGroupPermissions(true);
        serviceContext.setAddGuestPermissions(true);
        serviceContext.setScopeGroupId(group.getGroupId());

        serviceContext.setAttribute("sourceFileName", _GADGET_FILE_NAME);

        fileEntry = DLAppLocalServiceUtil.addFileEntry(user.getUserId(),
                gadgetEditorRootFolder.getRepositoryId(), gadgetEditorRootFolder.getFolderId(),
                _GADGET_FILE_NAME, ContentTypes.APPLICATION_X_WWW_FORM_URLENCODED_UTF8, _GADGET_FILE_NAME,
                StringPool.BLANK, StringPool.BLANK, xml.getBytes(StringPool.UTF8), serviceContext);
    }

    Gadget gadget = GadgetLocalServiceUtil.fetchGadget(companyId, getFileEntryURL(fileEntry));

    if (gadget == null) {
        ServiceContext serviceContext = new ServiceContext();

        serviceContext.setAddGroupPermissions(true);
        serviceContext.setAddGuestPermissions(true);
        serviceContext.setScopeGroupId(group.getGroupId());

        GadgetLocalServiceUtil.addGadget(companyId, getFileEntryURL(fileEntry), _PORTLET_CATEGORY_NAMES,
                serviceContext);
    }
}

From source file:com.rivetlogic.tree.view.model.documentlibrary.DLFolder.java

License:Open Source License

public DLFolder(Folder folder) {
    this.setFolderId(folder.getFolderId());
    this.setName(folder.getName());
    this.setParentFolderId(folder.getParentFolderId());
    this.setRepositoryId(folder.getRepositoryId());
    this.deletePermission = false;
    this.updatePermission = false;
    this.rowCheckerId = String.valueOf(folder.getFolderId());
    this.rowCheckerName = Folder.class.getSimpleName();
}