Example usage for com.liferay.portal.service.http GroupServiceHttp getGroupDisplayURL

List of usage examples for com.liferay.portal.service.http GroupServiceHttp getGroupDisplayURL

Introduction

In this page you can find the example usage for com.liferay.portal.service.http GroupServiceHttp getGroupDisplayURL.

Prototype

public static String getGroupDisplayURL(HttpPrincipal httpPrincipal, long groupId, boolean privateLayout,
            boolean secureConnection) throws com.liferay.portal.kernel.exception.PortalException 

Source Link

Usage

From source file:com.liferay.exportimport.staging.StagingImpl.java

License:Open Source License

@Override
public String getRemoteSiteURL(Group stagingGroup, boolean privateLayout) throws PortalException {

    if (!stagingGroup.isStagedRemotely()) {
        return StringPool.BLANK;
    }/*  www  .ja  v a 2  s.co m*/

    PermissionChecker permissionChecker = PermissionThreadLocal.getPermissionChecker();

    User user = permissionChecker.getUser();

    UnicodeProperties typeSettingsProperties = stagingGroup.getTypeSettingsProperties();

    HttpPrincipal httpPrincipal = new HttpPrincipal(buildRemoteURL(typeSettingsProperties), user.getLogin(),
            user.getPassword(), user.getPasswordEncrypted());

    long remoteGroupId = GetterUtil.getLong(typeSettingsProperties.getProperty("remoteGroupId"));
    boolean secureConnection = GetterUtil.getBoolean(typeSettingsProperties.getProperty("secureConnection"));

    String groupDisplayURL = GroupServiceHttp.getGroupDisplayURL(httpPrincipal, remoteGroupId, privateLayout,
            secureConnection);

    try {
        URL remoteSiteURL = new URL(groupDisplayURL);

        String remoteAddress = typeSettingsProperties.getProperty("remoteAddress");

        remoteSiteURL = new URL(remoteSiteURL.getProtocol(), remoteAddress, remoteSiteURL.getPort(),
                remoteSiteURL.getFile());

        return remoteSiteURL.toString();
    } catch (MalformedURLException murle) {
        throw new PortalException(murle);
    }
}