first step to support VRE folder

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@91531 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2014-02-13 14:19:42 +00:00
parent eb1f9418a0
commit 895c4b33d4
10 changed files with 200 additions and 69 deletions

View File

@ -25,6 +25,8 @@ public class FileModel extends BaseModelData implements Serializable {
protected GXTFolderItemTypeEnum test; //TODO remove?
protected InfoContactModel infoContacts;
protected boolean isRoot = false;
protected boolean isVreFolder;
protected FileModel(){
}
@ -312,24 +314,26 @@ public class FileModel extends BaseModelData implements Serializable {
return (GXTFolderItemTypeEnum) get(ConstantsExplorer.FOLDERITEMTYPE);
}
public boolean isVreFolder() {
return isVreFolder;
}
public void setVreFolder(boolean isVreFolder) {
this.isVreFolder = isVreFolder;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("FileModel [isShareable()=");
builder.append(isShareable());
builder.append(", isShared()=");
builder.append(isShared());
builder.append(", getIdentifier()=");
builder.append(getIdentifier());
builder.append(", getName()=");
builder.append(getName());
builder.append(", getParentFileModel()=");
builder.append(getParentFileModel());
builder.append(", isDirectory()=");
builder.append(isDirectory());
builder.append("FileModel [test=");
builder.append(test);
builder.append(", infoContacts=");
builder.append(infoContacts);
builder.append(", isRoot=");
builder.append(isRoot);
builder.append(", isVreFolder=");
builder.append(isVreFolder);
builder.append("]");
return builder.toString();
}
}

View File

