Skip to content

Commit

Permalink
LPS-27756 added company permission checking to added UserService dele…
Browse files Browse the repository at this point in the history
…gates
  • Loading branch information
igr authored and brianchandotcom committed Jun 27, 2012
1 parent 744a479 commit 4813f89
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 12 deletions.
Expand Up @@ -570,7 +570,8 @@ public static void deleteUser(HttpPrincipal httpPrincipal, long userId)

public static java.util.List<com.liferay.portal.model.User> getCompanyUsers(
HttpPrincipal httpPrincipal, long companyId, int start, int end)
throws com.liferay.portal.kernel.exception.SystemException {
throws com.liferay.portal.kernel.exception.PortalException,
com.liferay.portal.kernel.exception.SystemException {
try {
MethodKey methodKey = new MethodKey(UserServiceUtil.class.getName(),
"getCompanyUsers", _getCompanyUsersParameterTypes13);
Expand All @@ -584,6 +585,10 @@ public static java.util.List<com.liferay.portal.model.User> getCompanyUsers(
returnObj = TunnelUtil.invoke(httpPrincipal, methodHandler);
}
catch (Exception e) {
if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
throw (com.liferay.portal.kernel.exception.PortalException)e;
}

if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
throw (com.liferay.portal.kernel.exception.SystemException)e;
}
Expand All @@ -602,7 +607,8 @@ public static java.util.List<com.liferay.portal.model.User> getCompanyUsers(

public static int getCompanyUsersCount(HttpPrincipal httpPrincipal,
long companyId)
throws com.liferay.portal.kernel.exception.SystemException {
throws com.liferay.portal.kernel.exception.PortalException,
com.liferay.portal.kernel.exception.SystemException {
try {
MethodKey methodKey = new MethodKey(UserServiceUtil.class.getName(),
"getCompanyUsersCount",
Expand All @@ -616,6 +622,10 @@ public static int getCompanyUsersCount(HttpPrincipal httpPrincipal,
returnObj = TunnelUtil.invoke(httpPrincipal, methodHandler);
}
catch (Exception e) {
if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
throw (com.liferay.portal.kernel.exception.PortalException)e;
}

if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
throw (com.liferay.portal.kernel.exception.SystemException)e;
}
Expand Down
Expand Up @@ -36,6 +36,7 @@
import com.liferay.portal.model.Organization;
import com.liferay.portal.model.Phone;
import com.liferay.portal.model.Role;
import com.liferay.portal.model.RoleConstants;
import com.liferay.portal.model.User;
import com.liferay.portal.model.UserGroup;
import com.liferay.portal.model.UserGroupRole;
Expand Down Expand Up @@ -634,16 +635,25 @@ public void deleteUser(long userId)
}

public List<User> getCompanyUsers(long companyId, int start, int end)
throws SystemException {
throws PortalException, SystemException {

if (!roleLocalService.hasUserRole(
getUserId(), companyId, RoleConstants.ADMINISTRATOR, true)) {

// todo add permission
throw new PrincipalException();
}

return userLocalService.getCompanyUsers(companyId, start, end);
}

public int getCompanyUsersCount(long companyId) throws SystemException {
public int getCompanyUsersCount(long companyId)
throws PortalException, SystemException {

// todo add permission
if (!roleLocalService.hasUserRole(
getUserId(), companyId, RoleConstants.ADMINISTRATOR, true)) {

throw new PrincipalException();
}

return userLocalService.getCompanyUsersCount(companyId);
}
Expand Down
Expand Up @@ -461,11 +461,13 @@ public void deleteUser(long userId)
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public java.util.List<com.liferay.portal.model.User> getCompanyUsers(
long companyId, int start, int end)
throws com.liferay.portal.kernel.exception.SystemException;
throws com.liferay.portal.kernel.exception.PortalException,
com.liferay.portal.kernel.exception.SystemException;

@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public int getCompanyUsersCount(long companyId)
throws com.liferay.portal.kernel.exception.SystemException;
throws com.liferay.portal.kernel.exception.PortalException,
com.liferay.portal.kernel.exception.SystemException;

/**
* Returns the primary keys of all the users belonging to the group.
Expand Down
Expand Up @@ -508,12 +508,14 @@ public static void deleteUser(long userId)

public static java.util.List<com.liferay.portal.model.User> getCompanyUsers(
long companyId, int start, int end)
throws com.liferay.portal.kernel.exception.SystemException {
throws com.liferay.portal.kernel.exception.PortalException,
com.liferay.portal.kernel.exception.SystemException {
return getService().getCompanyUsers(companyId, start, end);
}

public static int getCompanyUsersCount(long companyId)
throws com.liferay.portal.kernel.exception.SystemException {
throws com.liferay.portal.kernel.exception.PortalException,
com.liferay.portal.kernel.exception.SystemException {
return getService().getCompanyUsersCount(companyId);
}

Expand Down
Expand Up @@ -497,12 +497,14 @@ public void deleteUser(long userId)

public java.util.List<com.liferay.portal.model.User> getCompanyUsers(
long companyId, int start, int end)
throws com.liferay.portal.kernel.exception.SystemException {
throws com.liferay.portal.kernel.exception.PortalException,
com.liferay.portal.kernel.exception.SystemException {
return _userService.getCompanyUsers(companyId, start, end);
}

public int getCompanyUsersCount(long companyId)
throws com.liferay.portal.kernel.exception.SystemException {
throws com.liferay.portal.kernel.exception.PortalException,
com.liferay.portal.kernel.exception.SystemException {
return _userService.getCompanyUsersCount(companyId);
}

Expand Down

0 comments on commit 4813f89

Please sign in to comment.