Started working on ckan data catalogue publish mechanism. Server side is almost complete
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@129324 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
43f7a97989
commit
1c4985b38a
20
pom.xml
20
pom.xml
|
@ -55,12 +55,12 @@
|
||||||
|
|
||||||
<!-- This dependency is needed to use GWT UI BInder without old Xerces
|
<!-- This dependency is needed to use GWT UI BInder without old Xerces
|
||||||
version of gCore complaining -->
|
version of gCore complaining -->
|
||||||
<!-- <dependency> -->
|
<!-- <dependency> -->
|
||||||
<!-- <groupId>xerces</groupId> -->
|
<!-- <groupId>xerces</groupId> -->
|
||||||
<!-- <artifactId>xercesImpl</artifactId> -->
|
<!-- <artifactId>xercesImpl</artifactId> -->
|
||||||
<!-- <version>2.9.1</version> -->
|
<!-- <version>2.9.1</version> -->
|
||||||
<!-- <scope>provided</scope> -->
|
<!-- <scope>provided</scope> -->
|
||||||
<!-- </dependency> -->
|
<!-- </dependency> -->
|
||||||
|
|
||||||
<!-- Google Web Toolkit (GWT) -->
|
<!-- Google Web Toolkit (GWT) -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -223,6 +223,14 @@
|
||||||
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Metadata publisher widget -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.portlets.widgets</groupId>
|
||||||
|
<artifactId>ckan-metadata-publisher-widget</artifactId>
|
||||||
|
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- JSON PARSER -->
|
<!-- JSON PARSER -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.json</groupId>
|
<groupId>org.json</groupId>
|
||||||
|
|
|
@ -694,4 +694,11 @@ public interface GWTWorkspaceService extends RemoteService{
|
||||||
|
|
||||||
FileModel getItemForFileTree(String itemId) throws Exception;
|
FileModel getItemForFileTree(String itemId) throws Exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows the user to public onto the data catalogue if he has at least
|
||||||
|
* the role editor somewhere.
|
||||||
|
* @return true if he can publish, false otherwise
|
||||||
|
*/
|
||||||
|
boolean hasUserRoleAdminOrEditor();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -248,7 +248,7 @@ public interface GWTWorkspaceServiceAsync {
|
||||||
*/
|
*/
|
||||||
void getAllContacts(AsyncCallback<List<InfoContactModel>> callback);
|
void getAllContacts(AsyncCallback<List<InfoContactModel>> callback);
|
||||||
|
|
||||||
// void sendTo(List<InfoContactModel> listContacts, List<FileModel> listAttachments, String subject, String text, AsyncCallback<Boolean> callback);
|
// void sendTo(List<InfoContactModel> listContacts, List<FileModel> listAttachments, String subject, String text, AsyncCallback<Boolean> callback);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send to by id.
|
* Send to by id.
|
||||||
|
@ -683,6 +683,11 @@ public interface GWTWorkspaceServiceAsync {
|
||||||
void setGcubeItemProperties(String itemId, Map<String, String> properties,
|
void setGcubeItemProperties(String itemId, Map<String, String> properties,
|
||||||
AsyncCallback<Void> callback);
|
AsyncCallback<Void> callback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows the user to public onto the data catalogue if he has at least
|
||||||
|
* the role editor somewhere.
|
||||||
|
* @return true if he can publish, false otherwise
|
||||||
|
*/
|
||||||
|
void hasUserRoleAdminOrEditor(AsyncCallback<Boolean> callback);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ import java.util.Map;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.gcube.application.framework.core.session.ASLSession;
|
import org.gcube.application.framework.core.session.ASLSession;
|
||||||
|
@ -40,6 +41,9 @@ 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.WorkspaceTrashFolder;
|
||||||
import org.gcube.common.homelibrary.home.workspace.trash.WorkspaceTrashItem;
|
import org.gcube.common.homelibrary.home.workspace.trash.WorkspaceTrashItem;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
|
import org.gcube.datacatalogue.ckanutillibrary.CKanUtilsImpl;
|
||||||
|
import org.gcube.datacatalogue.ckanutillibrary.models.CkanRolesIntoLiferay;
|
||||||
|
import org.gcube.datacatalogue.ckanutillibrary.models.RolesIntoOrganization;
|
||||||
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
|
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
|
||||||
import org.gcube.portlets.user.workspace.client.interfaces.GXTCategoryItemInterface;
|
import org.gcube.portlets.user.workspace.client.interfaces.GXTCategoryItemInterface;
|
||||||
import org.gcube.portlets.user.workspace.client.model.FileDetailsModel;
|
import org.gcube.portlets.user.workspace.client.model.FileDetailsModel;
|
||||||
|
@ -79,11 +83,15 @@ import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingEntryTyp
|
||||||
import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingField;
|
import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingField;
|
||||||
import org.gcube.portlets.user.workspaceapplicationhandler.ApplicationReaderFromGenericResource;
|
import org.gcube.portlets.user.workspaceapplicationhandler.ApplicationReaderFromGenericResource;
|
||||||
import org.gcube.vomanagement.usermanagement.GroupManager;
|
import org.gcube.vomanagement.usermanagement.GroupManager;
|
||||||
|
import org.gcube.vomanagement.usermanagement.RoleManager;
|
||||||
import org.gcube.vomanagement.usermanagement.UserManager;
|
import org.gcube.vomanagement.usermanagement.UserManager;
|
||||||
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
|
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
|
||||||
import org.gcube.vomanagement.usermanagement.exception.UserRetrievalFault;
|
import org.gcube.vomanagement.usermanagement.exception.UserRetrievalFault;
|
||||||
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
|
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
|
||||||
|
import org.gcube.vomanagement.usermanagement.impl.LiferayRoleManager;
|
||||||
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
|
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
|
||||||
|
import org.gcube.vomanagement.usermanagement.model.GCubeGroup;
|
||||||
|
import org.gcube.vomanagement.usermanagement.model.GCubeRole;
|
||||||
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||||
|
|
||||||
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
||||||
|
@ -104,6 +112,25 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
public static final String SELECTION_STATE_ATTRIBUTE = "WORKSPACE.SELECTION_STATE";
|
public static final String SELECTION_STATE_ATTRIBUTE = "WORKSPACE.SELECTION_STATE";
|
||||||
protected Logger workspaceLogger = Logger.getLogger(GWTWorkspaceServiceImpl.class);
|
protected Logger workspaceLogger = Logger.getLogger(GWTWorkspaceServiceImpl.class);
|
||||||
|
|
||||||
|
// for the data catalogue
|
||||||
|
public static final String CKAN_TOKEN_KEY = "ckanToken";
|
||||||
|
public static final String CKAN_ROLE = "ckanRole"; // editor, admin, member
|
||||||
|
|
||||||
|
// ckan utils methods
|
||||||
|
private CKanUtilsImpl instance;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(){
|
||||||
|
|
||||||
|
// retrieve ckan information
|
||||||
|
try{
|
||||||
|
String currentScope = ScopeProvider.instance.get();
|
||||||
|
instance = new CKanUtilsImpl(currentScope);
|
||||||
|
}catch(Exception e){
|
||||||
|
workspaceLogger.error("Unable to retrieve ckan information");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the GWT workspace builder.
|
* Gets the GWT workspace builder.
|
||||||
*
|
*
|
||||||
|
@ -224,7 +251,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
return gwtroot;
|
return gwtroot;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
workspaceLogger.error("Error in server during root retrieving", e);
|
workspaceLogger.error("Error in server during root retrieving", e);
|
||||||
// workspaceLogger.trace("Error in server During root retrieving " + e);
|
// workspaceLogger.trace("Error in server During root retrieving " + e);
|
||||||
|
|
||||||
//GWT can't serialize all exceptions
|
//GWT can't serialize all exceptions
|
||||||
throw new Exception("Error during workspace loading, please contact the support. Exception:" +e);
|
throw new Exception("Error during workspace loading, please contact the support. Exception:" +e);
|
||||||
|
@ -245,11 +272,11 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
Workspace workspace = getWorkspace();
|
Workspace workspace = getWorkspace();
|
||||||
workspaceLogger.trace("on server getRoot for scope: " + scopeId);
|
workspaceLogger.trace("on server getRoot for scope: " + scopeId);
|
||||||
|
|
||||||
// GCUBEScope gcubeScope = null;
|
// GCUBEScope gcubeScope = null;
|
||||||
//
|
//
|
||||||
// if(scopeId.compareTo(ScopeUtilFilter.IDALLSCOPE)!=0){
|
// if(scopeId.compareTo(ScopeUtilFilter.IDALLSCOPE)!=0){
|
||||||
// gcubeScope = GCUBEScope.getScope(scopeId);
|
// gcubeScope = GCUBEScope.getScope(scopeId);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
WorkspaceFolder root = workspace.getRoot();
|
WorkspaceFolder root = workspace.getRoot();
|
||||||
|
|
||||||
|
@ -298,7 +325,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
return listFileGridModels;
|
return listFileGridModels;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
workspaceLogger.error("Error in server During search retrieving", e);
|
workspaceLogger.error("Error in server During search retrieving", e);
|
||||||
// workspaceLogger.trace("Error in server During search retrieving " + e);
|
// workspaceLogger.trace("Error in server During search retrieving " + e);
|
||||||
|
|
||||||
//GWT can't serialize all exceptions
|
//GWT can't serialize all exceptions
|
||||||
throw new Exception("Error during searching, please contact the support.");
|
throw new Exception("Error during searching, please contact the support.");
|
||||||
|
@ -354,7 +381,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
workspaceLogger.error("Error in server During item retrieving", e);
|
workspaceLogger.error("Error in server During item retrieving", e);
|
||||||
// workspaceLogger.trace("Error in server During item retrieving " + e);
|
// workspaceLogger.trace("Error in server During item retrieving " + e);
|
||||||
String error = ConstantsExplorer.SERVER_ERROR + RETRIEVING_ITEM_EITHER_ITEM_DOESN_T_EXIST;
|
String error = ConstantsExplorer.SERVER_ERROR + RETRIEVING_ITEM_EITHER_ITEM_DOESN_T_EXIST;
|
||||||
//GWT can't serialize all exceptions
|
//GWT can't serialize all exceptions
|
||||||
throw new Exception(error);
|
throw new Exception(error);
|
||||||
|
@ -409,7 +436,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
workspaceLogger.info("Folder is root, loading special folders..");
|
workspaceLogger.info("Folder is root, loading special folders..");
|
||||||
WorkspaceFolder specialFolder = workspace.getMySpecialFolders();
|
WorkspaceFolder specialFolder = workspace.getMySpecialFolders();
|
||||||
FileGridModel specialFolderModel = builder.buildGXTFileGridModelItem(specialFolder, folder);
|
FileGridModel specialFolderModel = builder.buildGXTFileGridModelItem(specialFolder, folder);
|
||||||
// specialFolderModel.setShortcutCategory(GXTCategoryItemInterface.SMF_VRE_FOLDERS);
|
// specialFolderModel.setShortcutCategory(GXTCategoryItemInterface.SMF_VRE_FOLDERS);
|
||||||
specialFolderModel.setSpecialFolder(true);
|
specialFolderModel.setSpecialFolder(true);
|
||||||
String newName = getNameForSpecialFolder();
|
String newName = getNameForSpecialFolder();
|
||||||
|
|
||||||
|
@ -739,7 +766,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
workspaceLogger.warn("Notifies added item: "+destinationItem+ "to share doesn't sent because "+destinationSharedFolder+" is not istance of WorkspaceSharedFolder");
|
workspaceLogger.warn("Notifies added item: "+destinationItem+ "to share doesn't sent because "+destinationSharedFolder+" is not istance of WorkspaceSharedFolder");
|
||||||
// np.notifyAddedItemToSharing(listContacts, (WorkspaceFolder) folderDestinationItem);
|
// np.notifyAddedItemToSharing(listContacts, (WorkspaceFolder) folderDestinationItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -776,7 +803,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
|
|
||||||
workspaceLogger.trace("checkNotifyMoveItemFromShare source item: "+sourceItem.getName()+" sourceSharedId: "+sourceSharedId + " folder destination: "+folderDestinationItem.getName() +" sourceItemIsShared: "+sourceItemIsShared);
|
workspaceLogger.trace("checkNotifyMoveItemFromShare source item: "+sourceItem.getName()+" sourceSharedId: "+sourceSharedId + " folder destination: "+folderDestinationItem.getName() +" sourceItemIsShared: "+sourceItemIsShared);
|
||||||
|
|
||||||
// System.out.println("shareChangeCondition remove item: "+ shareChangeCondition);
|
// System.out.println("shareChangeCondition remove item: "+ shareChangeCondition);
|
||||||
|
|
||||||
workspaceLogger.trace("shareChangeCondition remove item: "+ shareChangeCondition);
|
workspaceLogger.trace("shareChangeCondition remove item: "+ shareChangeCondition);
|
||||||
|
|
||||||
|
@ -1074,7 +1101,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
listWorkspaceItems = workspace.getFolderItems(FolderItemType.IMAGE_DOCUMENT, FolderItemType.EXTERNAL_IMAGE);
|
listWorkspaceItems = workspace.getFolderItems(FolderItemType.IMAGE_DOCUMENT, FolderItemType.EXTERNAL_IMAGE);
|
||||||
//Category BIODIVERSITY
|
//Category BIODIVERSITY
|
||||||
}else if(category.equals(GXTCategoryItemInterface.SMF_BIODIVERSITY.toString())){
|
}else if(category.equals(GXTCategoryItemInterface.SMF_BIODIVERSITY.toString())){
|
||||||
// listWorkspaceItems = workspace.getFolderItems(FolderItemType.AQUAMAPS_ITEM);
|
// listWorkspaceItems = workspace.getFolderItems(FolderItemType.AQUAMAPS_ITEM);
|
||||||
//Category DOCUMENTS
|
//Category DOCUMENTS
|
||||||
}else if(category.equals(GXTCategoryItemInterface.SMF_DOCUMENTS.toString())){
|
}else if(category.equals(GXTCategoryItemInterface.SMF_DOCUMENTS.toString())){
|
||||||
|
|
||||||
|
@ -1089,7 +1116,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
|
|
||||||
//Category LINKS
|
//Category LINKS
|
||||||
}else if(category.equals(GXTCategoryItemInterface.SMF_LINKS.toString())){
|
}else if(category.equals(GXTCategoryItemInterface.SMF_LINKS.toString())){
|
||||||
// listWorkspaceItems = workspace.getFolderItems(FolderItemType.EXTERNAL_URL, FolderItemType.URL_DOCUMENT, FolderItemType.EXTERNAL_RESOURCE_LINK);
|
// listWorkspaceItems = workspace.getFolderItems(FolderItemType.EXTERNAL_URL, FolderItemType.URL_DOCUMENT, FolderItemType.EXTERNAL_RESOURCE_LINK);
|
||||||
//Category REPORTS
|
//Category REPORTS
|
||||||
}else if(category.equals(GXTCategoryItemInterface.SMF_REPORTS.toString())){
|
}else if(category.equals(GXTCategoryItemInterface.SMF_REPORTS.toString())){
|
||||||
listWorkspaceItems = workspace.getFolderItems(FolderItemType.REPORT_TEMPLATE, FolderItemType.REPORT);
|
listWorkspaceItems = workspace.getFolderItems(FolderItemType.REPORT_TEMPLATE, FolderItemType.REPORT);
|
||||||
|
@ -1163,7 +1190,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
workspaceLogger.error("Error in server create smart folder by name: ", e);
|
workspaceLogger.error("Error in server create smart folder by name: ", e);
|
||||||
// workspaceLogger.trace("Error in server create smart folder by id " + e);
|
// workspaceLogger.trace("Error in server create smart folder by id " + e);
|
||||||
//GWT can't serialize all exceptions
|
//GWT can't serialize all exceptions
|
||||||
throw new Exception(e.getMessage());
|
throw new Exception(e.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -1316,7 +1343,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
workspaceLogger.error("Error in server get image by id ", e);
|
workspaceLogger.error("Error in server get image by id ", e);
|
||||||
// workspaceLogger.trace("Error in server get image by id " + e);
|
// workspaceLogger.trace("Error in server get image by id " + e);
|
||||||
//GWT can't serialize all exceptions
|
//GWT can't serialize all exceptions
|
||||||
throw new Exception(e.getMessage());
|
throw new Exception(e.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -1337,12 +1364,12 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
workspaceLogger.trace("create url in parent id: "+parentFileModel.getIdentifier());
|
workspaceLogger.trace("create url in parent id: "+parentFileModel.getIdentifier());
|
||||||
|
|
||||||
//DEBUG
|
//DEBUG
|
||||||
// workspaceLogger.trace("Name " + name);
|
// workspaceLogger.trace("Name " + name);
|
||||||
// workspaceLogger.trace("description " + description);
|
// workspaceLogger.trace("description " + description);
|
||||||
// workspaceLogger.trace("url " + url);
|
// workspaceLogger.trace("url " + url);
|
||||||
// workspaceLogger.trace("parentFileModel " + parentFileModel.getIdentifier() + " " + parentFileModel.getName());
|
// workspaceLogger.trace("parentFileModel " + parentFileModel.getIdentifier() + " " + parentFileModel.getName());
|
||||||
// if(description == null)
|
// if(description == null)
|
||||||
// description = "";
|
// description = "";
|
||||||
|
|
||||||
ExternalUrl ext = workspace.createExternalUrl(name, description, url, parentFileModel.getIdentifier());
|
ExternalUrl ext = workspace.createExternalUrl(name, description, url, parentFileModel.getIdentifier());
|
||||||
WorkspaceItem parent = workspace.getItem(parentFileModel.getIdentifier()); //get item from workspace
|
WorkspaceItem parent = workspace.getItem(parentFileModel.getIdentifier()); //get item from workspace
|
||||||
|
@ -1352,7 +1379,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
workspaceLogger.error("Error in server create url in parent id ", e);
|
workspaceLogger.error("Error in server create url in parent id ", e);
|
||||||
// workspaceLogger.trace("Error in server create url in parent id " + e);
|
// workspaceLogger.trace("Error in server create url in parent id " + e);
|
||||||
//GWT can't serialize all exceptions
|
//GWT can't serialize all exceptions
|
||||||
throw new Exception(e.getMessage());
|
throw new Exception(e.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -1449,7 +1476,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
workspaceLogger.error("Error in server get all scope ", e);
|
workspaceLogger.error("Error in server get all scope ", e);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
// workspaceLogger.trace("Error in server get all scope " + e.getMessage());
|
// workspaceLogger.trace("Error in server get all scope " + e.getMessage());
|
||||||
//GWT can't serialize all exceptions
|
//GWT can't serialize all exceptions
|
||||||
throw new Exception(e.getMessage());
|
throw new Exception(e.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -1479,13 +1506,13 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
listContactsModel.add(contact);
|
listContactsModel.add(contact);
|
||||||
|
|
||||||
}
|
}
|
||||||
// //TEST USERS
|
// //TEST USERS
|
||||||
// listContactsModel.add(new InfoContactModel("antonio.gioia", "antonio.gioia", "Antonio Gioia",false));
|
// listContactsModel.add(new InfoContactModel("antonio.gioia", "antonio.gioia", "Antonio Gioia",false));
|
||||||
// listContactsModel.add(new InfoContactModel("fabio.sinibaldi", "fabio.sinibaldi", "Fabio Sinibaldi",false));
|
// listContactsModel.add(new InfoContactModel("fabio.sinibaldi", "fabio.sinibaldi", "Fabio Sinibaldi",false));
|
||||||
// listContactsModel.add(new InfoContactModel("pasquale.pagano", "pasquale.pagano", "Pasquale Pagano",false));
|
// listContactsModel.add(new InfoContactModel("pasquale.pagano", "pasquale.pagano", "Pasquale Pagano",false));
|
||||||
// listContactsModel.add(new InfoContactModel(WsUtil.TEST_USER, WsUtil.TEST_USER, WsUtil.TEST_USER_FULL_NAME,false));
|
// listContactsModel.add(new InfoContactModel(WsUtil.TEST_USER, WsUtil.TEST_USER, WsUtil.TEST_USER_FULL_NAME,false));
|
||||||
// listContactsModel.add(new InfoContactModel("francesco.mangiacrapa", "francesco.mangiacrapa", "Francesco Mangiacrapa",false));
|
// listContactsModel.add(new InfoContactModel("francesco.mangiacrapa", "francesco.mangiacrapa", "Francesco Mangiacrapa",false));
|
||||||
// listContactsModel.add(new InfoContactModel("massimiliano.assante", "massimiliano.assante", "Massimiliano Assante",false));
|
// listContactsModel.add(new InfoContactModel("massimiliano.assante", "massimiliano.assante", "Massimiliano Assante",false));
|
||||||
|
|
||||||
workspaceLogger.trace("Home Library User Manager getting list Gcube Group");
|
workspaceLogger.trace("Home Library User Manager getting list Gcube Group");
|
||||||
listContactsModel.addAll(builder.buildGXTListContactsModelFromGcubeGroup(hlUserManager.getGroups()));
|
listContactsModel.addAll(builder.buildGXTListContactsModelFromGcubeGroup(hlUserManager.getGroups()));
|
||||||
|
@ -1510,7 +1537,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
workspaceLogger.error("Error in server get all contacts ", e);
|
workspaceLogger.error("Error in server get all contacts ", e);
|
||||||
// return new ArrayList<InfoContactModel>();
|
// return new ArrayList<InfoContactModel>();
|
||||||
throw new Exception(e.getMessage());
|
throw new Exception(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1524,9 +1551,9 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Workspace workspace = getWorkspace();
|
Workspace workspace = getWorkspace();
|
||||||
// workspaceLogger.trace("######### SEND TO: ");
|
// workspaceLogger.trace("######### SEND TO: ");
|
||||||
// workspaceLogger.trace("subject " + subject);
|
// workspaceLogger.trace("subject " + subject);
|
||||||
// workspaceLogger.trace("body " + body);
|
// workspaceLogger.trace("body " + body);
|
||||||
|
|
||||||
//DEBUG
|
//DEBUG
|
||||||
for(String contactId : listContactsId)
|
for(String contactId : listContactsId)
|
||||||
|
@ -1670,7 +1697,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
workspaceLogger.error("Error in getNewFolderBulkCreator ", e);
|
workspaceLogger.error("Error in getNewFolderBulkCreator ", e);
|
||||||
// workspaceLogger.trace("Error in getNewFolderBulkCreator " + e.getMessage());
|
// workspaceLogger.trace("Error in getNewFolderBulkCreator " + e.getMessage());
|
||||||
throw new Exception(e.getMessage());
|
throw new Exception(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1746,7 +1773,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
if(!sourceFolderIsShared) //if source folder is not already shared
|
if(!sourceFolderIsShared) //if source folder is not already shared
|
||||||
np.notifyFolderSharing(listContacts, sharedFolder);
|
np.notifyFolderSharing(listContacts, sharedFolder);
|
||||||
else{
|
else{
|
||||||
// printContacts(listContacts);
|
// printContacts(listContacts);
|
||||||
np.notifyUpdatedUsersToSharing(listSharedContact, listContacts, sharedFolder);
|
np.notifyUpdatedUsersToSharing(listSharedContact, listContacts, sharedFolder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1948,7 +1975,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
FolderModel root = builder.buildGXTFolderModelItemHandleSpecialFolder(wsFolder, null, nameSpecialFolder);
|
FolderModel root = builder.buildGXTFolderModelItemHandleSpecialFolder(wsFolder, null, nameSpecialFolder);
|
||||||
List<FileModel> listParents = new ArrayList<FileModel>(1);
|
List<FileModel> listParents = new ArrayList<FileModel>(1);
|
||||||
listParents.add(root);
|
listParents.add(root);
|
||||||
// workspaceLogger.trace("returning: "+listParents.toString());
|
// workspaceLogger.trace("returning: "+listParents.toString());
|
||||||
return listParents;
|
return listParents;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
@ -1969,7 +1996,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
listParents.add(root);
|
listParents.add(root);
|
||||||
if(parent!=null)
|
if(parent!=null)
|
||||||
listParents.add(parent);
|
listParents.add(parent);
|
||||||
// workspaceLogger.trace("returning: "+listParents.toString());
|
// workspaceLogger.trace("returning: "+listParents.toString());
|
||||||
return listParents;
|
return listParents;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -2002,8 +2029,8 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
FileModel fileModel = arrayParents[i+1];
|
FileModel fileModel = arrayParents[i+1];
|
||||||
fileModel.setParentFileModel(parent);
|
fileModel.setParentFileModel(parent);
|
||||||
}
|
}
|
||||||
// workspaceLogger.trace("list parents returning size: "+arrayParents.length);
|
// workspaceLogger.trace("list parents returning size: "+arrayParents.length);
|
||||||
// return new ArrayList<FileModel>(Arrays.asList(arrayParents));
|
// return new ArrayList<FileModel>(Arrays.asList(arrayParents));
|
||||||
workspaceLogger.trace("list parents returning size: "+arrayParents.length);
|
workspaceLogger.trace("list parents returning size: "+arrayParents.length);
|
||||||
if(arrayParents[0]==null){ //EXIT BY BREAK IN CASE OF SPECIAL FOLDER
|
if(arrayParents[0]==null){ //EXIT BY BREAK IN CASE OF SPECIAL FOLDER
|
||||||
List<FileModel> breadcrumbs = new ArrayList<FileModel>(arrayParents.length-1);
|
List<FileModel> breadcrumbs = new ArrayList<FileModel>(arrayParents.length-1);
|
||||||
|
@ -2409,10 +2436,10 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
|
|
||||||
garbage.put(itemId, new GarbageItem(sourceItemIsShared, itemName, itemId, sourceFolderSharedId));
|
garbage.put(itemId, new GarbageItem(sourceItemIsShared, itemName, itemId, sourceFolderSharedId));
|
||||||
|
|
||||||
// workspace.removeItem(itemId);
|
// workspace.removeItem(itemId);
|
||||||
// //IF SOURCE SHARED FOLDER IS NOT NULL
|
// //IF SOURCE SHARED FOLDER IS NOT NULL
|
||||||
// if(sourceFolderSharedId!=null)
|
// if(sourceFolderSharedId!=null)
|
||||||
// NotificationsUtil.checkSendNotifyRemoveItemToShare(this.getThreadLocalRequest().getSession(), sourceItemIsShared, itemName, itemId, sourceFolderSharedId);
|
// NotificationsUtil.checkSendNotifyRemoveItemToShare(this.getThreadLocalRequest().getSession(), sourceItemIsShared, itemName, itemId, sourceFolderSharedId);
|
||||||
}
|
}
|
||||||
|
|
||||||
//ITEM ID - ERROR
|
//ITEM ID - ERROR
|
||||||
|
@ -2483,14 +2510,14 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
//IS ROOT SHARED FOLDER
|
//IS ROOT SHARED FOLDER
|
||||||
ite = (WorkspaceSharedFolder) wsItem;
|
ite = (WorkspaceSharedFolder) wsItem;
|
||||||
workspaceLogger.trace("Folder " +ite.getName()+" is a "+WorkspaceSharedFolder.class.getName());
|
workspaceLogger.trace("Folder " +ite.getName()+" is a "+WorkspaceSharedFolder.class.getName());
|
||||||
// ite = (WorkspaceSharedFolder) workspace.getItemByPath(wsItem.getPath());
|
// ite = (WorkspaceSharedFolder) workspace.getItemByPath(wsItem.getPath());
|
||||||
}else{
|
}else{
|
||||||
// IS SUB FOLDER OF THE SHARING
|
// IS SUB FOLDER OF THE SHARING
|
||||||
ite = (WorkspaceFolder) wsItem;
|
ite = (WorkspaceFolder) wsItem;
|
||||||
workspaceLogger.trace("Folder " +ite.getName()+" is a "+WorkspaceFolder.class.getName());
|
workspaceLogger.trace("Folder " +ite.getName()+" is a "+WorkspaceFolder.class.getName());
|
||||||
// ite = (WorkspaceSharedFolder) workspace.getItem(wsItem.getIdSharedFolder());
|
// ite = (WorkspaceSharedFolder) workspace.getItem(wsItem.getIdSharedFolder());
|
||||||
}
|
}
|
||||||
// validateACLToUser(ite, listLogins, aclType);
|
// validateACLToUser(ite, listLogins, aclType);
|
||||||
ite.setACL(listLogins, ACLType.valueOf(aclType));
|
ite.setACL(listLogins, ACLType.valueOf(aclType));
|
||||||
}else
|
}else
|
||||||
throw new Exception("Source item is not shared or shared folder");
|
throw new Exception("Source item is not shared or shared folder");
|
||||||
|
@ -2810,7 +2837,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
workspaceLogger.trace("Get SharedFolderForId: folder id "+folderId+" is shared");
|
workspaceLogger.trace("Get SharedFolderForId: folder id "+folderId+" is shared");
|
||||||
|
|
||||||
//TODO REMOVE wsItem.getIdSharedFolder()
|
//TODO REMOVE wsItem.getIdSharedFolder()
|
||||||
// WorkspaceSharedFolder wsFolder = (WorkspaceSharedFolder) workspace.getItem(wsItem.getIdSharedFolder());
|
// WorkspaceSharedFolder wsFolder = (WorkspaceSharedFolder) workspace.getItem(wsItem.getIdSharedFolder());
|
||||||
|
|
||||||
WorkspaceFolder wsFolder = (WorkspaceFolder) wsItem;
|
WorkspaceFolder wsFolder = (WorkspaceFolder) wsItem;
|
||||||
if(wsFolder!=null){
|
if(wsFolder!=null){
|
||||||
|
@ -3045,8 +3072,8 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// trash = workspace.getTrash();
|
// trash = workspace.getTrash();
|
||||||
// result.setTrashContent(builder.buildGXTListTrashContent(trash));
|
// result.setTrashContent(builder.buildGXTListTrashContent(trash));
|
||||||
|
|
||||||
if(!listContentError.isEmpty()){
|
if(!listContentError.isEmpty()){
|
||||||
result.setListErrors(listContentError);
|
result.setListErrors(listContentError);
|
||||||
|
@ -3259,7 +3286,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
workspaceLogger.info("Getting workspace size..");
|
workspaceLogger.info("Getting workspace size..");
|
||||||
Workspace workspace = getWorkspace();
|
Workspace workspace = getWorkspace();
|
||||||
long size = workspace.getDiskUsage();
|
long size = workspace.getDiskUsage();
|
||||||
// workspaceLogger.info("Root size is: "+size +" formatting..");
|
// workspaceLogger.info("Root size is: "+size +" formatting..");
|
||||||
String formatSize = GWTWorkspaceBuilder.formatFileSize(size);
|
String formatSize = GWTWorkspaceBuilder.formatFileSize(size);
|
||||||
workspaceLogger.info("returning workspace size: "+formatSize);
|
workspaceLogger.info("returning workspace size: "+formatSize);
|
||||||
return formatSize;
|
return formatSize;
|
||||||
|
@ -3388,4 +3415,132 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
throw new Exception(error);
|
throw new Exception(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasUserRoleAdminOrEditor() {
|
||||||
|
ASLSession asl = WsUtil.getAslSession(this.getThreadLocalRequest().getSession());
|
||||||
|
String username = asl.getUsername();
|
||||||
|
|
||||||
|
// check if this information was already into the ASL Session
|
||||||
|
String role = (String)asl.getAttribute(CKAN_ROLE);
|
||||||
|
|
||||||
|
if(role != null)
|
||||||
|
switch(role){
|
||||||
|
case "editor" :
|
||||||
|
case "admin" : return true;
|
||||||
|
default: return false; // member
|
||||||
|
}
|
||||||
|
|
||||||
|
try{
|
||||||
|
|
||||||
|
if(!isWithinPortal()){
|
||||||
|
workspaceLogger.warn("OUT FROM PORTAL DETECTED RETURNING TRUE");
|
||||||
|
asl.setAttribute(CKAN_ROLE, "editor");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// first of all, check if the user is a sysadmin in the catalog (in this case he can do everything)
|
||||||
|
boolean isSysAdmin = instance.isSysAdmin(username, getUserCKanTokenFromSession());
|
||||||
|
|
||||||
|
if(isSysAdmin){
|
||||||
|
|
||||||
|
workspaceLogger.debug("The user is a sysadmin of the catalog -> he can edit/add");
|
||||||
|
asl.setAttribute(CKAN_ROLE, "admin");
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
|
// retrieve the liferay's roles for the user
|
||||||
|
UserManager userManager = new LiferayUserManager();
|
||||||
|
RoleManager roleManager = new LiferayRoleManager();
|
||||||
|
GroupManager groupManager = new LiferayGroupManager();
|
||||||
|
|
||||||
|
// we need to iterate over vres
|
||||||
|
List<GCubeGroup> groups = groupManager.listGroups();
|
||||||
|
|
||||||
|
for (GCubeGroup gCubeGroup : groups) {
|
||||||
|
|
||||||
|
String groupName = gCubeGroup.getGroupName();
|
||||||
|
|
||||||
|
// skip if it is not a vre
|
||||||
|
if(!groupManager.isVRE(gCubeGroup.getGroupId()))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
List<GCubeRole> roles = roleManager.listRolesByUserAndGroup(userManager.getUserId(username), groupManager.getGroupId(groupName));
|
||||||
|
|
||||||
|
// the default one
|
||||||
|
RolesIntoOrganization correspondentRoleToCheck = RolesIntoOrganization.MEMBER;
|
||||||
|
String roleToSetInSession = null;
|
||||||
|
|
||||||
|
// NOTE: it is supposed that there is just one role for this person correspondent to the one in the catalog
|
||||||
|
for (GCubeRole gCubeRole : roles) {
|
||||||
|
|
||||||
|
workspaceLogger.debug("User " + username + " has role " + gCubeRole.getRoleName() + " in " + groupName);
|
||||||
|
if(gCubeRole.getRoleName().equalsIgnoreCase(CkanRolesIntoLiferay.CATALOG_ADMIN.toString())){
|
||||||
|
correspondentRoleToCheck = RolesIntoOrganization.ADMIN;
|
||||||
|
roleToSetInSession = "admin";
|
||||||
|
break;
|
||||||
|
}else if(gCubeRole.getRoleName().equalsIgnoreCase(CkanRolesIntoLiferay.CATALOG_EDITOR.toString())){
|
||||||
|
correspondentRoleToCheck = RolesIntoOrganization.EDITOR;
|
||||||
|
roleToSetInSession = "editor";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if the role is member, keep continuing
|
||||||
|
if(correspondentRoleToCheck.equals(RolesIntoOrganization.MEMBER))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// with this invocation, we check if the role is present in ckan and if it is not it will be added
|
||||||
|
boolean res = instance.checkRole(username, groupName, correspondentRoleToCheck);
|
||||||
|
|
||||||
|
// set the role in the asl session
|
||||||
|
if(res){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch(Exception e){
|
||||||
|
workspaceLogger.error("Unable to retrieve the role information for this user. Returning FALSE", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
workspaceLogger.debug("Unable to check the role into ckan organization, returning FALSE");
|
||||||
|
|
||||||
|
// set the role member into the asl
|
||||||
|
asl.setAttribute(CKAN_ROLE, "member");
|
||||||
|
|
||||||
|
// return false
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get current user's token.
|
||||||
|
*
|
||||||
|
* @return String the ckan user's token
|
||||||
|
*/
|
||||||
|
private String getUserCKanTokenFromSession(){
|
||||||
|
|
||||||
|
HttpSession httpSession = this.getThreadLocalRequest().getSession();
|
||||||
|
ASLSession session = WsUtil.getAslSession(httpSession);
|
||||||
|
String username = session.getUsername();
|
||||||
|
workspaceLogger.debug("User in session is " + username);
|
||||||
|
|
||||||
|
String token = null;
|
||||||
|
if(this.getThreadLocalRequest().getSession().getAttribute(CKAN_TOKEN_KEY) != null)
|
||||||
|
token = (String)this.getThreadLocalRequest().getSession().getAttribute(CKAN_TOKEN_KEY);
|
||||||
|
else{
|
||||||
|
|
||||||
|
token = instance.getApiKeyFromUsername(username);
|
||||||
|
this.getThreadLocalRequest().getSession().setAttribute(CKAN_TOKEN_KEY, token);
|
||||||
|
workspaceLogger.debug("Ckan token has been set for user " + username);
|
||||||
|
}
|
||||||
|
|
||||||
|
workspaceLogger.debug("Found ckan token " + token + " for user " + username);
|
||||||
|
return token;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue