List of usage examples for com.liferay.portal.kernel.exception RemoteOptionsException RemoteOptionsException
public RemoteOptionsException(int type)
From source file:com.liferay.exportimport.staging.StagingImpl.java
License:Open Source License
@Override public void validateRemote(long groupId, String remoteAddress, int remotePort, String remotePathContext, boolean secureConnection, long remoteGroupId) throws PortalException { RemoteOptionsException roe = null;//from w ww. j ava 2 s .co m if (!Validator.isDomain(remoteAddress) && !Validator.isIPAddress(remoteAddress)) { roe = new RemoteOptionsException(RemoteOptionsException.REMOTE_ADDRESS); roe.setRemoteAddress(remoteAddress); throw roe; } if ((remotePort < 1) || (remotePort > 65535)) { roe = new RemoteOptionsException(RemoteOptionsException.REMOTE_PORT); roe.setRemotePort(remotePort); throw roe; } if (Validator.isNotNull(remotePathContext) && (!remotePathContext.startsWith(StringPool.FORWARD_SLASH) || remotePathContext.endsWith(StringPool.FORWARD_SLASH))) { roe = new RemoteOptionsException(RemoteOptionsException.REMOTE_PATH_CONTEXT); roe.setRemotePathContext(remotePathContext); throw roe; } validateRemoteGroup(groupId, remoteGroupId, remoteAddress, remotePort, remotePathContext, secureConnection); }
From source file:com.liferay.exportimport.staging.StagingImpl.java
License:Open Source License
protected void validateRemoteGroup(long groupId, long remoteGroupId, String remoteAddress, int remotePort, String remotePathContext, boolean secureConnection) throws PortalException { if (remoteGroupId <= 0) { RemoteOptionsException roe = new RemoteOptionsException(RemoteOptionsException.REMOTE_GROUP_ID); roe.setRemoteGroupId(remoteGroupId); throw roe; }/*from w w w.j a v a2 s. com*/ Thread currentThread = Thread.currentThread(); ClassLoader contextClassLoader = currentThread.getContextClassLoader(); PermissionChecker permissionChecker = PermissionThreadLocal.getPermissionChecker(); User user = permissionChecker.getUser(); String remoteURL = buildRemoteURL(remoteAddress, remotePort, remotePathContext, secureConnection); HttpPrincipal httpPrincipal = new HttpPrincipal(remoteURL, user.getLogin(), user.getPassword(), user.getPasswordEncrypted()); try { currentThread.setContextClassLoader(PortalClassLoaderUtil.getClassLoader()); // Ping the remote host and verify that the remote group exists in // the same company as the remote user GroupServiceHttp.checkRemoteStagingGroup(httpPrincipal, remoteGroupId); // Ensure that the local group and the remote group are not the same // group and that they are either both company groups or both not // company groups Group group = _groupLocalService.getGroup(groupId); Group remoteGroup = GroupServiceHttp.getGroup(httpPrincipal, remoteGroupId); if (group.isCompany() ^ isCompanyGroup(httpPrincipal, remoteGroup)) { RemoteExportException ree = new RemoteExportException(RemoteExportException.INVALID_GROUP); ree.setGroupId(remoteGroupId); throw ree; } } catch (NoSuchGroupException nsge) { // LPS-52675 if (_log.isDebugEnabled()) { _log.debug(nsge, nsge); } RemoteExportException ree = new RemoteExportException(RemoteExportException.NO_GROUP); ree.setGroupId(remoteGroupId); throw ree; } catch (PrincipalException pe) { // LPS-52675 if (_log.isDebugEnabled()) { _log.debug(pe, pe); } RemoteExportException ree = new RemoteExportException(RemoteExportException.NO_PERMISSIONS); ree.setGroupId(remoteGroupId); throw ree; } catch (RemoteAuthException rae) { // LPS-52675 if (_log.isDebugEnabled()) { _log.debug(rae, rae); } rae.setURL(remoteURL); throw rae; } catch (SystemException se) { // LPS-52675 if (_log.isDebugEnabled()) { _log.debug(se, se); } RemoteExportException ree = new RemoteExportException(RemoteExportException.BAD_CONNECTION, se.getMessage()); ree.setURL(remoteURL); throw ree; } finally { currentThread.setContextClassLoader(contextClassLoader); } }