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

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

Introduction

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

Prototype

public String getProperty(String key) 

Source Link

Usage

From source file:com.fb.action.OpenGraphLayoutAction.java

License:Open Source License

protected void addOpenGraphProperties(HttpServletRequest request) throws PortalException, SystemException {

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    Map<String, String> opengraphAttributes = (Map<String, String>) request
            .getAttribute("LIFERAY_SHARED_OPENGRAPH");

    if (opengraphAttributes == null) {
        opengraphAttributes = new HashMap<String, String>();

        request.setAttribute("LIFERAY_SHARED_OPENGRAPH", opengraphAttributes);
    }/*w  ww  .ja  v  a  2s .  c  o  m*/

    UnicodeProperties layoutTypeSettings = null;
    Layout layout = themeDisplay.getLayout();
    Group group = themeDisplay.getScopeGroup();

    if (layout != null) {
        layoutTypeSettings = layout.getTypeSettingsProperties();
    }

    String ogTitle = layoutTypeSettings.getProperty("og-title");
    String ogType = layoutTypeSettings.getProperty("og-type");
    String ogImage = layoutTypeSettings.getProperty("og-image");

    String ogDescription = layoutTypeSettings.getProperty("og-description");
    String ogVideo = layoutTypeSettings.getProperty("og-video");
    String ogAudio = layoutTypeSettings.getProperty("og-audio");
    String ogDeterminer = layoutTypeSettings.getProperty("og-determiner");

    if (Validator.isNull(ogType)) {
        if (group.isUser()) {
            ogType = "profile";
        } else {
            ogType = "website";
        }
    }

    opengraphAttributes.put("type", ogType);

    opengraphAttributes.put("url",
            PortalUtil.getCanonicalURL(PortalUtil.getLayoutFullURL(themeDisplay), themeDisplay, layout));

    if (Validator.isNull(ogTitle)) {
        ogTitle = layout.getTitle(themeDisplay.getLanguageId());
    }

    opengraphAttributes.put("title", ogTitle);

    if (Validator.isNull(ogDescription)) {
        ogDescription = layout.getDescription(themeDisplay.getLanguageId());
    }

    if (Validator.isNotNull(ogDescription)) {
        opengraphAttributes.put("description", ogDescription);
    }

    if (Validator.isNotNull(ogVideo)) {
        opengraphAttributes.put("video", ogVideo);
    }

    if (Validator.isNotNull(ogAudio)) {
        opengraphAttributes.put("audio", ogAudio);
    }

    if (Validator.isNotNull(ogDeterminer)) {
        opengraphAttributes.put("determiner", ogDeterminer);
    }

    opengraphAttributes.put("site_name", group.getDescriptiveName());

    opengraphAttributes.put("locale", themeDisplay.getLanguageId());

    if (Validator.isNull(ogImage) && layout.isIconImage()) {
        ogImage = themeDisplay.getPathImage() + "/layout_icon?img_id=" + layout.getIconImageId() + "&t="
                + WebServerServletTokenUtil.getToken(layout.getIconImageId());
    }

    if (Validator.isNotNull(ogImage)) {
        opengraphAttributes.put("image", ogImage);
    }
}

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 va2  s  .  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  www.  jav  a  2s  . c  o m*/
    } 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.calendarimporter.model.impl.ImportEntryImpl.java

License:Open Source License

@Override
public String getTypeSettingsProperty(String key) {
    UnicodeProperties typeSettingsProperties = getTypeSettingsProperties();

    return typeSettingsProperties.getProperty(key);
}

From source file:com.liferay.calendarimporter.source.LotusNotesImportSource.java

License:Open Source License

