Example usage for com.liferay.portal.kernel.util UnicodeProperties setProperty

List of usage examples for com.liferay.portal.kernel.util UnicodeProperties setProperty

Introduction

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

Prototype

public String setProperty(String key, String value) 

Source Link

Usage

From source file:com.abubusoft.liferay.linkedin.action.AddLinkedinExpandoFieldsAction.java

License:Open Source License

protected void doRun(long companyId) throws Exception {
    ExpandoTable expandoTable = null;/* w  ww . j  a va2  s  . c o m*/

    try {
        expandoTable = ExpandoTableLocalServiceUtil.addTable(companyId, User.class.getName(),
                ExpandoTableConstants.DEFAULT_TABLE_NAME);
    } catch (Exception e) {
        expandoTable = ExpandoTableLocalServiceUtil.getTable(companyId, User.class.getName(),
                ExpandoTableConstants.DEFAULT_TABLE_NAME);
    }

    try {
        UnicodeProperties properties = new UnicodeProperties();

        properties.setProperty("hidden", "true");
        properties.setProperty("visible-with-update-permission", "false");

        addColumn(expandoTable.getTableId(), LinkedinConstants.LINKEDIN_ID_COLUMN_NAME, properties);

        if (_log.isInfoEnabled()) {
            _log.info("Custom field '" + LinkedinConstants.LINKEDIN_ID_COLUMN_NAME + "' added to User entity");
        }
    } catch (Exception e) {
        if (_log.isDebugEnabled()) {
            _log.debug("Couldn't add custom field '" + LinkedinConstants.LINKEDIN_ID_COLUMN_NAME + "'");
        }
    }
}

From source file:com.abubusoft.liferay.twitter.action.AddTwitterExpandoFieldsAction.java

License:Open Source License

protected void doRun(long companyId) throws Exception {
    ExpandoTable expandoTable = null;//w  w  w .j  a v a  2 s .  c  o  m

    try {
        expandoTable = ExpandoTableLocalServiceUtil.addTable(companyId, User.class.getName(),
                ExpandoTableConstants.DEFAULT_TABLE_NAME);
    } catch (Exception e) {
        expandoTable = ExpandoTableLocalServiceUtil.getTable(companyId, User.class.getName(),
                ExpandoTableConstants.DEFAULT_TABLE_NAME);
    }

    try {
        UnicodeProperties properties = new UnicodeProperties();

        properties.setProperty("hidden", "true");
        properties.setProperty("visible-with-update-permission", "false");

        addColumn(expandoTable.getTableId(), TwitterConstants.TWITTER_ID_COLUMN_NAME, properties);

        if (_log.isInfoEnabled()) {
            _log.info("Custom field '" + TwitterConstants.TWITTER_ID_COLUMN_NAME + "' added to User entity");
        }
    } catch (Exception e) {
        if (_log.isDebugEnabled()) {
            _log.debug("Couldn't add custom field '" + TwitterConstants.TWITTER_ID_COLUMN_NAME + "'");
        }
    }
}

From source file:com.liferay.asset.publisher.layout.prototype.internal.instance.lifecycle.AddLayoutPrototypePortalInstanceLifecycleListener.java

License:Open Source License

