fixed get owner on search item
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@85529 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
5c37e2b25e
commit
b0b885cfc4
|
@ -32,10 +32,10 @@ public class FileDetailsModel extends FileGridModel {
|
||||||
set(ConstantsExplorer.LASTMODIFIED, lastModified);
|
set(ConstantsExplorer.LASTMODIFIED, lastModified);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Date getLastModified() {
|
// private Date getLastModified() {
|
||||||
return (Date) get(ConstantsExplorer.LASTMODIFIED);
|
// return (Date) get(ConstantsExplorer.LASTMODIFIED);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public String getDescription(){
|
public String getDescription(){
|
||||||
return get(ConstantsExplorer.DESCRIPTION);
|
return get(ConstantsExplorer.DESCRIPTION);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,9 @@ import java.util.Date;
|
||||||
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
|
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
|
* @Nov 14, 2013
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class FileGridModel extends FileModel {
|
public class FileGridModel extends FileModel {
|
||||||
|
@ -18,18 +20,18 @@ public class FileGridModel extends FileModel {
|
||||||
protected FileGridModel(){
|
protected FileGridModel(){
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileGridModel(String identifier, String name, String path, Date creationDate, FileModel parent, long size, boolean isDirectory, boolean isShared) {
|
public FileGridModel(String identifier, String name, String path, Date lastUpdate, FileModel parent, long size, boolean isDirectory, boolean isShared) {
|
||||||
super(identifier, name, parent, isDirectory, isShared);
|
super(identifier, name, parent, isDirectory, isShared);
|
||||||
|
|
||||||
setCreationDate(creationDate);
|
setLastModification(lastUpdate);
|
||||||
setSize(size);
|
setSize(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public FileGridModel(String identifier, String name, Date creationDate, FileModel parent, long size, boolean isDirectory, boolean isShared) {
|
public FileGridModel(String identifier, String name, Date lastUpdate, FileModel parent, long size, boolean isDirectory, boolean isShared) {
|
||||||
super(identifier, name, parent, isDirectory, isShared);
|
super(identifier, name, parent, isDirectory, isShared);
|
||||||
|
|
||||||
setCreationDate(creationDate);
|
setLastModification(lastUpdate);
|
||||||
setSize(size);
|
setSize(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,15 +43,25 @@ public class FileGridModel extends FileModel {
|
||||||
return (Long) get(ConstantsExplorer.SIZE);
|
return (Long) get(ConstantsExplorer.SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setCreationDate(Date creationDate) {
|
// private void setCreationDate(Date creationDate) {
|
||||||
set(ConstantsExplorer.GRIDCOLUMNCREATIONDATE, creationDate);
|
// set(ConstantsExplorer.GRIDCOLUMNCREATIONDATE, creationDate);
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
|
private void setLastModification(Date lastUpdate) {
|
||||||
|
set(ConstantsExplorer.LASTMODIFIED, lastUpdate);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getCreationDate(){
|
public Date getLastModification() {
|
||||||
return (Date) get(ConstantsExplorer.GRIDCOLUMNCREATIONDATE);
|
return (Date) get(ConstantsExplorer.LASTMODIFIED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// public Date getCreationDate(){
|
||||||
|
// return (Date) get(ConstantsExplorer.GRIDCOLUMNCREATIONDATE);
|
||||||
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (obj != null && obj instanceof FileGridModel) {
|
if (obj != null && obj instanceof FileGridModel) {
|
||||||
|
|
|
@ -108,17 +108,25 @@ public class DialogGetInfo extends Dialog {
|
||||||
txtCreated = new TextField<String>();
|
txtCreated = new TextField<String>();
|
||||||
txtCreated.setFieldLabel("Created");
|
txtCreated.setFieldLabel("Created");
|
||||||
txtCreated.setReadOnly(true);
|
txtCreated.setReadOnly(true);
|
||||||
if(fileModel instanceof FileGridModel)
|
// if(fileModel instanceof FileGridModel)
|
||||||
textFieldSetValue(txtCreated, ((FileGridModel) fileModel).getCreationDate().toString());
|
// textFieldSetValue(txtCreated, ((FileGridModel) fileModel).getCreationDate().toString());
|
||||||
else
|
// else
|
||||||
loadCreationDate(fileModel.getIdentifier());
|
// loadCreationDate(fileModel.getIdentifier());
|
||||||
|
|
||||||
|
loadCreationDate(fileModel.getIdentifier());
|
||||||
|
|
||||||
add(txtCreated);
|
add(txtCreated);
|
||||||
|
|
||||||
|
|
||||||
txtLastMofication = new TextField<String>();
|
txtLastMofication = new TextField<String>();
|
||||||
txtLastMofication.setFieldLabel("Last Mofication");
|
txtLastMofication.setFieldLabel("Last Mofication");
|
||||||
txtLastMofication.setReadOnly(true);
|
txtLastMofication.setReadOnly(true);
|
||||||
loadLastModificationDate(fileModel.getIdentifier());
|
if(fileModel instanceof FileGridModel)
|
||||||
|
textFieldSetValue(txtLastMofication, ((FileGridModel) fileModel).getLastModification().toString());
|
||||||
|
else
|
||||||
|
loadLastModificationDate(fileModel.getIdentifier());
|
||||||
|
|
||||||
|
// loadLastModificationDate(fileModel.getIdentifier());
|
||||||
add(txtLastMofication);
|
add(txtLastMofication);
|
||||||
|
|
||||||
txtSize = new TextField<String>();
|
txtSize = new TextField<String>();
|
||||||
|
|
|
@ -982,11 +982,13 @@ public class GWTWorkspaceBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected List<FileGridModel> buildGXTListFileGridModelItemForSearch(List<SearchItem> listSearchItems, FileModel parentFileModel) throws InternalErrorException
|
protected List<FileGridModel> buildGXTListFileGridModelItemForSearch(List<SearchItem> listSearchItems) throws InternalErrorException
|
||||||
{
|
{
|
||||||
|
|
||||||
List<FileGridModel> listFileGridModel = new ArrayList<FileGridModel>();
|
List<FileGridModel> listFileGridModel = new ArrayList<FileGridModel>();
|
||||||
|
|
||||||
|
FileModel parentFileModel = null;
|
||||||
|
|
||||||
for (SearchItem item : listSearchItems)
|
for (SearchItem item : listSearchItems)
|
||||||
listFileGridModel.add(buildGXTFileGridModelItemForSearch(item,parentFileModel));
|
listFileGridModel.add(buildGXTFileGridModelItemForSearch(item,parentFileModel));
|
||||||
|
|
||||||
|
@ -1001,7 +1003,8 @@ public class GWTWorkspaceBuilder {
|
||||||
switch (item.getType()) {
|
switch (item.getType()) {
|
||||||
|
|
||||||
case FOLDER:
|
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.getCreationDate()), parentFileModel, -1, true, false);
|
||||||
|
fileGridModel = (FolderGridModel) new FolderGridModel(item.getId(), item.getName(), toDate(item.getLastModified()), parentFileModel, -1, true, false);
|
||||||
fileGridModel.setType(GXTFolderItemTypeEnum.FOLDER.toString());
|
fileGridModel.setType(GXTFolderItemTypeEnum.FOLDER.toString());
|
||||||
fileGridModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS);
|
fileGridModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS);
|
||||||
fileGridModel.setShareable(true);
|
fileGridModel.setShareable(true);
|
||||||
|
@ -1009,14 +1012,16 @@ public class GWTWorkspaceBuilder {
|
||||||
|
|
||||||
case FOLDER_ITEM:
|
case FOLDER_ITEM:
|
||||||
SearchFolderItem folderItem = (SearchFolderItem) item;
|
SearchFolderItem folderItem = (SearchFolderItem) item;
|
||||||
fileGridModel = new FileGridModel(item.getId(), item.getName(), toDate(item.getCreationDate()), parentFileModel, folderItem.getSize(), false, false);
|
// fileGridModel = new FileGridModel(item.getId(), item.getName(), toDate(item.getCreationDate()), parentFileModel, folderItem.getSize(), false, false);
|
||||||
|
fileGridModel = new FileGridModel(item.getId(), item.getName(), toDate(item.getLastModified()), parentFileModel, folderItem.getSize(), false, false);
|
||||||
// FolderItem folderItem = (FolderItem) item;
|
// FolderItem folderItem = (FolderItem) item;
|
||||||
fileGridModel = (FileGridModel) setFolderItemTypeForSearch(fileGridModel, folderItem);
|
fileGridModel = (FileGridModel) setFolderItemTypeForSearch(fileGridModel, folderItem);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SHARED_FOLDER:
|
case SHARED_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.getCreationDate()), parentFileModel, -1, true, false);
|
||||||
|
fileGridModel = (FolderGridModel) new FolderGridModel(item.getId(), item.getName(), toDate(item.getLastModified()), parentFileModel, -1, true, true);
|
||||||
fileGridModel.setType(GXTFolderItemTypeEnum.SHARED_FOLDER.toString());
|
fileGridModel.setType(GXTFolderItemTypeEnum.SHARED_FOLDER.toString());
|
||||||
fileGridModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS);
|
fileGridModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS);
|
||||||
fileGridModel.setShareable(true);
|
fileGridModel.setShareable(true);
|
||||||
|
@ -1032,11 +1037,29 @@ public class GWTWorkspaceBuilder {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO SETTING OWNER, ISSHARED IN SEARCH ITEM
|
//TODO ISSHARED IN SEARCH ITEM IN HL
|
||||||
|
|
||||||
//ACCOUNTING
|
//ACCOUNTING
|
||||||
// fileGridModel.setMarkAsRead(item.isMarkedAsRead());
|
// fileGridModel.setMarkAsRead(item.isMarkedAsRead());
|
||||||
|
|
||||||
|
|
||||||
|
//OWNER
|
||||||
|
if(fileGridModel.isShared()){ //IS READ FROM HL ONLY IF THE ITEM IS SHARED
|
||||||
|
String portalLogin = item.getOwner();
|
||||||
|
if(portalLogin!=null){
|
||||||
|
String fullName = portalLogin;
|
||||||
|
|
||||||
|
if(!WsUtil.withoutPortal) //INTO PORTAL
|
||||||
|
fullName = UserUtil.getUserFullName(portalLogin);
|
||||||
|
|
||||||
|
fileGridModel.setOwnerFullName(fullName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if(userLogged!=null)
|
||||||
|
fileGridModel.setOwnerFullName(userLogged.getName());
|
||||||
|
}
|
||||||
|
|
||||||
return fileGridModel;
|
return fileGridModel;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1067,7 +1090,9 @@ public class GWTWorkspaceBuilder {
|
||||||
switch (item.getType()) {
|
switch (item.getType()) {
|
||||||
|
|
||||||
case FOLDER:
|
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.getCreationTime()), parentFileModel, -1, true, false);
|
||||||
|
|
||||||
|
fileGridModel = (FolderGridModel) new FolderGridModel(item.getId(), item.getName(), toDate(item.getLastModificationTime()), parentFileModel, -1, true, false);
|
||||||
fileGridModel.setType(GXTFolderItemTypeEnum.FOLDER.toString());
|
fileGridModel.setType(GXTFolderItemTypeEnum.FOLDER.toString());
|
||||||
fileGridModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS);
|
fileGridModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS);
|
||||||
fileGridModel.setShareable(true);
|
fileGridModel.setShareable(true);
|
||||||
|
@ -1077,12 +1102,14 @@ public class GWTWorkspaceBuilder {
|
||||||
case FOLDER_ITEM:
|
case FOLDER_ITEM:
|
||||||
|
|
||||||
FolderItem folderItem = (FolderItem) item;
|
FolderItem folderItem = (FolderItem) item;
|
||||||
fileGridModel = new FileGridModel(item.getId(), item.getName(), toDate(item.getCreationTime()), parentFileModel, folderItem.getLength(), false, false);
|
// fileGridModel = new FileGridModel(item.getId(), item.getName(), toDate(item.getCreationTime()), parentFileModel, folderItem.getLength(), false, false);
|
||||||
|
fileGridModel = new FileGridModel(item.getId(), item.getName(), toDate(item.getLastModificationTime()), parentFileModel, folderItem.getLength(), false, false);
|
||||||
fileGridModel = (FileGridModel) setFolderItemType(fileGridModel, folderItem);
|
fileGridModel = (FileGridModel) setFolderItemType(fileGridModel, folderItem);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SHARED_FOLDER:
|
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.getCreationTime()), parentFileModel, -1, true, true);
|
||||||
|
fileGridModel = (FolderGridModel) new FolderGridModel(item.getId(), item.getName(), toDate(item.getLastModificationTime()), parentFileModel, -1, true, true);
|
||||||
fileGridModel.setType(GXTFolderItemTypeEnum.SHARED_FOLDER.toString());
|
fileGridModel.setType(GXTFolderItemTypeEnum.SHARED_FOLDER.toString());
|
||||||
fileGridModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS);
|
fileGridModel.setShortcutCategory(GXTCategoryItemInterface.SMF_DOCUMENTS);
|
||||||
fileGridModel.setShareable(true);
|
fileGridModel.setShareable(true);
|
||||||
|
|
|
@ -211,7 +211,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
|
|
||||||
workspaceLogger.trace("Call search HL..");
|
workspaceLogger.trace("Call search HL..");
|
||||||
|
|
||||||
listFileGridModels = builder.buildGXTListFileGridModelItemForSearch(listSearchItems, null);
|
listFileGridModels = builder.buildGXTListFileGridModelItemForSearch(listSearchItems);
|
||||||
workspaceLogger.trace("Search converted, completed...");
|
workspaceLogger.trace("Search converted, completed...");
|
||||||
|
|
||||||
return listFileGridModels;
|
return listFileGridModels;
|
||||||
|
@ -963,7 +963,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
|
|
||||||
workspaceLogger.trace(" children size "+wsSmartFolder.getSearchItems().size());
|
workspaceLogger.trace(" children size "+wsSmartFolder.getSearchItems().size());
|
||||||
|
|
||||||
return builder.buildGXTListFileGridModelItemForSearch((List<SearchItem>) wsSmartFolder.getSearchItems(), null);
|
return builder.buildGXTListFileGridModelItemForSearch((List<SearchItem>) wsSmartFolder.getSearchItems());
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
workspaceLogger.error("Error in get server smart folder by id", e);
|
workspaceLogger.error("Error in get server smart folder by id", e);
|
||||||
|
|
|
@ -74,10 +74,10 @@ public class WsUtil {
|
||||||
|
|
||||||
/*USE ANOTHER ACCOUNT (OTHERWHISE BY TEST_USER) FOR RUNNING
|
/*USE ANOTHER ACCOUNT (OTHERWHISE BY TEST_USER) FOR RUNNING
|
||||||
* COMMENT THIS IN DEVELOP ENVIROMENT (UNCOMMENT IN PRODUCTION)*/
|
* COMMENT THIS IN DEVELOP ENVIROMENT (UNCOMMENT IN PRODUCTION)*/
|
||||||
user=TEST_USER;
|
// user=TEST_USER;
|
||||||
|
|
||||||
//UNCOMMENT THIS IN DEVELOP ENVIROMENT
|
//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("WORKSPACE PORTLET STARTING IN TEST MODE - NO USER FOUND - PORTLETS STARTING WITH FOLLOWING SETTINGS:");
|
||||||
logger.warn("session id: "+sessionID);
|
logger.warn("session id: "+sessionID);
|
||||||
|
|
|
@ -0,0 +1,76 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.workspace;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import org.gcube.common.homelibrary.home.HomeLibrary;
|
||||||
|
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
||||||
|
import org.gcube.common.homelibrary.home.workspace.WorkspaceItemType;
|
||||||
|
import org.gcube.common.homelibrary.home.workspace.search.SearchFolder;
|
||||||
|
import org.gcube.common.homelibrary.home.workspace.search.SearchFolderItem;
|
||||||
|
import org.gcube.common.homelibrary.home.workspace.search.SearchItem;
|
||||||
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
|
import org.gcube.common.scope.impl.ScopeBean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
|
* @Jul 3, 2013
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SearchTextTest {
|
||||||
|
|
||||||
|
|
||||||
|
protected static Logger logger = Logger.getLogger(SearchTextTest.class);
|
||||||
|
private static String text = "test";
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
ScopeBean scope = new ScopeBean("/gcube/devsec");
|
||||||
|
ScopeProvider.instance.set(scope.toString());
|
||||||
|
|
||||||
|
Workspace ws = HomeLibrary
|
||||||
|
.getHomeManagerFactory()
|
||||||
|
.getHomeManager()
|
||||||
|
.getHome("francesco.mangiacrapa")
|
||||||
|
.getWorkspace();
|
||||||
|
//
|
||||||
|
|
||||||
|
List<SearchItem> listSearchItems = ws.searchByName(text);
|
||||||
|
|
||||||
|
System.out.println("Total item founds: "+listSearchItems.size());
|
||||||
|
|
||||||
|
int i=0;
|
||||||
|
for (SearchItem searchItem : listSearchItems) {
|
||||||
|
|
||||||
|
|
||||||
|
if(searchItem.getType().equals(WorkspaceItemType.FOLDER) || searchItem.getType().equals(WorkspaceItemType.SHARED_FOLDER)){
|
||||||
|
|
||||||
|
SearchFolder folder = (SearchFolder) searchItem;
|
||||||
|
|
||||||
|
System.out.println(++i+") folder name: "+folder.getName() + " type: "+folder.getType());
|
||||||
|
}else{
|
||||||
|
|
||||||
|
|
||||||
|
if(searchItem.getType().equals(WorkspaceItemType.FOLDER_ITEM)){
|
||||||
|
|
||||||
|
SearchFolderItem folderItem = (SearchFolderItem) searchItem;
|
||||||
|
|
||||||
|
System.out.println(++i+") folderItem id: "+folderItem.getId() +", name: "+folderItem.getName()+", type: "+folderItem.getType());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println("end");
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue