updated icon for root folder, added support for folder size and private storage used

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@101089 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2014-10-28 16:12:40 +00:00
parent ed0ed850bd
commit 2f814300ae
13 changed files with 237 additions and 66 deletions

View File

@ -10,7 +10,7 @@
<groupId>org.gcube.portlets.user</groupId>
<artifactId>workspace-tree-widget</artifactId>
<version>6.6.8-SNAPSHOT</version>
<version>6.7.0-SNAPSHOT</version>
<name>gCube Workspace Tree Widget</name>
<description>
gCube Workspace Tree Widget.
@ -326,7 +326,7 @@
<executions>
<execution>
<goals>
<goal>compile</goal>
<!-- <goal>compile</goal> -->
<!-- <goal>test</goal> -->
</goals>
</execution>

View File

@ -138,6 +138,7 @@ import org.gcube.portlets.user.workspace.client.workspace.folder.item.GWTExterna
import org.gcube.portlets.user.workspace.client.workspace.folder.item.gcube.GWTImageDocument;
import org.gcube.portlets.user.workspace.client.workspace.folder.item.gcube.GWTUrlDocument;
import org.gcube.portlets.user.workspace.shared.SessionExpiredException;
import org.gcube.portlets.user.workspace.shared.UserBean;
import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingField;
import org.gcube.portlets.widgets.fileupload.client.events.FileUploadCompleteEvent;
import org.gcube.portlets.widgets.fileupload.client.events.FileUploadCompleteEventHandler;
@ -180,6 +181,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
private boolean selectRootItem;
private FileUploader fileUploader;
public static String myLogin;
public static String myLoginFirstName;
private static AppControllerExplorer singleton;
@ -2200,7 +2202,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
private void loadMyLogin(){
rpcWorkspaceService.getMyLogin(new AsyncCallback<String>() {
rpcWorkspaceService.getMyLogin(new AsyncCallback<UserBean>() {
@Override
public void onFailure(Throwable caught) {
@ -2210,9 +2212,10 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
}
@Override
public void onSuccess(String result) {
GWT.log("My login is: "+result);
myLogin = result;
public void onSuccess(UserBean user) {
GWT.log("My login is: "+user.getUsername());
myLogin = user.getUsername();
myLoginFirstName = user.getFirstName();
}
});
}

View File

@ -5,6 +5,9 @@ import com.google.gwt.resources.client.ImageResource;
public interface Icons extends ClientBundle {
@Source("icons/cloud-drive.png")
ImageResource cloudDrive();
@Source("icons/table.png")
ImageResource table();

View File

@ -39,7 +39,11 @@ public class Resources {
private static final String PPTX = "vnd.openxmlformats-officedocument.presentationml.presentation";
private static final String XSLX = "vnd.openxmlformats-officedocument.spreadsheetml.sheet";
public static AbstractImagePrototype getCloudDriveIcon(){
return AbstractImagePrototype.create(ICONS.cloudDrive());
}
public static AbstractImagePrototype getIconTable(){
return AbstractImagePrototype.create(ICONS.table());

Binary file not shown.

After

Width:  |  Height:  |  Size: 539 B

View File

@ -20,6 +20,7 @@ import org.gcube.portlets.user.workspace.shared.ExtendedWorkspaceACL;
import org.gcube.portlets.user.workspace.shared.SessionExpiredException;
import org.gcube.portlets.user.workspace.shared.TrashContent;
import org.gcube.portlets.user.workspace.shared.TrashOperationContent;
import org.gcube.portlets.user.workspace.shared.UserBean;
import org.gcube.portlets.user.workspace.shared.WorkspaceACL;
import org.gcube.portlets.user.workspace.shared.WorkspaceTrashOperation;
import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingField;
@ -30,101 +31,101 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
@RemoteServiceRelativePath("WorkspaceService")
public interface GWTWorkspaceService extends RemoteService{
/** SendToRequest **/
String getUserWorkspaceSize() throws Exception;
public FolderModel getRootForTree() throws Exception;
public FolderModel getRootForTree(String scopeId) throws Exception;
public List<ScopeModel> getAllScope() throws Exception;
public List<FileModel> getFolderChildren(FolderModel folder) throws Exception, SessionExpiredException;
public List<FileGridModel> getFolderChildrenForFileGrid(FileModel folder) throws Exception, SessionExpiredException;
public FileDetailsModel getDetailsFile(FileModel item) throws Exception;
public FolderModel createFolder(String nameFolder, String description, FileModel parent) throws Exception;
public ArrayList<SubTree> getChildrenSubTreeToRootByIdentifier(String itemIdentifier) throws Exception;
public List<FileGridModel> getSmartFolderResultsByCategory(String category) throws Exception;
public SmartFolderModel createSmartFolder(String name, String description, String query) throws Exception;
public List<FileGridModel> getSmartFolderResultsById(String folderId) throws Exception;
public List<SmartFolderModel> getAllSmartFolders() throws Exception;
public GWTWorkspaceItem getImageById(String identifier, boolean isInteralImage, boolean fullDetails) throws Exception;
public GWTWorkspaceItem getUrlById(String identifier, boolean isInternalUrl, boolean fullDetails) throws Exception;
public FileModel createExternalUrl(FileModel parentFileModel, String name, String description, String url) throws Exception;
public void setValueInSession(String name, String value) throws Exception;
public List<FileGridModel> getItemsBySearchName(String text) throws Exception;
public Boolean moveItem(String itemId, String destinationId) throws Exception;
public Boolean removeItem(String itemId) throws Exception;
public Boolean renameItem(String itemId, String newName, String oldName) throws Exception;
public Boolean removeSmartFolder(String itemId, String name) throws Exception;
public List<InfoContactModel> getAllContacts() throws Exception;
public String getUrlWebDav(String itemId) throws Exception;
// public boolean sendTo(List<InfoContactModel> listContacts, List<FileModel> listAttachments, String subject, String text) throws Exception;
// public boolean sendTo(List<InfoContactModel> listContacts, List<FileModel> listAttachments, String subject, String text) throws Exception;
public boolean sentToByMessageModel(MessageModel message) throws Exception;
public boolean sendToById(List<String> listContactsId, List<String> listAttachmentsId, String subject, String text) throws Exception;
public List<MessageModel> getAllMessagesReceived() throws Exception;
public List<MessageModel> getNewMessagesReceived() throws Exception;
public List<MessageModel> getAllMessagesSent() throws Exception;
public List<MessageModel> searchInSentMessagesByText(String text) throws Exception;
public List<MessageModel> searchInReceivedMessagesByText(String text) throws Exception;
public MessageModel getMessageById(String messageIdentifier, String messageType) throws Exception;
public boolean saveAttachments(String messageIdentifier, String messageType) throws Exception;
public boolean saveAttach(String attachId) throws Exception;
public boolean markMessage(String messageIdentifier, String messageType, boolean boolMark, String markType) throws Exception;
public boolean deleteMessage(String messageIdentifier, String messageType) throws Exception;
public boolean copyItem(String itemId, String destinationFolderId) throws Exception;
public List<BulkCreatorModel> getListFolderBulkCreator() throws Exception;
public boolean deleteBulk(String bulkId) throws Exception;
public GWTWorkspaceItem getTimeSeriesById(String identifier) throws Exception;
boolean shareFolder(FileModel folder, List<InfoContactModel> listContacts,
boolean isNewFolder, WorkspaceACL acl) throws Exception;
public List<InfoContactModel> getListUserSharedByFolderSharedId(String itemId) throws Exception;
public boolean unSharedFolderByFolderSharedId(String folderSharedId) throws Exception;
public List<FileModel> getListParentsByItemIdentifier(String itemIdentifier, boolean includeItemAsParent) throws Exception;
public String getURLFromApplicationProfile(String oid) throws Exception;
public InfoContactModel getOwnerByItemId(String itemId) throws Exception;
public String itemExistsInWorkpaceFolder(String parentId, String itemName) throws Exception;
public List<InfoContactModel> getListUserSharedBySharedItem(String sharedItemId) throws Exception;
@ -165,7 +166,7 @@ public interface GWTWorkspaceService extends RemoteService{
* @throws Exception
*/
List<FileGridModel> getFolderChildrenForFileGridById(String folderId) throws Exception, SessionExpiredException;
String getShortUrl(String longUrl) throws Exception;
/**
@ -178,8 +179,8 @@ public interface GWTWorkspaceService extends RemoteService{
throws Exception;
boolean isSessionExpired() throws Exception;
void deleteListItemsForIds(List<String> ids) throws Exception;
/**
@ -204,7 +205,7 @@ public interface GWTWorkspaceService extends RemoteService{
void setACLs(String folderId, List<String> listLogins, String aclType)
throws Exception;
String getMyLogin();
UserBean getMyLogin();
void updateACLForVREbyGroupName(String folderId, String aclType) throws Exception;

View File

@ -19,6 +19,7 @@ import org.gcube.portlets.user.workspace.client.workspace.GWTWorkspaceItem;
import org.gcube.portlets.user.workspace.shared.ExtendedWorkspaceACL;
import org.gcube.portlets.user.workspace.shared.TrashContent;
import org.gcube.portlets.user.workspace.shared.TrashOperationContent;
import org.gcube.portlets.user.workspace.shared.UserBean;
import org.gcube.portlets.user.workspace.shared.WorkspaceACL;
import org.gcube.portlets.user.workspace.shared.WorkspaceTrashOperation;
import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingField;
@ -26,7 +27,8 @@ import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingField;
import com.google.gwt.user.client.rpc.AsyncCallback;
public interface GWTWorkspaceServiceAsync {
void getUserWorkspaceSize(AsyncCallback<String> callback);
void getRootForTree(AsyncCallback<FolderModel> callback);
void getRootForTree(String scopeId, AsyncCallback<FolderModel> callback);
@ -182,7 +184,7 @@ public interface GWTWorkspaceServiceAsync {
void setACLs(String folderId, List<String> listLogins, String aclType,
AsyncCallback<Void> callback);
void getMyLogin(AsyncCallback<String> callback);
void getMyLogin(AsyncCallback<UserBean> callback);
void updateACLForVREbyGroupName(String folderId, String aclType,
AsyncCallback<Void> callback);
@ -216,4 +218,6 @@ public interface GWTWorkspaceServiceAsync {
void getACLBySharedFolderId(String identifier, AsyncCallback<WorkspaceACL> callback);
}

View File

@ -61,6 +61,8 @@ import com.google.gwt.user.client.ui.AbstractImagePrototype;
public class AsyncTreePanel extends LayoutContainer {
private static final String TREE_MESSAGE_PANEL_ASYNC = "treeMessagePanelAsync";
private static final String ROOT_SUFFIX = "'s workspace";
// private TreeLoader<FileModel> loader;
private TreePanel<FileModel> treePanel;
private TreeStore<FileModel> store;
@ -147,6 +149,10 @@ public class AsyncTreePanel extends LayoutContainer {
return Resources.getIconByFolderItemType(model.getGXTFolderItemType());
}
if (model.isRoot()) {
model.setName(AppControllerExplorer.myLoginFirstName+ROOT_SUFFIX);
return Resources.getCloudDriveIcon();
}
if(model.getStatus() == ConstantsExplorer.FOLDERNOTLOAD)
return Resources.getIconLoading2();

View File

@ -7,6 +7,7 @@ import org.gcube.portlets.user.workspace.client.AppControllerExplorer;
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
import org.gcube.portlets.user.workspace.client.model.FileGridModel;
import org.gcube.portlets.user.workspace.client.model.FileModel;
import org.gcube.portlets.user.workspace.client.model.FolderGridModel;
import org.gcube.portlets.user.workspace.client.model.InfoContactModel;
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
@ -103,7 +104,6 @@ public class DialogGetInfo extends Dialog {
textFieldSetValue(txtCategory,fileModel.getShortcutCategory());
add(txtCategory);
txtOwner = new TextField<String>();
txtOwner.setFieldLabel("Owner");
txtOwner.setReadOnly(true);
@ -247,7 +247,7 @@ public class DialogGetInfo extends Dialog {
}
private void loadSize(final String itemId){
GWT.log("Load size");
txtSize.mask();
AppControllerExplorer.rpcWorkspaceService.loadSizeByItemId(itemId, new AsyncCallback<Long>() {
@ -260,6 +260,7 @@ public class DialogGetInfo extends Dialog {
@Override
public void onSuccess(Long result) {
GWT.log("Loaded size="+result);
textFieldSetValue(txtSize,getFormattedSize(result));
txtSize.unmask();
}

View File

@ -1108,7 +1108,6 @@ 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,false);
fileGridModel.setType(GXTFolderItemTypeEnum.FOLDER.toString());
fileGridModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS);

View File

@ -1,6 +1,7 @@
package org.gcube.portlets.user.workspace.server;
import java.io.File;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
@ -41,6 +42,7 @@ import org.gcube.common.homelibrary.home.workspace.sharing.WorkspaceMessage;
import org.gcube.common.homelibrary.home.workspace.trash.WorkspaceTrashFolder;
import org.gcube.common.homelibrary.home.workspace.trash.WorkspaceTrashItem;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portal.custom.communitymanager.OrganizationsUtil;
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
import org.gcube.portlets.user.workspace.client.interfaces.GXTCategoryItemInterface;
import org.gcube.portlets.user.workspace.client.model.BulkCreatorModel;
@ -71,6 +73,7 @@ import org.gcube.portlets.user.workspace.shared.ExtendedWorkspaceACL;
import org.gcube.portlets.user.workspace.shared.SessionExpiredException;
import org.gcube.portlets.user.workspace.shared.TrashContent;
import org.gcube.portlets.user.workspace.shared.TrashOperationContent;
import org.gcube.portlets.user.workspace.shared.UserBean;
import org.gcube.portlets.user.workspace.shared.WorkspaceACL;
import org.gcube.portlets.user.workspace.shared.WorkspaceTrashOperation;
import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingEntryType;
@ -82,6 +85,9 @@ import org.gcube.vomanagement.usermanagement.impl.liferay.LiferayGroupManager;
import org.gcube.vomanagement.usermanagement.impl.liferay.LiferayUserManager;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.service.UserLocalServiceUtil;
/**
@ -2178,10 +2184,10 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
NotificationsProducer np = getNotificationProducer();
List<InfoContactModel> purgeMyContact = new ArrayList<InfoContactModel>(contacts.size()-1);
String myLogin = getMyLogin();
String myLogin = getMyLogin().getUsername();
workspaceLogger.trace("Preparing list of contacts to send un share notification");
for (InfoContactModel infoContactModel : contacts) {
if(infoContactModel.getLogin().compareToIgnoreCase(getMyLogin())==0)
if(infoContactModel.getLogin().compareToIgnoreCase(getMyLogin().getUsername())==0)
workspaceLogger.trace("skipping my login "+myLogin);
else
purgeMyContact.add(infoContactModel);
@ -2420,6 +2426,9 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
FolderItem folderItem = (FolderItem) wsItem;
size = new Long(folderItem.getLength());
} else if (wsItem instanceof WorkspaceFolder ){
WorkspaceFolder theFolder = (WorkspaceFolder) wsItem;
size = theFolder.getSize();
}
return size;
@ -2744,10 +2753,43 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
}
}
/**
*
* @return true if you're running into the portal, false if in development
*/
private boolean isWithinPortal() {
try {
UserLocalServiceUtil.getService();
return true;
}
catch (Exception ex) {
workspaceLogger.trace("Development Mode ON");
return false;
}
}
@Override
public String getMyLogin(){
public UserBean getMyLogin(){
ASLSession asl = WsUtil.getAslSession(this.getThreadLocalRequest().getSession());
return asl.getUsername();
String username = asl.getUsername();
String email = username+"@isti.cnr.it";
String firstName = "Testing";
String lastName = "User";
if (isWithinPortal() && username.compareTo(WsUtil.TEST_USER) != 0) {
com.liferay.portal.model.UserModel user = null;
try {
user = UserLocalServiceUtil.getUserByScreenName(OrganizationsUtil.getCompany().getCompanyId(), username);
firstName = user.getFirstName();
lastName = user.getLastName();
email = user.getEmailAddress();
} catch (PortalException | SystemException e) {
e.printStackTrace();
}
}
return new UserBean(username, firstName, lastName, email);
}
/**
@ -3179,5 +3221,41 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
throw new Exception(error);
}
}
@Override
public String getUserWorkspaceSize() throws Exception {
Workspace workspace = getWorkspace();
return formatFileSize(workspace.getRoot().getSize());
}
/**
* returns dynamically the formated size
* @param size
* @return
*/
private static String formatFileSize(long size) {
String formattedSize = null;
double b = size;
double k = size/1024.0;
double m = ((size/1024.0)/1024.0);
double g = (((size/1024.0)/1024.0)/1024.0);
double t = ((((size/1024.0)/1024.0)/1024.0)/1024.0);
DecimalFormat dec = new DecimalFormat("0.00");
if ( t>1 ) {
formattedSize = dec.format(t).concat(" TB");
} else if ( g>1 ) {
formattedSize = dec.format(g).concat(" GB");
} else if ( m>1 ) {
formattedSize = dec.format(m).concat(" MB");
} else if ( k>1 ) {
formattedSize = dec.format(k).concat(" KB");
} else {
formattedSize = dec.format(b).concat(" Bytes");
}
return formattedSize;
}
}

View File

@ -26,6 +26,8 @@ import org.gcube.portlets.user.workspace.server.shortener.UrlShortener;
import org.gcube.portlets.user.workspace.server.util.resource.PropertySpecialFolderReader;
import org.gcube.portlets.user.workspace.server.util.scope.ScopeUtilFilter;
import com.liferay.portal.service.UserLocalServiceUtil;
/**
*
@ -63,14 +65,29 @@ public class WsUtil {
// public static final String TEST_USER_FULL_NAME = "Francesco Mangiacrapa";
//UNCOMMENT THIS FOR RELEASE
public static final String TEST_USER = "test.user";
public static final String TEST_USER_FULL_NAME = "Test User";
public static String TEST_USER = "test.user";
public static String TEST_USER_FULL_NAME = "Test User";
protected static Logger logger = Logger.getLogger(WsUtil.class);
public static boolean withoutPortal = false;
/**
*
* @return true if you're running into the portal, false if in development
*/
private static boolean isWithinPortal() {
try {
UserLocalServiceUtil.getService();
return true;
}
catch (Exception ex) {
logger.trace("Development Mode ON");
return false;
}
}
public static ASLSession getAslSession(HttpSession httpSession)
{
String sessionID = httpSession.getId();
@ -85,7 +102,10 @@ public class WsUtil {
//UNCOMMENT THIS IN DEVELOP ENVIROMENT
// user = "francesco.mangiacrapa";
// user = "valentina.marioli";
if (! isWithinPortal()) {
TEST_USER = "luca.frosini";
TEST_USER_FULL_NAME = "Andrea Rossi";
}
logger.warn("WORKSPACE PORTLET STARTING IN TEST MODE - NO USER FOUND - PORTLETS STARTING WITH FOLLOWING SETTINGS:");
logger.warn("session id: "+sessionID);

View File

@ -0,0 +1,52 @@
package org.gcube.portlets.user.workspace.shared;
import java.io.Serializable;
@SuppressWarnings("serial")
public class UserBean implements Serializable {
private String username;
private String firstName;
private String lastName;
private String email;
public UserBean(String username, String firstName, String lastName,
String email) {
super();
this.username = username;
this.firstName = firstName;
this.lastName = lastName;
this.email = email;
}
public UserBean() {
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
}