protected void addWebContentPage(long companyId, long defaultUserId, List<LayoutPrototype> layoutPrototypes)
        throws Exception {

    ResourceBundleLoader resourceBundleLoader = new AggregateResourceBundleLoader(
            ResourceBundleUtil.getResourceBundleLoader("content.Language", getClassLoader()),
            LanguageResources.RESOURCE_BUNDLE_LOADER);

    Map<Locale, String> nameMap = ResourceBundleUtil.getLocalizationMap(resourceBundleLoader,
            "layout-prototype-web-content-title");
    Map<Locale, String> descriptionMap = ResourceBundleUtil.getLocalizationMap(resourceBundleLoader,
            "layout-prototype-web-content-description");

    Layout layout = DefaultLayoutPrototypesUtil.addLayoutPrototype(companyId, defaultUserId, nameMap,
            descriptionMap, "2_columns_ii", layoutPrototypes);

    if (layout == null) {
        return;// w  w w  .j a v a 2 s  .  com
    }

    DefaultLayoutPrototypesUtil.addPortletId(layout, AssetTagsNavigationPortletKeys.ASSET_TAGS_NAVIGATION,
            "column-1");

    DefaultLayoutPrototypesUtil.addPortletId(layout,
            AssetCategoriesNavigationPortletKeys.ASSET_CATEGORIES_NAVIGATION, "column-1");

    String portletId = DefaultLayoutPrototypesUtil.addPortletId(layout,
            AssetPublisherPortletKeys.ASSET_PUBLISHER, "column-2");

    Map<String, String> preferences = new HashMap<>();

    preferences.put("showOnlyLayoutAssets", Boolean.TRUE.toString());

    DefaultLayoutPrototypesUtil.updatePortletSetup(layout, portletId, preferences);

    UnicodeProperties typeSettingsProperties = layout.getTypeSettingsProperties();

    typeSettingsProperties.setProperty(LayoutTypePortletConstants.DEFAULT_ASSET_PUBLISHER_PORTLET_ID,
            portletId);

    _layoutLocalService.updateLayout(layout.getGroupId(), layout.isPrivateLayout(), layout.getLayoutId(),
            layout.getTypeSettings());
}

From source file:com.liferay.asset.publisher.web.AssetPublisherPortletLayoutListener.java

License:Open Source License

@Override
public void updatePropertiesOnRemoveFromLayout(String portletId, UnicodeProperties typeSettingsProperties)
        throws PortletLayoutListenerException {

    String defaultAssetPublisherPortletId = typeSettingsProperties
            .getProperty(LayoutTypePortletConstants.DEFAULT_ASSET_PUBLISHER_PORTLET_ID);

    if (portletId.equals(defaultAssetPublisherPortletId)) {
        typeSettingsProperties.setProperty(LayoutTypePortletConstants.DEFAULT_ASSET_PUBLISHER_PORTLET_ID,
                StringPool.BLANK);//w  w w.ja  va 2s .  c o m
    }
}

From source file:com.liferay.asset.publisher.web.portlet.action.AssetPublisherConfigurationAction.java

License:Open Source License

protected void updateDefaultAssetPublisher(ActionRequest actionRequest) throws Exception {

    boolean defaultAssetPublisher = ParamUtil.getBoolean(actionRequest, "defaultAssetPublisher");

    Layout layout = (Layout) actionRequest.getAttribute(WebKeys.LAYOUT);

    String portletResource = ParamUtil.getString(actionRequest, "portletResource");

    UnicodeProperties typeSettingsProperties = layout.getTypeSettingsProperties();

    if (defaultAssetPublisher) {
        typeSettingsProperties.setProperty(LayoutTypePortletConstants.DEFAULT_ASSET_PUBLISHER_PORTLET_ID,
                portletResource);/*from   w  ww  .jav  a2 s  .c om*/
    } else {
        String defaultAssetPublisherPortletId = typeSettingsProperties
                .getProperty(LayoutTypePortletConstants.DEFAULT_ASSET_PUBLISHER_PORTLET_ID);

        if (Validator.isNotNull(defaultAssetPublisherPortletId)
                && defaultAssetPublisherPortletId.equals(portletResource)) {

            typeSettingsProperties.setProperty(LayoutTypePortletConstants.DEFAULT_ASSET_PUBLISHER_PORTLET_ID,
                    StringPool.BLANK);
        }
    }

    layout = layoutLocalService.updateLayout(layout.getGroupId(), layout.isPrivateLayout(),
            layout.getLayoutId(), layout.getTypeSettings());

    if (LayoutStagingUtil.isBranchingLayout(layout)) {
        HttpServletRequest request = portal.getHttpServletRequest(actionRequest);

        LayoutSetBranch layoutSetBranch = LayoutStagingUtil.getLayoutSetBranch(layout.getLayoutSet());

        long layoutSetBranchId = layoutSetBranch.getLayoutSetBranchId();

        long layoutRevisionId = staging.getRecentLayoutRevisionId(request, layoutSetBranchId, layout.getPlid());

        LayoutRevision layoutRevision = layoutRevisionLocalService.getLayoutRevision(layoutRevisionId);

        PortletPreferencesImpl portletPreferences = (PortletPreferencesImpl) actionRequest.getPreferences();

        if (layoutRevision != null) {
            portletPreferences.setPlid(layoutRevision.getLayoutRevisionId());
        }
    }
}