@Override
protected void doExecuteImport(Calendar calendar, UnicodeProperties typeSettingsProperties) throws Exception {

    String url = typeSettingsProperties.getProperty("url");
    String userName = typeSettingsProperties.getProperty("user-name");
    String password = typeSettingsProperties.getProperty("password");

    if (!StringUtil.endsWith(url, CharPool.SLASH)) {
        url += CharPool.SLASH;/*from ww w .j  a  va 2  s  . c  om*/
    }

    url += _EVENTS_PATH;

    Http.Options options = new Http.Options();

    options.setAuth(null, 0, null, userName, password);
    options.setLocation(url);

    String json = HttpUtil.URLtoString(options);

    if (Validator.isNull(json)) {
        return;
    }

    JSONObject jsonObject = JSONFactoryUtil.createJSONObject(json);

    JSONArray eventsJSON = jsonObject.getJSONArray("events");

    importEvents(calendar, eventsJSON);
}

From source file:com.liferay.content.targeting.analytics.util.AnalyticsUtil.java

License:Open Source License

private static Boolean _getBoolean(long groupId, String key, boolean defaultValue) {

    try {/*from   w  ww  .j  a v  a 2  s.c  o  m*/
        Group group = GroupLocalServiceUtil.getGroup(groupId);

        UnicodeProperties typeSettingsProperties = group.getParentLiveGroupTypeSettingsProperties();

        boolean companyValue = PrefsPropsUtil.getBoolean(group.getCompanyId(), key);

        if (!companyValue) {
            return false;
        }

        return GetterUtil.getBoolean(typeSettingsProperties.getProperty(key), companyValue);
    } catch (Exception e) {
        return defaultValue;
    }
}

From source file:com.liferay.content.targeting.analytics.util.AnalyticsUtil.java

License:Open Source License

private static String _getString(long groupId, String key, String defaultValue) {

    try {/*from  ww w.j a v a  2  s .c  o  m*/
        Group group = GroupLocalServiceUtil.getGroup(groupId);

        UnicodeProperties typeSettingsProperties = group.getParentLiveGroupTypeSettingsProperties();

        String companyValue = PrefsPropsUtil.getString(group.getCompanyId(), key);

        return GetterUtil.getString(typeSettingsProperties.getProperty(key), companyValue);
    } catch (Exception e) {
        return defaultValue;
    }
}

From source file:com.liferay.content.targeting.util.ContentTargetingUtil.java

License:Open Source License

public static boolean isStaged(long liveGroupId, String portletId) throws PortalException, SystemException {

    Group liveGroup = GroupLocalServiceUtil.getGroup(liveGroupId);

    UnicodeProperties liveGroupTypeSettings = liveGroup.getTypeSettingsProperties();

    return GetterUtil.getBoolean(liveGroupTypeSettings.getProperty(StagingUtil.getStagedPortletId(portletId)),
            false);/*from  w  ww  . ja  v a2  s  .  c o  m*/
}

From source file:com.liferay.directory.web.internal.search.DirectoryOpenSearchImpl.java

License:Open Source License

protected LinkedHashMap<String, Object> getUserParams(long companyId, String keywords) {

    LinkedHashMap<String, Object> userParams = new LinkedHashMap<>();

    ExpandoBridge expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(companyId, User.class.getName());

    Enumeration<String> enu = expandoBridge.getAttributeNames();

    while (enu.hasMoreElements()) {
        String attributeName = enu.nextElement();

        UnicodeProperties properties = expandoBridge.getAttributeProperties(attributeName);

        int indexType = GetterUtil.getInteger(properties.getProperty(ExpandoColumnConstants.INDEX_TYPE));

        if (indexType != ExpandoColumnConstants.INDEX_TYPE_NONE) {
            userParams.put(attributeName, keywords);
        }/*from  ww  w .  j av a2s.co m*/
    }

    return userParams;
}

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

License:Open Source License

@Override
public String getProperty(Class<? extends Capability> owner, String key) {
    try {/*from  w  w w.  j a va2 s .  co m*/
        Repository repository = _repositoryServiceAdapter.getRepository(_documentRepository.getRepositoryId());

        UnicodeProperties typeSettingsProperties = repository.getTypeSettingsProperties();

        return typeSettingsProperties.getProperty(_getUniqueKey(owner, key));
    } catch (PortalException pe) {
        throw new SystemException("Unable to read repository configuration property", pe);
    }
}