Example usage for com.liferay.portal.kernel.util PortalUtil getCompanyIds

List of usage examples for com.liferay.portal.kernel.util PortalUtil getCompanyIds

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util PortalUtil getCompanyIds.

Prototype

public static long[] getCompanyIds() 

Source Link

Usage

From source file:com.liferay.exportimport.content.processor.base.BaseTextExportImportContentProcessor.java

License:Open Source License

protected void validateDLReferences(long groupId, String content) throws PortalException {

    String portalURL = PortalUtil.getPathContext();

    ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();

    if ((serviceContext != null) && (serviceContext.getThemeDisplay() != null)) {

        ThemeDisplay themeDisplay = serviceContext.getThemeDisplay();

        portalURL = PortalUtil.getPortalURL(themeDisplay) + PortalUtil.getPathContext();
    }/*from w  w  w.  j a v  a 2  s .  c  om*/

    String[] patterns = { portalURL.concat("/c/document_library/get_file?"), portalURL.concat("/documents/"),
            portalURL.concat("/image/image_gallery?") };

    String[] completePatterns = new String[patterns.length];

    long[] companyIds = PortalUtil.getCompanyIds();

    for (long companyId : companyIds) {
        Company company = CompanyLocalServiceUtil.getCompany(companyId);

        String webId = company.getWebId();

        int i = 0;

        for (String pattern : patterns) {
            completePatterns[i] = webId.concat(pattern);

            i++;
        }

        int beginPos = -1;
        int endPos = content.length();

        while (true) {
            beginPos = StringUtil.lastIndexOfAny(content, completePatterns, endPos);

            if (beginPos == -1) {
                break;
            }

            Map<String, String[]> dlReferenceParameters = getDLReferenceParameters(groupId, content,
                    beginPos + portalURL.length() + webId.length(), endPos);

            FileEntry fileEntry = getFileEntry(dlReferenceParameters);

            if (fileEntry == null) {
                throw new NoSuchFileEntryException();
            }

            endPos = beginPos - 1;
        }
    }
}

From source file:com.liferay.marketplace.internal.upgrade.v0_0_1.UpgradeExpando.java

License:Open Source License

@Override
protected void doUpgrade() throws Exception {
    for (long companyId : PortalUtil.getCompanyIds()) {
        updateMPExpandoColumns(companyId);
    }//  w  w  w.ja  v a  2 s . co  m
}