From source file:com.liferay.compat.hook.events.StartupAction.java

License:Open Source License

protected void doRun(long companyId) throws Exception {
    ExpandoBridge expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(companyId,
            DLFileEntry.class.getName());

    if (!expandoBridge.hasAttribute(DLUtil.MANUAL_CHECK_IN_REQUIRED)) {
        expandoBridge.addAttribute(DLUtil.MANUAL_CHECK_IN_REQUIRED, ExpandoColumnConstants.BOOLEAN, false);

        UnicodeProperties properties = expandoBridge.getAttributeProperties(DLUtil.MANUAL_CHECK_IN_REQUIRED);

        properties.setProperty("hidden", Boolean.toString(true));

        expandoBridge.setAttributeProperties(DLUtil.MANUAL_CHECK_IN_REQUIRED, properties, false);
    }/*from w  w  w  .  j ava2s . c o  m*/
}

From source file:com.liferay.content.targeting.service.test.util.LayoutTestUtil.java

License:Open Source License

public static Layout addTypeArticleLayout(long groupId, String name, String articleId) throws Exception {

    Layout layout = addLayout(groupId, name);

    UnicodeProperties typeSettingsProperties = layout.getTypeSettingsProperties();

    typeSettingsProperties.setProperty("article-id", articleId);

    layout.setType(LayoutConstants.TYPE_ARTICLE);

    LayoutLocalServiceUtil.updateLayout(layout);

    return layout;
}

From source file:com.liferay.content.targeting.service.test.util.LayoutTestUtil.java

License:Open Source License

public static Layout addTypeLinkToLayoutLayout(long groupId, String name, long linkedToLayoutId)
        throws Exception {

    Layout layout = addLayout(groupId, name);

    UnicodeProperties typeSettingsProperties = layout.getTypeSettingsProperties();

    typeSettingsProperties.setProperty("linkToLayoutId", String.valueOf(linkedToLayoutId));

    layout.setType(LayoutConstants.TYPE_LINK_TO_LAYOUT);

    LayoutLocalServiceUtil.updateLayout(layout);

    return layout;
}

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

License:Open Source License

@Override
public void setProperty(Class<? extends Capability> owner, String key, String value) {

    try {//from w w  w .j  a va  2 s . com
        Repository repository = _repositoryServiceAdapter.getRepository(_documentRepository.getRepositoryId());

        UnicodeProperties typeSettingsProperties = repository.getTypeSettingsProperties();

        typeSettingsProperties.setProperty(_getUniqueKey(owner, key), value);

        repository.setTypeSettingsProperties(typeSettingsProperties);

        _repositoryServiceAdapter.updateRepository(repository);
    } catch (PortalException pe) {
        throw new SystemException("Unable to set repository configuration property", pe);
    }
}

From source file:com.liferay.document.library.repository.cmis.internal.CMISRepositoryUtil.java

License:Open Source License

public static void checkRepository(long repositoryId, Map<String, String> parameters,
        UnicodeProperties typeSettingsProperties, String typeSettingsKey)
        throws PortalException, RepositoryException {

    if (!typeSettingsProperties.containsKey(typeSettingsKey)) {
        org.apache.chemistry.opencmis.client.api.Repository cmisRepository = getCMISRepository(parameters);

        typeSettingsProperties.setProperty(typeSettingsKey, cmisRepository.getId());

        try {/*  w w  w. j a va  2s  .com*/
            RepositoryLocalServiceUtil.updateRepository(repositoryId, typeSettingsProperties);
        } catch (PortalException | SystemException e) {
            throw new RepositoryException(e);
        }
    }

    parameters.put(SessionParameter.REPOSITORY_ID,
            getTypeSettingsValue(typeSettingsProperties, typeSettingsKey));
}