From 96a00cbb66e716691d59f7fda1b921a868af8820 Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Tue, 9 May 2017 09:40:05 +0000 Subject: [PATCH] ref 8432:TDM - DatabasesManager - Support Java 8 compatibility https://support.d4science.org/issues/8432 Updated to support Java 8 compatibility git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/databases-manager-portlet@148378 82a268e6-3cf1-43bd-a215-b396298e98cf --- .classpath | 12 +++++- .settings/org.eclipse.wst.common.component | 6 +-- .../client/utils/UIDGenerator.java | 2 +- .../server/util/ServiceCredentials.java | 18 ++++----- .../server/util/SessionUtil.java | 37 ++++++++----------- 5 files changed, 36 insertions(+), 39 deletions(-) diff --git a/.classpath b/.classpath index 27e030b..db6721d 100644 --- a/.classpath +++ b/.classpath @@ -6,14 +6,22 @@ - + + + + + - + + + + + diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index b648fc3..ebbc378 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,12 +1,10 @@ - + - - uses - + diff --git a/src/main/java/org/gcube/portlets/user/databasesmanager/client/utils/UIDGenerator.java b/src/main/java/org/gcube/portlets/user/databasesmanager/client/utils/UIDGenerator.java index 7e1a04f..024ea15 100644 --- a/src/main/java/org/gcube/portlets/user/databasesmanager/client/utils/UIDGenerator.java +++ b/src/main/java/org/gcube/portlets/user/databasesmanager/client/utils/UIDGenerator.java @@ -27,7 +27,7 @@ public class UIDGenerator { * @param len * the desired number of characters * @param radix - * the number of allowable values for each character (must be <= + * the number of allowable values for each character (must be <= * 62) * @return random uuid */ diff --git a/src/main/java/org/gcube/portlets/user/databasesmanager/server/util/ServiceCredentials.java b/src/main/java/org/gcube/portlets/user/databasesmanager/server/util/ServiceCredentials.java index 7bc2515..d268927 100644 --- a/src/main/java/org/gcube/portlets/user/databasesmanager/server/util/ServiceCredentials.java +++ b/src/main/java/org/gcube/portlets/user/databasesmanager/server/util/ServiceCredentials.java @@ -2,10 +2,9 @@ package org.gcube.portlets.user.databasesmanager.server.util; import java.io.Serializable; -/** +/* * - * @author Giancarlo Panichi email: g.panichi@isti.cnr.it + * @author Giancarlo Panichi * */ public class ServiceCredentials implements Serializable { @@ -33,9 +32,8 @@ public class ServiceCredentials implements Serializable { this.token = token; } - public ServiceCredentials(String userName, String fullName, String name, - String lastName, String email, String scope, String groupId, - String groupName, String userAvatarURL, String token) { + public ServiceCredentials(String userName, String fullName, String name, String lastName, String email, + String scope, String groupId, String groupName, String userAvatarURL, String token) { super(); this.userName = userName; this.fullName = fullName; @@ -131,11 +129,9 @@ public class ServiceCredentials implements Serializable { @Override public String toString() { - return "ServiceCredentials [userName=" + userName + ", fullName=" - + fullName + ", name=" + name + ", lastName=" + lastName - + ", email=" + email + ", scope=" + scope + ", groupId=" - + groupId + ", groupName=" + groupName + ", userAvatarURL=" - + userAvatarURL + ", token=" + token + "]"; + return "ServiceCredentials [userName=" + userName + ", fullName=" + fullName + ", name=" + name + ", lastName=" + + lastName + ", email=" + email + ", scope=" + scope + ", groupId=" + groupId + ", groupName=" + + groupName + ", userAvatarURL=" + userAvatarURL + ", token=" + token + "]"; } } diff --git a/src/main/java/org/gcube/portlets/user/databasesmanager/server/util/SessionUtil.java b/src/main/java/org/gcube/portlets/user/databasesmanager/server/util/SessionUtil.java index 64cdba4..83c1400 100644 --- a/src/main/java/org/gcube/portlets/user/databasesmanager/server/util/SessionUtil.java +++ b/src/main/java/org/gcube/portlets/user/databasesmanager/server/util/SessionUtil.java @@ -12,7 +12,6 @@ import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager; import org.gcube.vomanagement.usermanagement.model.GCubeGroup; import org.gcube.vomanagement.usermanagement.model.GCubeUser; - public class SessionUtil { private static final Logger logger = Logger.getLogger(SessionUtil.class); @@ -20,23 +19,25 @@ public class SessionUtil { /** * * @param httpServletRequest - * @return - * @throws TDGWTServiceException + * http servlet request + * @return ServiceCredentials + * @throws ServiceException ServiceException */ - public static ServiceCredentials getServiceCredentials( - HttpServletRequest httpServletRequest) throws org.gcube.portlets.user.databasesmanager.shared.exception.ServiceException { + public static ServiceCredentials getServiceCredentials(HttpServletRequest httpServletRequest) + throws ServiceException { return getServiceCredentials(httpServletRequest, null); } /** * * @param httpServletRequest + * http servlet request * @param scopeGroupId - * @return - * @throws TDGWTServiceException + * scope + * @return ServiceCredentials + * @throws ServiceException ServiceException */ - public static ServiceCredentials getServiceCredentials( - HttpServletRequest httpServletRequest, String scopeGroupId) + public static ServiceCredentials getServiceCredentials(HttpServletRequest httpServletRequest, String scopeGroupId) throws ServiceException { ServiceCredentials sCredentials = null; @@ -94,8 +95,7 @@ public class SessionUtil { GCubeUser gCubeUser = pContext.getCurrentUser(httpServletRequest); if (gCubeUser == null) { - String error = "Error retrieving gCubeUser in scope " + scope - + ": " + gCubeUser; + String error = "Error retrieving gCubeUser in scope " + scope + ": " + gCubeUser; logger.error(error); throw new ServiceException(error); } @@ -103,8 +103,7 @@ public class SessionUtil { userName = gCubeUser.getUsername(); if (userName == null || userName.isEmpty()) { - String error = "Error retrieving username in scope " + scope - + ": " + userName; + String error = "Error retrieving username in scope " + scope + ": " + userName; logger.error(error); throw new ServiceException(error); } @@ -112,8 +111,7 @@ public class SessionUtil { token = pContext.getCurrentUserToken(scope, userName); if (token == null || token.isEmpty()) { - String error = "Error retrieving token for " + userName - + " in " + scope + ": " + token; + String error = "Error retrieving token for " + userName + " in " + scope + ": " + token; logger.error(error); throw new ServiceException(error); } @@ -157,22 +155,19 @@ public class SessionUtil { } else { - groupId = String.valueOf(pContext - .getCurrentGroupId(httpServletRequest)); + groupId = String.valueOf(pContext.getCurrentGroupId(httpServletRequest)); groupName = pContext.getCurrentGroupName(httpServletRequest); } - sCredentials = new ServiceCredentials(userName, fullName, name, - lastName, email, scope, groupId, groupName, userAvatarURL, - token); + sCredentials = new ServiceCredentials(userName, fullName, name, lastName, email, scope, groupId, groupName, + userAvatarURL, token); } logger.debug("ServiceCredentials: " + sCredentials); return sCredentials; } - }