Fixed bug on currUserId. See #6275

Not it is passed as parameter

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@141347 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2016-12-21 17:49:00 +00:00
parent 3e267e603b
commit c905902b5d
2 changed files with 23 additions and 15 deletions

View File

@ -222,25 +222,28 @@ public class GWTWorkspaceBuilder {
* Builds the image url.
*
* @param id the id
* @param scope the scope
* @param currentGroupId the current group id
* @param currUserId the curr user id
* @return the string
*/
protected String buildImageUrl(String id, String scope)
protected String buildImageUrl(String id, String currentGroupId, String currUserId)
{
return buildImageServiceUrl(id, ImageRequestType.IMAGE, scope);
return buildImageServiceUrl(id, ImageRequestType.IMAGE, currentGroupId, currUserId);
}
/**
* Builds the thumbnail url.
*
* @param id the id
* @param currentGroupId the current group id read from PortalContext
* @param currentGroupId the current group id
* @param currUserId the curr user id
* @return the string
*/
protected String buildThumbnailUrl(String id, String currentGroupId)
protected String buildThumbnailUrl(String id, String currentGroupId, String currUserId)
{
return buildImageServiceUrl(id, ImageRequestType.THUMBNAIL, currentGroupId);
return buildImageServiceUrl(id, ImageRequestType.THUMBNAIL, currentGroupId, currUserId);
}
@ -250,9 +253,10 @@ public class GWTWorkspaceBuilder {
* @param id the id
* @param requestType the request type
* @param currentGroupId the current group id read from PortalContext
* @param currUserId
* @return the string
*/
protected String buildImageServiceUrl(String id, ImageRequestType requestType, String currentGroupId){
protected String buildImageServiceUrl(String id, ImageRequestType requestType, String currentGroupId, String currUserId){
StringBuilder sb = new StringBuilder();
sb.append(IMAGE_SERVICE_URL);
sb.append("?id=");
@ -261,6 +265,8 @@ public class GWTWorkspaceBuilder {
sb.append(requestType.toString());
sb.append("&"+ConstantsExplorer.CURRENT_CONTEXT_ID+"=");
sb.append(currentGroupId);
sb.append("&"+ConstantsExplorer.CURRENT_USER_ID+"=");
sb.append(currUserId);
sb.append("&random=");
sb.append(UUID.randomUUID().toString());
return sb.toString();
@ -277,7 +283,7 @@ public class GWTWorkspaceBuilder {
* @throws InternalErrorException the internal error exception
*/
@SuppressWarnings("unchecked")
protected GWTWorkspaceItem buildGWTWorkspaceImage(WorkspaceItem item, boolean isInteralImage, boolean fullDetails, String currentGroupId) throws InternalErrorException
protected GWTWorkspaceItem buildGWTWorkspaceImage(WorkspaceItem item, boolean isInteralImage, boolean fullDetails, String currentGroupId, String currentUserId) throws InternalErrorException
{
GWTWorkspaceItem gwtImage;
@ -303,8 +309,8 @@ public class GWTWorkspaceBuilder {
toDate(image.getLastModificationTime()),
GWTWorkspaceItemAction.valueOf(image.getLastAction().toString()),
null,
buildImageUrl(image.getId(), currentGroupId),
buildThumbnailUrl(image.getId(), currentGroupId),
buildImageUrl(image.getId(), currentGroupId, currentUserId),
buildThumbnailUrl(image.getId(), currentGroupId, currentUserId),
Integer.parseInt(image.getProperties().getPropertyValue(NodeProperty.IMAGE_WIDTH.toString())),
Integer.parseInt(image.getProperties().getPropertyValue(NodeProperty.IMAGE_HEIGHT.toString())),
Integer.parseInt(image.getProperties().getPropertyValue(NodeProperty.THUMBNAIL_WIDTH.toString())),
@ -336,8 +342,8 @@ public class GWTWorkspaceBuilder {
toDate(image.getLastModificationTime()),
GWTWorkspaceItemAction.valueOf(image.getLastAction().toString()),
null, //parent
buildImageUrl(image.getId(), currentGroupId),
buildThumbnailUrl(image.getId(), currentGroupId),
buildImageUrl(image.getId(), currentGroupId, currentUserId),
buildThumbnailUrl(image.getId(), currentGroupId, currentUserId),
image.getWidth(),
image.getHeight(),
image.getLength(),
@ -348,8 +354,8 @@ public class GWTWorkspaceBuilder {
}else{
gwtImage = new GWTExternalImage(
buildImageUrl(image.getId(), currentGroupId),
buildThumbnailUrl(image.getId(), currentGroupId),
buildImageUrl(image.getId(), currentGroupId, currentUserId),
buildThumbnailUrl(image.getId(), currentGroupId, currentUserId),
image.getWidth(),
image.getHeight(),
image.getLength(),

View File

@ -41,6 +41,7 @@ import org.gcube.common.homelibrary.home.workspace.folder.items.GCubeItem;
import org.gcube.common.homelibrary.home.workspace.search.SearchItem;
import org.gcube.common.homelibrary.home.workspace.trash.WorkspaceTrashFolder;
import org.gcube.common.homelibrary.home.workspace.trash.WorkspaceTrashItem;
import org.gcube.common.portal.PortalContext;
import org.gcube.datacatalogue.ckanutillibrary.ApplicationProfileScopePerUrlReader;
import org.gcube.datacatalogue.ckanutillibrary.DataCatalogue;
import org.gcube.datacatalogue.ckanutillibrary.DataCatalogueFactory;
@ -1287,7 +1288,8 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
workspaceLogger.trace("item name " + item.getName());
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
PortalContextInfo context = WsUtil.getPortalContext(this.getThreadLocalRequest());
return builder.buildGWTWorkspaceImage(item, isInteralImage, fullDetails, context.getCurrGroupId()+"");
GCubeUser user = PortalContext.getConfiguration().getCurrentUser(this.getThreadLocalRequest());
return builder.buildGWTWorkspaceImage(item, isInteralImage, fullDetails, context.getCurrGroupId()+"", user.getUserId()+"");
} catch (Exception e) {
workspaceLogger.error("Error in server get image by id", e);