when the user is currently visiting a profile in a vre scope, the information show are the ones relative to the whole infrastructure

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/user-statistics@128565 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2016-05-12 08:29:44 +00:00
parent 4a3f7e352a
commit fcd0bba533
2 changed files with 7 additions and 8 deletions

View File

@ -4,9 +4,6 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<dependent-module archiveName="callout-tour-1.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/callout-tour/callout-tour">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="java-output-path" value="/user-statistics/target/user-statistics-portlet-0.0.1-SNAPSHOT/WEB-INF/classes"/>
<property name="context-root" value="user-statistics"/>
</wb-module>

View File

@ -99,14 +99,16 @@ public class UserStatisticsServiceImpl extends RemoteServiceServlet implements U
/**
* Indicates whether the scope is the whole infrastructure.
* @param userid in case userid is not null, the user is visiting a profile page and
* the statistics to return are the ones available in the whole infrastructure
* @return <code>true</code> if it is, <code>false</code> otherwise.
*/
private boolean isInfrastructureScope() {
private boolean isInfrastructureScope(String userid) {
boolean toReturn = false;
try {
GroupManager manager = new LiferayGroupManager();
long groupId = manager.getGroupIdFromInfrastructureScope(getASLSession().getScope());
toReturn = !manager.isVRE(groupId);
toReturn = !manager.isVRE(groupId) || userid != null;
return toReturn;
}
catch (Exception e) {
@ -278,9 +280,9 @@ public class UserStatisticsServiceImpl extends RemoteServiceServlet implements U
}
if(isWithinPortal()){
// If the user is in the root panel, we have to send him the overall number of posts made, comments/likes(received) and the space in use.
// If the user is in the root panel (or is visiting a profile page), we have to send him the overall number of posts made, comments/likes(received) and the space in use.
// Otherwise we have to filter on the vre.
boolean isInfrastructure = isInfrastructureScope();
boolean isInfrastructure = isInfrastructureScope(userid);
_log.debug("User scope is " + (isInfrastructure ? " the whole infrastucture " : " a VRE"));
// get path of the avatar
@ -363,7 +365,7 @@ public class UserStatisticsServiceImpl extends RemoteServiceServlet implements U
long totalFeeds = 0, totalLikes = 0, totalComments = 0;
// check if the user is or not in a VRE
boolean isInfrastructure = isInfrastructureScope();
boolean isInfrastructure = isInfrastructureScope(userid);
// date corresponding to one year ago
Calendar oneYearAgo = Calendar.getInstance();