@ -16,12 +16,14 @@ public class FolderGridModel extends FileGridModel {
protected FolderGridModel() {
}
public FolderGridModel(String identifier, String name, String path, Date creationDate, FileModel parent, long size, boolean isDirectory, boolean isShared) {
public FolderGridModel(String identifier, String name, String path, Date creationDate, FileModel parent, long size, boolean isDirectory, boolean isShared, boolean isVREFolder) {
super(identifier, name, path, creationDate, parent, size, isDirectory, isShared);
super.setVreFolder(isVREFolder);
}
public FolderGridModel(String identifier, String name, Date creationDate, FileModel parent, long size, boolean isDirectory, boolean isShared) {
public FolderGridModel(String identifier, String name, Date creationDate, FileModel parent, long size, boolean isDirectory, boolean isShared, boolean isVREFolder) {
super(identifier, name, creationDate, parent, size, isDirectory, isShared);
super.setVreFolder(isVREFolder);
}
}

View File

@ -11,14 +11,15 @@ public class FolderModel extends FileModel {
*/
private static final long serialVersionUID = 1L;
protected FolderModel() {
}
public FolderModel(String identifier, String name, FileModel parent, boolean isDirectory, boolean isShared) {
public FolderModel(String identifier, String name, FileModel parent, boolean isDirectory, boolean isShared, boolean isVreFolder) {
super(identifier, name, parent, isDirectory, isShared);
}
public FolderModel(String identifier, String name, boolean isDirectory) {
public FolderModel(String identifier, String name, boolean isDirectory, boolean isVreFolder) {
super(identifier, name, isDirectory);
}
@ -27,4 +28,5 @@ public class FolderModel extends FileModel {
return super.toString();
}
}

View File

@ -0,0 +1,128 @@
package org.gcube.portlets.user.workspace.client.view.sharing;
import java.util.List;
import org.gcube.portlets.user.workspace.client.resources.Resources;
import org.gcube.portlets.user.workspace.shared.WorkspaceACL;
import org.gcube.portlets.user.workspace.shared.WorkspaceACL.USER_TYPE;
import com.extjs.gxt.ui.client.Style.ButtonScale;
import com.extjs.gxt.ui.client.Style.IconAlign;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.widget.HorizontalPanel;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.button.ToggleButton;
import com.extjs.gxt.ui.client.widget.tips.ToolTipConfig;
import com.google.gwt.core.shared.GWT;
public class PanelTogglePermission extends LayoutContainer {
protected static final String WORKSPACEACLGROUP = "WORKSPACEACLGROUP";
// private ButtonGroup buttonGroup;
private HorizontalPanel hp = new HorizontalPanel();
private WorkspaceACL selectedAcl = null;
public PanelTogglePermission(List<WorkspaceACL> acls) {
setStyleAttribute("margin-top", "10px");
setStyleAttribute("margin-bottom", "10px");
setSize(350, 30);
// buttonGroup = new ButtonGroup(acls.size());
// buttonGroup.mask("Loading ACLs");
hp.mask("Loading ACLs");
for (WorkspaceACL acl : acls) {
if(acl.getUserType().equals(USER_TYPE.OTHER)){
ToggleButton toggle = createToggle(acl);
toggle.setToggleGroup(WORKSPACEACLGROUP);
toggle.setStyleAttribute("margin-right", "5px");
// buttonGroup.add(toggle);
hp.add(toggle);
}
}
hp.unmask();
// buttonGroup.unmask();
add(hp);
}
private ToggleButton createToggle(final WorkspaceACL acl) {
final ToggleButton bToggle = new ToggleButton(acl.getLabel());
bToggle.setScale(ButtonScale.LARGE);
bToggle.setId(acl.getId());
bToggle.toggle(acl.getDefaultValue());
bToggle.setIconAlign(IconAlign.BOTTOM);
bToggle.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
if(bToggle.isPressed()){
selectedAcl = acl;
}
}
});
bToggle.setToolTip(new ToolTipConfig(acl.getDescription()));
setIcon(bToggle, acl.getId());
return bToggle;
}
private void setIcon(ToggleButton bToggle, String id){
if(id.compareTo("ADMINISTRATOR")==0){
}else if(id.compareTo("READ_ONLY")==0){
bToggle.setIcon(Resources.getIconReadOnly());
}else if(id.compareTo("WRITE_OWNER")==0){
bToggle.setIcon(Resources.getIconWriteOwn());
}else if(id.compareTo("WRITE_ALL")==0){
bToggle.setIcon(Resources.getIconWriteAll());
}
}
public WorkspaceACL getSelectedACL() {
GWT.log("Selected ACL is: "+selectedAcl);
return selectedAcl;
}
/*
public List<WorkspaceACL> getCheckedGroupList() {
List<WorkspaceACL> listDS = new ArrayList<WorkspaceACL>();
List<Radio> values = new ArrayList<Radio>();
if (radioGroup.getValue()!=null){
Radio radio = radioGroup.getValue();
values.add((Radio) radio);
}
else {
List<Field<?>> listChecks = radioGroup.getAll();
for (Field<?> field : listChecks) {
values.add((Radio) field);
}
}
for (Radio radio : values) {
if (radio.isEnabled()){
WorkspaceACL acl = (WorkspaceACL) radio.getData(WORKSPACEACL);
listDS.add(acl);
}
}
if (listDS.size() == 0)
return null;
return listDS;
}
*/
}

View File

@ -603,8 +603,6 @@ public class ContextMenuTree {
printSelected();
if(targetFileModel!=null){
if(targetFileModel.getParentFileModel()==null){
@ -712,6 +710,18 @@ public class ContextMenuTree {
contextMenu.getItemByItemId(WorkspaceOperation.SHARE_LINK.getId()).setVisible(true);
}
/*
if(selectedItem.isBaseVREFolder()){
contextMenu.getItemByItemId(WorkspaceOperation.SHARE.getId()).setVisible(false); //SHARE
contextMenu.getItemByItemId(WorkspaceOperation.INSERT_SHARED_FOLDER.getId()).setVisible(false); //insert shared folder
contextMenu.getItemByItemId(WorkspaceOperation.UNSHARE.getId()).setVisible(false); //UNSHARE
contextMenu.getItemByItemId(WorkspaceOperation.RENAME.getId()).setVisible(false); //UNSHARE
contextMenu.getItemByItemId(WorkspaceOperation.REMOVE.getId()).setVisible(false); //UNSHARE
return;
}*/
//CASE DIRECTORY
if(selectedItem.isDirectory()){
contextMenu.getItemByItemId(WorkspaceOperation.SHARE.getId()).setVisible(true); //SHARE
contextMenu.getItemByItemId(WorkspaceOperation.SHOW.getId()).setVisible(false); //show

View File

@ -19,6 +19,7 @@ import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
import org.gcube.common.homelibrary.home.workspace.Properties;
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
import org.gcube.common.homelibrary.home.workspace.WorkspaceSharedFolder;
import org.gcube.common.homelibrary.home.workspace.WorkspaceSmartFolder;
import org.gcube.common.homelibrary.home.workspace.accounting.AccountingEntry;
import org.gcube.common.homelibrary.home.workspace.accounting.AccountingEntryAdd;
@ -789,7 +790,7 @@ public class GWTWorkspaceBuilder {
logger.trace("workspace name: "+ workspaceRoot.getName());
logger.trace("workspace path "+ workspaceRoot.getPath());
FolderModel root = new FolderModel(workspaceRoot.getId(),workspaceRoot.getName(),null, true, workspaceRoot.isShared());
FolderModel root = new FolderModel(workspaceRoot.getId(),workspaceRoot.getName(),null, true, workspaceRoot.isShared(), false);
root.setIsRoot(true);
// root.setShareable(true);
@ -847,7 +848,7 @@ public class GWTWorkspaceBuilder {
switch (item.getType()) {
case FOLDER: fileModel = new FolderModel(item.getId(), item.getName(), true);
case FOLDER: fileModel = new FolderModel(item.getId(), item.getName(), true, false);
fileModel.setType(GXTFolderItemTypeEnum.FOLDER.toString());
break;
@ -859,13 +860,11 @@ public class GWTWorkspaceBuilder {
case SHARED_FOLDER:
fileModel = new FolderModel(item.getId(), item.getName(), true);
WorkspaceSharedFolder sharedFolder = (WorkspaceSharedFolder) item;
fileModel = new FolderModel(item.getId(), item.getName(), true, sharedFolder.isVreFolder());
fileModel.setShared(true);
fileModel.setType(GXTFolderItemTypeEnum.SHARED_FOLDER.toString());
// WorkspaceSharedFolder sharedFolder = (WorkspaceSharedFolder) item;
// fileModel.setListShareUser(buildGxtInfoContactFromPortalLogin(sharedFolder.getUsers()));
break;
default:
logger.error("gxt conversion return null for item "+item.getName());
@ -933,15 +932,16 @@ public class GWTWorkspaceBuilder {
case FOLDER:
fileModel = new FolderModel(item.getId(), item.getName(), (FolderModel) parentFolderModel, true, false);
fileModel = new FolderModel(item.getId(), item.getName(), (FolderModel) parentFolderModel, true, false, false);
fileModel.setType(GXTFolderItemTypeEnum.FOLDER.toString());
fileModel.setShareable(true);
fileModel.setDescription(item.getDescription());
// WorkspaceFolder folder = (WorkspaceFolder)
// WorkspaceFolder folder = (WorkspaceFolder) item;
break;
case FOLDER_ITEM:
// fileModel = new FileModel(item.getId(), item.getName(), item.getPath(), (FolderModel) parentFolderModel, false);
fileModel = new FileModel(item.getId(), item.getName(), (FolderModel) parentFolderModel, false, false);
FolderItem folderItem = (FolderItem) item;
@ -950,8 +950,9 @@ public class GWTWorkspaceBuilder {
break;
case SHARED_FOLDER:
fileModel = new FolderModel(item.getId(), item.getName(), (FolderModel) parentFolderModel, true, true);
WorkspaceSharedFolder shared = (WorkspaceSharedFolder) item;
String name = shared.isVreFolder()?shared.getDisplayName():item.getName();
fileModel = new FolderModel(item.getId(), name, (FolderModel) parentFolderModel, true, true,shared.isVreFolder());
fileModel.setType(GXTFolderItemTypeEnum.SHARED_FOLDER.toString());
fileModel.setShareable(true);
fileModel.setDescription(item.getDescription());
@ -1007,7 +1008,7 @@ public class GWTWorkspaceBuilder {
case FOLDER:
// fileGridModel = (FolderGridModel) new FolderGridModel(item.getId(), item.getName(), toDate(item.getCreationDate()), parentFileModel, -1, true, false);
fileGridModel = (FolderGridModel) new FolderGridModel(item.getId(), item.getName(), toDate(item.getLastModified()), parentFileModel, -1, true, false);
fileGridModel = (FolderGridModel) new FolderGridModel(item.getId(), item.getName(), toDate(item.getLastModified()), parentFileModel, -1, true, false,false);
fileGridModel.setType(GXTFolderItemTypeEnum.FOLDER.toString());
fileGridModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS);
fileGridModel.setShareable(true);
@ -1023,8 +1024,10 @@ public class GWTWorkspaceBuilder {
case SHARED_FOLDER:
WorkspaceSharedFolder shared = (WorkspaceSharedFolder) item;
String name = shared.isVreFolder()?shared.getDisplayName():item.getName();
// fileGridModel = (FolderGridModel) new FolderGridModel(item.getId(), item.getName(), toDate(item.getCreationDate()), parentFileModel, -1, true, false);
fileGridModel = (FolderGridModel) new FolderGridModel(item.getId(), item.getName(), toDate(item.getLastModified()), parentFileModel, -1, true, true);
fileGridModel = (FolderGridModel) new FolderGridModel(item.getId(), name, toDate(item.getLastModified()), parentFileModel, -1, true, true,shared.isVreFolder());
fileGridModel.setType(GXTFolderItemTypeEnum.SHARED_FOLDER.toString());
fileGridModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS);
fileGridModel.setShareable(true);
@ -1096,7 +1099,7 @@ public class GWTWorkspaceBuilder {
case FOLDER:
// fileGridModel = (FolderGridModel) new FolderGridModel(item.getId(), item.getName(), toDate(item.getCreationTime()), parentFileModel, -1, true, false);
fileGridModel = (FolderGridModel) new FolderGridModel(item.getId(), item.getName(), toDate(item.getLastModificationTime()), parentFileModel, -1, true, false);
fileGridModel = (FolderGridModel) new FolderGridModel(item.getId(), item.getName(), toDate(item.getLastModificationTime()), parentFileModel, -1, true, false,false);
fileGridModel.setType(GXTFolderItemTypeEnum.FOLDER.toString());
fileGridModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS);
fileGridModel.setShareable(true);
@ -1112,8 +1115,9 @@ public class GWTWorkspaceBuilder {
break;
case SHARED_FOLDER:
// fileGridModel = (FolderGridModel) new FolderGridModel(item.getId(), item.getName(), toDate(item.getCreationTime()), parentFileModel, -1, true, true);
fileGridModel = (FolderGridModel) new FolderGridModel(item.getId(), item.getName(), toDate(item.getLastModificationTime()), parentFileModel, -1, true, true);
WorkspaceSharedFolder shared = (WorkspaceSharedFolder) item;
String name = shared.isVreFolder()?shared.getDisplayName():item.getName();
fileGridModel = (FolderGridModel) new FolderGridModel(item.getId(), name, toDate(item.getLastModificationTime()), parentFileModel, -1, true, true, shared.isVreFolder());
fileGridModel.setType(GXTFolderItemTypeEnum.SHARED_FOLDER.toString());
fileGridModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS);
fileGridModel.setShareable(true);
@ -1421,7 +1425,7 @@ public class GWTWorkspaceBuilder {
*/
public FolderModel buildGXTFolderModelItem(WorkspaceFolder wsFolder, FileModel parent) throws InternalErrorException {
FolderModel folder = new FolderModel(wsFolder.getId(),wsFolder.getName(), parent, true, wsFolder.isShared());
FolderModel folder = new FolderModel(wsFolder.getId(),wsFolder.getName(), parent, true, wsFolder.isShared(), false);
folder.setShareable(true);
folder.setDescription(wsFolder.getDescription());
// folder.setOwner(wsFolder.getOwner());

View File

@ -45,6 +45,7 @@ import org.gcube.portlets.user.workspace.client.model.MessageModel;
import org.gcube.portlets.user.workspace.client.model.ScopeModel;
import org.gcube.portlets.user.workspace.client.model.SmartFolderModel;
import org.gcube.portlets.user.workspace.client.model.SubTree;
import org.gcube.portlets.user.workspace.client.resources.Resources;
import org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService;
import org.gcube.portlets.user.workspace.client.workspace.GWTWorkspaceItem;
import org.gcube.portlets.user.workspace.server.notifications.NotificationsProducer;
@ -944,7 +945,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
return;
}
FolderModel parentModel = new FolderModel(item.getParent().getId(), item.getParent().getName(), null, true, item.getParent().isShared()); //Create parent model
FolderModel parentModel = new FolderModel(item.getParent().getId(), item.getParent().getName(), null, true, item.getParent().isShared(), false); //Create parent model
List<FileModel> childrenList = getFolderChildren(parentModel); //create children list
@ -2509,7 +2510,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
switch (acl) {
case ADMINISTRATOR:
acls.add(new WorkspaceACL(acl.toString(), acl.toString(), false, USER_TYPE.ADMINISTRATOR,""));
acls.add(new WorkspaceACL(acl.toString(), acl.toString(), false, USER_TYPE.ADMINISTRATOR, ""));
break;
case READ_ONLY:
acls.add(new WorkspaceACL(acl.toString(), "Read Only", false, USER_TYPE.OTHER, "Users can read any file but cannot update/delete"));

View File

@ -28,7 +28,7 @@ public class UserUtil {
public static String getUserFullName(String portalLogin){
// return user.getPortalLogin(); //for testing in eclipse
logger.trace("Finding full name for: "+portalLogin);
// logger.trace("Finding full name for: "+portalLogin);
if(portalLogin==null)
return "";
@ -58,7 +58,7 @@ public class UserUtil {
if (curr != null){
logger.trace("Return "+curr.getFullname() +" full name for: "+portalLogin);
// logger.trace("Return "+curr.getFullname() +" full name for: "+portalLogin);
return curr.getFullname();
}

View File

@ -74,10 +74,10 @@ public class WsUtil {
/*USE ANOTHER ACCOUNT (OTHERWHISE BY TEST_USER) FOR RUNNING
* COMMENT THIS IN DEVELOP ENVIROMENT (UNCOMMENT IN PRODUCTION)*/
user=TEST_USER;
// user=TEST_USER;
//UNCOMMENT THIS IN DEVELOP ENVIROMENT
// user = "francesco.mangiacrapa";
user = "francesco.mangiacrapa";
logger.warn("WORKSPACE PORTLET STARTING IN TEST MODE - NO USER FOUND - PORTLETS STARTING WITH FOLLOWING SETTINGS:");
logger.warn("session id: "+sessionID);
@ -105,10 +105,10 @@ public class WsUtil {
withoutPortal = true;
//COMMENT THIS IN PRODUCTION ENVIROMENT
// }else if(user.compareToIgnoreCase("francesco.mangiacrapa")==0){
//
// withoutPortal = true;
// //END UNCOMMENT
}else if(user.compareToIgnoreCase("francesco.mangiacrapa")==0){
withoutPortal = true;
//END UNCOMMENT
}else{
withoutPortal = false;

View File

@ -21,6 +21,7 @@ public class WorkspaceACL implements Serializable{
private String description;
public enum USER_TYPE{ADMINISTRATOR, GROUP, OWNER, OTHER};
public WorkspaceACL(String id, String label, boolean defaultValue, USER_TYPE userType, String description) {
@ -33,9 +34,7 @@ public class WorkspaceACL implements Serializable{
}
public WorkspaceACL() {
// TODO Auto-generated constructor stub
}
public String getId() {
@ -79,23 +78,4 @@ public class WorkspaceACL implements Serializable{
this.description = description;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("WorkspaceACL [id=");
builder.append(id);
builder.append(", label=");
builder.append(label);
builder.append(", defaultValue=");
builder.append(defaultValue);
builder.append(", userType=");
builder.append(userType);
builder.append(", description=");
builder.append(description);
builder.append("]");
return builder.toString();
}
}