implemented the context's dependent capability: whenever ina VRE context it shows the VRE Folder content only
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/workspace-widget-portlet@167179 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
2dd71014f9
commit
212419b86b
|
@ -238,7 +238,7 @@ public class Utils {
|
|||
public static ImageType getFileIconImageType(String extension) {
|
||||
if (extension == null || extension.compareTo("") == 0)
|
||||
return ImageType.NONE;
|
||||
|
||||
extension = extension.toLowerCase();
|
||||
switch (extension) {
|
||||
case "doc":
|
||||
case "docx":
|
||||
|
|
|
@ -29,6 +29,7 @@ import com.liferay.portal.kernel.json.JSONObject;
|
|||
import com.liferay.portal.kernel.log.LogFactoryUtil;
|
||||
import com.liferay.portal.kernel.servlet.ServletResponseUtil;
|
||||
import com.liferay.portal.kernel.util.ParamUtil;
|
||||
import com.liferay.portal.service.GroupLocalServiceUtil;
|
||||
import com.liferay.portal.util.PortalUtil;
|
||||
import com.liferay.util.bridges.mvc.MVCPortlet;
|
||||
|
||||
|
@ -70,8 +71,8 @@ public class WorkspaceWidget extends MVCPortlet {
|
|||
listItems(resourceRequest, resourceResponse, selectedItemId, selectedItemName, start, length, draw);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private void listItems(ResourceRequest request, ResourceResponse resourceResponse, String itemId, String itemName, int start, int offset, int draw) {
|
||||
try {
|
||||
AuthorizedUser authUser = setAuthorizationToken(request);
|
||||
|
@ -80,11 +81,21 @@ public class WorkspaceWidget extends MVCPortlet {
|
|||
WSItem clicked = null;
|
||||
int count = 0;
|
||||
if (itemId.compareTo("root") == 0) {
|
||||
//here we have to check is is a VRE, in that case the content of the VRE Folder is the root
|
||||
itemId = getRootItem(request).getId();
|
||||
itemsList = StorageHubServiceUtil.getRootChildren(authUser, start, offset);
|
||||
toSet = new Breadcrumb(itemId, Utils.getCurrentUser(request).getFirstName()+"\'s home");
|
||||
request.getPortletSession().setAttribute(BREADCRUMB_ATTR, toSet, PortletSession.APPLICATION_SCOPE);
|
||||
//here we have to check if is a VRE, in that case the content of the VRE Folder is the root
|
||||
long groupId = PortalUtil.getScopeGroupId(request);
|
||||
if (GroupLocalServiceUtil.getParentGroups(groupId).isEmpty()) { //is in Site / RootVO
|
||||
itemId = getRootItem(request).getId();
|
||||
itemsList = StorageHubServiceUtil.getRootChildren(authUser, start, offset);
|
||||
toSet = new Breadcrumb(itemId, Utils.getCurrentUser(request).getFirstName()+"\'s home");
|
||||
request.getPortletSession().setAttribute(BREADCRUMB_ATTR, toSet, PortletSession.APPLICATION_SCOPE);
|
||||
} else { //is in a VRE
|
||||
WorkspaceManagerClient wsclient = AbstractPlugin.workspace().build();
|
||||
itemId = wsclient.getVreFolder("hl:accounting").getId();
|
||||
itemsList = StorageHubServiceUtil.getItemChildren(authUser, itemId, itemId, start, offset);
|
||||
String groupName = GroupLocalServiceUtil.getGroup(groupId).getName();
|
||||
toSet = new Breadcrumb(itemId, groupName+"\'s VRE home");
|
||||
request.getPortletSession().setAttribute(BREADCRUMB_ATTR, toSet, PortletSession.APPLICATION_SCOPE);
|
||||
}
|
||||
}
|
||||
else {
|
||||
_log.debug("non root");
|
||||
|
@ -218,7 +229,6 @@ public class WorkspaceWidget extends MVCPortlet {
|
|||
String scope = Utils.getCurrentContext(request);
|
||||
String authorizationToken = Utils.getCurrentUserToken(scope, currentUser.getUsername());
|
||||
SecurityTokenProvider.instance.set(authorizationToken);
|
||||
return new AuthorizedUser(currentUser, authorizationToken);
|
||||
return new AuthorizedUser(currentUser, authorizationToken, scope);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,10 +5,12 @@ import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
|||
public class AuthorizedUser {
|
||||
private GCubeUser user;
|
||||
private String token;
|
||||
public AuthorizedUser(GCubeUser user, String token) {
|
||||
private String context;
|
||||
public AuthorizedUser(GCubeUser user, String token, String context) {
|
||||
super();
|
||||
this.user = user;
|
||||
this.token = token;
|
||||
this.context = context;
|
||||
}
|
||||
public GCubeUser getUser() {
|
||||
return user;
|
||||
|
@ -22,6 +24,12 @@ public class AuthorizedUser {
|
|||
public void setSecurityToken(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
public String getContext() {
|
||||
return context;
|
||||
}
|
||||
public void setContext(String context) {
|
||||
this.context = context;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
@ -29,9 +37,9 @@ public class AuthorizedUser {
|
|||
builder.append(user);
|
||||
builder.append(", token=");
|
||||
builder.append(token);
|
||||
builder.append(", context=");
|
||||
builder.append(context);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ public class WSItem implements ItemInterface {
|
|||
protected boolean isSpecialFolder = false;
|
||||
protected boolean isSharedFolder = false;
|
||||
protected boolean isRoot = false;
|
||||
protected boolean hidden = false;
|
||||
protected Date dateCreated;
|
||||
protected Date lastUpdated;
|
||||
|
||||
|
@ -54,6 +55,7 @@ public class WSItem implements ItemInterface {
|
|||
this.name = name;
|
||||
this.type = isFolder?ItemType.PRIVATE_FOLDER:ItemType.UNKNOWN_TYPE;
|
||||
this.children = new ArrayList<WSItem>();
|
||||
this.hidden = false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -74,6 +76,7 @@ public class WSItem implements ItemInterface {
|
|||
this(parent, id, name, type, path, owner, isFolder, isRoot);
|
||||
this.dateCreated = creationDate;
|
||||
this.lastUpdated = lastUpdated;
|
||||
this.hidden = false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -98,6 +101,7 @@ public class WSItem implements ItemInterface {
|
|||
this.owner = owner;
|
||||
this.isRoot = isRoot;
|
||||
this.isFolder = isFolder;
|
||||
this.hidden = false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -305,6 +309,12 @@ public class WSItem implements ItemInterface {
|
|||
this.isSpecialFolder = isSpecialFolder;
|
||||
}
|
||||
|
||||
public boolean isHidden() {
|
||||
return hidden;
|
||||
}
|
||||
public void setHidden(boolean hidden) {
|
||||
this.hidden = hidden;
|
||||
}
|
||||
/**
|
||||
* Gets the path.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue