selectionModelLeft;
private final ResourceElementBean initialBean;
- private final static HTML aboutHeader = new HTML("Resource Manager");
- private final static HTML aboutBody = new HTML("Move the files you want to attach to the product on the right panel below."
- + " Please consider that any complex hierarchy structure you may have will be flatten.
");
+ // private final static HTML aboutHeader = new HTML("Resource Manager");
+ // private final static HTML aboutBody = new HTML("Move the files you want to attach to the product on the right panel below."
+ // + " Please consider that any complex hierarchy structure you may have will be flatten.
");
- // private static final int PATH_THRESHOLD = 1; // TODO
+ // private static final short PATH_THRESHOLD = 1; // TODO
private static TwinColumnSelectionMainPanelUiBinder uiBinder = GWT
.create(TwinColumnSelectionMainPanelUiBinder.class);
@@ -107,20 +104,19 @@ public class TwinColumnSelectionMainPanel extends Composite{
this.initialBean = initialBean;
- this.buttonsPanel.getElement().getStyle().setMarginTop(50, Unit.PCT);
+ buttonsPanel.getElement().getStyle().setMarginTop(50, Unit.PCT);
allToRightButton.getElement().getStyle().setMarginBottom(4, Unit.PX);
toRightButton.getElement().getStyle().setMarginBottom(4, Unit.PX);
toLeftButton.getElement().getStyle().setMarginBottom(4, Unit.PX);
allToLeftButton.getElement().getStyle().setMarginBottom(4, Unit.PX);
buttonsPanel.getElement().setAttribute("align", "center");
-
- popoverResourceSelection.setPlacement(Placement.LEFT);
- popoverResourceSelection.setHeading(aboutHeader.getHTML());
- popoverResourceSelection.setText(aboutBody.getHTML());
- resourceInfoButton.getElement().getStyle().setFloat(Float.RIGHT);
- resourceInfoButton.getElement().getStyle().setPaddingRight(0, Unit.PX);
- mainContainerResourcesSelection.getElement().getStyle().setPadding(20, Unit.PX);
+ // popoverResourceSelection.setPlacement(Placement.LEFT);
+ // popoverResourceSelection.setHeading(aboutHeader.getHTML());
+ // popoverResourceSelection.setText(aboutBody.getHTML());
+ // resourceInfoButton.getElement().getStyle().setFloat(Float.RIGHT);
+ // resourceInfoButton.getElement().getStyle().setPaddingRight(0, Unit.PX);
+ mainContainerResourcesSelection.getElement().getStyle().setPadding(10, Unit.PX);
prepareHandlers();
initLeftSidePanel(initialBean);
@@ -146,6 +142,7 @@ public class TwinColumnSelectionMainPanel extends Composite{
// perform an action on selection
selectionModelLeft.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
+
public void onSelectionChange(SelectionChangeEvent event) {
Iterator selectedObjectsIterator = selectionModelLeft.getSelectedSet().iterator();
@@ -166,7 +163,8 @@ public class TwinColumnSelectionMainPanel extends Composite{
public void onClick(ClickEvent event) {
removeStartingFromBreadcrumbs(navElem, pathBean);
- // breadcrumbsUpdater();
+ GWT.log("Clicked on element " + pathBean.resourceFolder.getName());
+ //breadcrumbsUpdater();
ResourceElementBean folder = pathBean.resourceFolder;
Collections.sort(folder.getChildren());
dataProviderLeft.setList(folder.getChildren());
@@ -177,7 +175,7 @@ public class TwinColumnSelectionMainPanel extends Composite{
pathListBeans.add(pathBean);
breadcrumbs.add(navElem);
- // breadcrumbsUpdater();
+ //breadcrumbsUpdater();
Collections.sort(selectedBean.getChildren());
dataProviderLeft.setList(selectedBean.getChildren());
@@ -207,7 +205,7 @@ public class TwinColumnSelectionMainPanel extends Composite{
public void onClick(ClickEvent event) {
removeStartingFromBreadcrumbs(root, pathBean);
- // breadcrumbsUpdater();
+ //breadcrumbsUpdater();
// set back the root content list
dataProviderLeft.setList(initialBean.getChildren());
@@ -222,8 +220,8 @@ public class TwinColumnSelectionMainPanel extends Composite{
showMorePanelLeft.setDisplay(cellListLeft);
showMorePanelLeft.setHeight(PANEL_HEIGHT);
showMorePanelLeft.getElement().getStyle().setBorderStyle(BorderStyle.SOLID);
- showMorePanelLeft.getElement().getStyle().setBorderWidth(1, Unit.PX);
- // showMorePanelLeft.getElement().getStyle().setBorderColor(PANEL_BORDER_COLOR);
+ showMorePanelLeft.getElement().getStyle().setBorderWidth(2, Unit.PX);
+ showMorePanelLeft.getElement().getStyle().setBorderColor(PANEL_BORDER_COLOR);
// add the list to the leftContainerPanel
leftContainer.add(showMorePanelLeft);
@@ -244,8 +242,10 @@ public class TwinColumnSelectionMainPanel extends Composite{
while(iteratorBreadcrumb.hasNext()){
Widget current = iteratorBreadcrumb.next();
- if(delete)
+ if(delete){
+ current.removeFromParent();
iteratorBreadcrumb.remove();
+ }
if(!delete && navElem.equals(current))
delete = true;
@@ -275,6 +275,16 @@ public class TwinColumnSelectionMainPanel extends Composite{
// Set a key provider that provides a unique key for each object.
cellListRight = new CellList(cell, ResourceElementBean.KEY_PROVIDER);
cellListRight.setKeyboardPagingPolicy(KeyboardPagingPolicy.INCREASE_RANGE);
+ cellListRight.setValueUpdater(new ValueUpdater() {
+
+ @Override
+ public void update(ResourceElementBean value) {
+
+ // just redraw the list
+ cellListRight.redraw();
+
+ }
+ });
// Add a selection model so we can select cells.
selectionModelRight = new MultiSelectionModel(ResourceElementBean.KEY_PROVIDER);
@@ -294,8 +304,8 @@ public class TwinColumnSelectionMainPanel extends Composite{
showMorePanelRight.setDisplay(cellListRight);
showMorePanelRight.setHeight(PANEL_HEIGHT);
showMorePanelRight.getElement().getStyle().setBorderStyle(BorderStyle.SOLID);
- showMorePanelRight.getElement().getStyle().setBorderWidth(1, Unit.PX);
- // showMorePanelRight.getElement().getStyle().setBorderColor(PANEL_BORDER_COLOR);
+ showMorePanelRight.getElement().getStyle().setBorderWidth(2, Unit.PX);
+ showMorePanelRight.getElement().getStyle().setBorderColor(PANEL_BORDER_COLOR);
// add the list to the leftContainerPanel
rightContainer.add(showMorePanelRight);
@@ -450,14 +460,13 @@ public class TwinColumnSelectionMainPanel extends Composite{
List current = dataProviderRight.getList();
List toReturn = new ArrayList();
- for (ResourceElementBean resourceElementBean : current) {
- if(resourceElementBean.isToBeAdded()){ // be sure ...
- resourceElementBean.setName(resourceElementBean.getFullPath());
- ResourceElementBean beanWithoutChildren = new ResourceElementBean(resourceElementBean);
+ for (ResourceElementBean resource : current) {
+ if(resource.isToBeAdded() && !resource.isFolder()){ // be sure ...
+ ResourceElementBean beanWithoutChildren = new ResourceElementBean(resource);
+ beanWithoutChildren.setName(resource.getEditableName());
toReturn.add(beanWithoutChildren);
}
}
-
return toReturn;
}
@@ -465,21 +474,24 @@ public class TwinColumnSelectionMainPanel extends Composite{
// void getResources(ClickEvent ce){
// getResourcesToPublish();
// }
-
+ //
// /**
- // * Short the current path if needed TODO
+ // * Short the current path if needed
// */
// private void breadcrumbsUpdater(){
//
// // ignore first and last elem
// boolean reduce = (pathListBeans.size() - 2) > PATH_THRESHOLD;
//
- // GWT.log("List is " + pathListBeans.toString());
+ // GWT.log("Is to reduce? " + reduce);
+ //
+ // GWT.log("Full size is " + pathListBeans.size());
//
// if(!reduce){
// GWT.log("Restore");
- // for(int i = 1; i < pathListBeans.size(); i++){
+ // for(int i = 0; i < pathListBeans.size(); i++){
// PathBean bean = pathListBeans.get(i);
+ // GWT.log("Elem is " + bean.resourceFolder);
// bean.link.setText(bean.resourceFolder.getName());
// bean.link.setVisible(true);
// }
@@ -491,7 +503,7 @@ public class TwinColumnSelectionMainPanel extends Composite{
// bean.link.setText(bean.resourceFolder.getName());
// bean.link.setVisible(true);
// }else if(i == (pathListBeans.size() - 2)){
- // GWT.log("The last to modify ****");
+ // GWT.log("The last to modify ****" + bean.resourceFolder.getName());
// bean.link.setText("...");
// bean.link.setVisible(true);
// }else{
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/TwinColumnSelection/TwinColumnSelectionMainPanel.ui.xml b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/TwinColumnSelection/TwinColumnSelectionMainPanel.ui.xml
index 31b92b3..a016c82 100644
--- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/TwinColumnSelection/TwinColumnSelectionMainPanel.ui.xml
+++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/TwinColumnSelection/TwinColumnSelectionMainPanel.ui.xml
@@ -1,27 +1,29 @@
+ xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:b="urn:import:com.github.gwtbootstrap.client.ui"
+ xmlns:m="urn:import:org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.TwinColumnSelection">
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
+
+
-
+
@@ -40,9 +42,12 @@
enabled="false" title="Remove selected files" text="<<" />
-
+
+
+
+
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/utils/GcubeDialogExtended.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/utils/GcubeDialogExtended.java
index 5876113..4627f1a 100644
--- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/utils/GcubeDialogExtended.java
+++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/utils/GcubeDialogExtended.java
@@ -1,6 +1,7 @@
package org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.utils;
import org.gcube.portlets.user.gcubewidgets.client.popup.GCubeDialog;
+import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.TwinColumnSelection.ResourceInfoForm;
import com.github.gwtbootstrap.client.ui.Paragraph;
import com.google.gwt.dom.client.Element;
@@ -19,6 +20,11 @@ import com.google.gwt.user.client.ui.HasHorizontalAlignment;
*/
public class GcubeDialogExtended extends GCubeDialog {
+ /**
+ * For simple information
+ * @param captionText
+ * @param text
+ */
public GcubeDialogExtended(String captionText, String text){
// add custom style
@@ -59,4 +65,47 @@ public class GcubeDialogExtended extends GCubeDialog {
});
add(new Paragraph(text));
}
+
+ /**
+ * For simple information
+ * @param captionText
+ * @param text
+ */
+ public GcubeDialogExtended(ResourceInfoForm form){
+
+ // add custom style
+ addStyleName("metadata-popup-panel");
+
+ // create an anchor to close the dialogbox
+ final Anchor closeAnchor = new Anchor("x");
+ closeAnchor.setTitle("Close");
+
+ // create a panel that will be put into the caption
+ FlexTable captionLayoutTable = new FlexTable();
+ captionLayoutTable.setText(0, 0, "About Resource");
+ captionLayoutTable.setWidget(0, 3, closeAnchor);
+ captionLayoutTable.getCellFormatter().setHorizontalAlignment(0, 3, HasHorizontalAlignment.ALIGN_RIGHT);
+ captionLayoutTable.setWidth("100%");
+ HTML caption = (HTML) getCaption();
+ caption.getElement().getStyle().setCursor(Cursor.MOVE);
+ caption.getElement().appendChild(captionLayoutTable.getElement());
+ caption.addClickHandler(new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent event) {
+ EventTarget target = event.getNativeEvent().getEventTarget();
+ Element targetElement = (Element) target.cast();
+ if (targetElement == closeAnchor.getElement()) {
+ closeAnchor.fireEvent(event);
+ }
+ }
+ });
+ closeAnchor.addClickHandler(new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent event) {
+ hide();
+ }
+ });
+ add(form);
+ }
+
}
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/utils/InfoIconsLabels.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/utils/InfoIconsLabels.java
index c2ae00a..b67127d 100644
--- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/utils/InfoIconsLabels.java
+++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/utils/InfoIconsLabels.java
@@ -29,7 +29,7 @@ public class InfoIconsLabels {
+ "product and by means of them it can be retrieved. A tag can contain only alphanumeric characters. "
+ "If the tag is composed by a single word it must have a size of at least two characters."
+ "Examples of good tags: \"This is a sample tag\", \"tagY\". Example of bad tag: \"c\".";
-
+
// LICENSES
public static final String LICENSES_INFO_ID_POPUP = "licenses-popup-panel-info";
public static final String LICENSES_INFO_CAPTION = "Licenses";
@@ -67,19 +67,20 @@ public class InfoIconsLabels {
// RESOURCES
public static final String RESOURCES_INFO_ID_POPUP = "resouces-popup-panel-info";
- public static final String RESOURCES_INFO_CAPTION = "Product Resources";
- public static final String RESOURCES_INFO_TEXT = "Manage the resources you want to associate to the product.";
-
+ public static final String RESOURCES_INFO_CAPTION = "Manage resource products";
+ public static final String RESOURCES_INFO_TEXT = "Move the files you want to attach to the product on the right panel below. Double click on the item for changing resource's name or description."
+ + " Please consider that any complex hierarchy structure you may have will be flatten.";
+
// CUSTOM FIELDS
public static final String CUSTOM_FIELDS_INFO_ID_POPUP = "custom-fields-popup-panel-info";
public static final String CUSTOM_FIELDS_INFO_CAPTION = "Product Custom Fields";
public static final String CUSTOM_FIELDS_INFO_TEXT = "Custom fields are customable metadata that will be added to the product. You have to choose a unique key for the field and a value for this. You can remove them at any time until you create the product.";
-
+
// TITLE
public static final String TITLE_INFO_ID_POPUP = "title-popup-panel-info";
public static final String TITLE_INFO_TEXT = "Product Title must contain only alphanumer characters, dots, underscore or hyphen minus. No others symbols are allowed.";
public static final String TITLE_INFO_CAPTION = "Product Title";
-
+
/**
* Prepare the popover and the gcube popup panel for information.
* @param text
@@ -140,7 +141,7 @@ public class InfoIconsLabels {
});
}
-
+
/**
* Check if an element of such type is actually a widget
* @param element
@@ -162,7 +163,7 @@ public class InfoIconsLabels {
}
return null;
}
-
+
/**
* Close any dialog box opened
*/
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/CKANPublisherServicesImpl.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/CKANPublisherServicesImpl.java
index f439dfd..cec163f 100644
--- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/CKANPublisherServicesImpl.java
+++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/CKANPublisherServicesImpl.java
@@ -93,7 +93,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
*/
public String getDevelopmentUser() {
String user = TEST_USER;
- // user = "costantino.perciante";
+ user = "costantino.perciante";
return user;
}
@@ -113,17 +113,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
ASLSession aslSession = getASLSession();
String username = aslSession.getUsername();
-
- // store info in the http session
- HttpSession httpSession = getThreadLocalRequest().getSession();
-
- // check the scope we need to discover
- String scopeInWhichDiscover = (scope != null && !scope.isEmpty()) ? scope : getASLSession().getScope();
-
- // get the key per scope
- String keyPerScope = UtilMethods.concatenateSessionKeyScope(SessionCatalogueAttributes.CKAN_TOKEN_KEY, scopeInWhichDiscover);
-
- // check if session expired
+ logger.debug("User in session is " + username);
if(username.equals(TEST_USER)){
logger.warn("Session expired, returning null token");
@@ -131,7 +121,11 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
}else{
try{
- logger.debug("User in session is " + username);
+
+ HttpSession httpSession = getThreadLocalRequest().getSession();
+ String scopeInWhichDiscover = (scope != null && !scope.isEmpty()) ? scope : getASLSession().getScope();
+ String keyPerScope = UtilMethods.concatenateSessionKeyScope(SessionCatalogueAttributes.CKAN_TOKEN_KEY, scopeInWhichDiscover);
+
if(httpSession.getAttribute(keyPerScope) != null){
token = (String)httpSession.getAttribute(keyPerScope);
logger.debug("Found ckan token into session");
@@ -161,10 +155,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
logger.debug("Request for user " + username + " organizations list");
List orgsName = new ArrayList();
- // get http session
HttpSession httpSession = getThreadLocalRequest().getSession();
-
- // get key
String keyPerScope = UtilMethods.concatenateSessionKeyScope(SessionCatalogueAttributes.CKAN_ORGANIZATIONS_PUBLISH_KEY, scope);
if(httpSession.getAttribute(keyPerScope) != null){
@@ -213,35 +204,40 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
ASLSession session = getASLSession();
String username = session.getUsername();
- // get http session
- HttpSession httpSession = getThreadLocalRequest().getSession();
- String scope = (String)httpSession.getAttribute(SessionCatalogueAttributes.SCOPE_CLIENT_PORTLET_URL);
+ if(username.equals(TEST_USER)){
- logger.info("Request for CKAN licenses for scope " + scope);
+ logger.warn("Session expired, returning null token");
+ return null;
- // get key per scope
- String keyPerScope = UtilMethods.concatenateSessionKeyScope(SessionCatalogueAttributes.CKAN_LICENSES_KEY, scope);
+ }else{
- LicensesBean licensesBean = null;
- if(httpSession.getAttribute(keyPerScope) != null){
- licensesBean = (LicensesBean)httpSession.getAttribute(keyPerScope);
- logger.debug("List of licenses was into session");
- }
- else{
- List titlesLicenses = getCatalogue(scope).getLicenses();
- List titles = new ArrayList();
- List urls = new ArrayList();
- for (CkanLicense license : titlesLicenses) {
- titles.add(license.getTitle());
- String url = (license.getUrl() != null && !license.getUrl().isEmpty()) ? license.getUrl() : "";
- urls.add(url);
+ // get http session
+ HttpSession httpSession = getThreadLocalRequest().getSession();
+ String scope = (String)httpSession.getAttribute(SessionCatalogueAttributes.SCOPE_CLIENT_PORTLET_URL);
+ logger.info("Request for CKAN licenses for scope " + scope);
+ String keyPerScope = UtilMethods.concatenateSessionKeyScope(SessionCatalogueAttributes.CKAN_LICENSES_KEY, scope);
+
+ LicensesBean licensesBean = null;
+ if(httpSession.getAttribute(keyPerScope) != null){
+ licensesBean = (LicensesBean)httpSession.getAttribute(keyPerScope);
+ logger.info("List of licenses was into session");
+ }
+ else{
+ List titlesLicenses = getCatalogue(scope).getLicenses();
+ List titles = new ArrayList();
+ List urls = new ArrayList();
+ for (CkanLicense license : titlesLicenses) {
+ titles.add(license.getTitle());
+ String url = (license.getUrl() != null && !license.getUrl().isEmpty()) ? license.getUrl() : "";
+ urls.add(url);
+ }
+ licensesBean = new LicensesBean(titles, urls);
+ httpSession.setAttribute(keyPerScope, licensesBean);
+ logger.info("List of licenses has been saved into session");
}
- licensesBean = new LicensesBean(titles, urls);
- httpSession.setAttribute(keyPerScope, licensesBean);
- logger.debug("List of licenses has been saved into session");
- }
- return licensesBean;
+ return licensesBean;
+ }
}
@Override
@@ -254,11 +250,6 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
logger.info("DatasetBean request for " + folderId + " and " + userName);
- HttpSession httpSession = this.getThreadLocalRequest().getSession();
- String scope = (String)httpSession.getAttribute(SessionCatalogueAttributes.SCOPE_CLIENT_PORTLET_URL);
-
- logger.debug("Scope recovered from session is " + scope);
-
if(isWithinPortal()){
try{
@@ -268,9 +259,14 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
return null;
}
+ HttpSession httpSession = this.getThreadLocalRequest().getSession();
+ String scope = (String)httpSession.getAttribute(SessionCatalogueAttributes.SCOPE_CLIENT_PORTLET_URL);
+
+ logger.debug("Scope recovered from session is " + scope);
+
logger.debug("Request dataset metadata bean for folder with id " + folderId
+ " whose owner is " + userName);
- // get usermanager (liferay)
+
UserManager liferUserManager = new LiferayUserManager();
GCubeUser userOwner = liferUserManager.getUserByUsername(userName);
@@ -290,9 +286,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
// if the request comes from the workspace
if(folderId != null && !folderId.isEmpty()){
-
WorkspaceUtils.handleWorkspaceResources(folderId, userName, bean);
-
}
}catch(Exception e){
@@ -301,7 +295,6 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
}else{
try{
-
bean = new DatasetMetadataBean();
bean.setId(folderId);
bean.setDescription("This is a fantastic description");
@@ -317,11 +310,8 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
bean.setOwnerIdentifier(userName);
if(folderId != null && !folderId.isEmpty()){
-
WorkspaceUtils.handleWorkspaceResources(folderId, userName, bean);
-
}
-
}catch(Exception e){
logger.error("Error while building bean into dev mode", e);
}
@@ -342,7 +332,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
// check if session expired
if(userName.equals(TEST_USER)){
- logger.debug("SESSION EXPIRED");
+ logger.warn("SESSION EXPIRED");
return null;
}
@@ -379,7 +369,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
if(datasetId != null){
- logger.debug("Dataset created!");
+ logger.info("Dataset created!");
toCreate.setId(datasetId);
// retrieve the url
@@ -427,7 +417,6 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
@Override
public ResourceElementBean addResourceToDataset(ResourceElementBean resource, String datasetId) {
-
ASLSession session = getASLSession();
String username = session.getUsername();
@@ -442,13 +431,10 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
}else{
if(username.equals(TEST_USER)){
-
- logger.warn("SESSION EXPIRED! ");
+ logger.warn("SESSION EXPIRED!");
return null;
-
}else{
try{
-
ResourceBean resourceBean = new ResourceBean(
resource.getUrl(),
resource.getName(),
@@ -501,7 +487,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
deleted = getCatalogue(scope).
deleteResourceFromDataset(resource.getOriginalIdInWorkspace(), getUserCKanTokenFromSession(scope));
if(deleted){
- logger.debug("Resource described by " + resource + " deleted");
+ logger.info("Resource described by " + resource + " deleted");
}else
logger.error("Resource described by " + resource + " NOT deleted");
}catch(Exception e){
@@ -516,7 +502,6 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
public List getProfiles(String orgName) {
logger.debug("Requested profiles for products into orgName " + orgName);
-
List toReturn = new ArrayList();
try{
String evaluatedScope = getScopeFromOrgName(orgName);
@@ -534,17 +519,13 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
if(title == null || title.isEmpty())
return true; // it's an error somehow
-
try{
-
String scope = (String)getThreadLocalRequest().getSession().getAttribute(SessionCatalogueAttributes.SCOPE_CLIENT_PORTLET_URL);
String idFromTitle = org.gcube.datacatalogue.ckanutillibrary.utils.UtilMethods.fromProductTitleToName(title);
return getCatalogue(scope).existProductWithNameOrId(idFromTitle);
-
}catch(Exception e){
logger.error("Unable to check if such a dataset id already exists", e);
}
-
return false;
}
@@ -555,7 +536,6 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
private String getScopeFromOrgName(String orgName){
logger.debug("Request for scope related to orgName " + orgName + "[ map that will be used is " + mapOrganizationScope.toString() + " ]");
-
if(orgName == null || orgName.isEmpty())
throw new IllegalArgumentException("orgName cannot be empty or null!");
@@ -565,22 +545,17 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
toReturn = mapOrganizationScope.get(orgName);
else{
try{
-
String evaluatedScope = Utils.retrieveScopeFromOrganizationName(orgName);
mapOrganizationScope.put(orgName, evaluatedScope);
toReturn = evaluatedScope;
-
}catch(Exception e){
logger.error("Failed to retrieve scope from OrgName for organization " + orgName, e);
}
}
-
-
logger.debug("Returning scope " + toReturn);
return toReturn;
-
}
- //
+
// @Override
// public ResourceElementBean getTreeFolder(String folderId) {
//
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/utils/WorkspaceUtils.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/utils/WorkspaceUtils.java
index b21bf5c..57aa4bb 100644
--- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/utils/WorkspaceUtils.java
+++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/utils/WorkspaceUtils.java
@@ -55,13 +55,16 @@ public class WorkspaceUtils {
copiedFolder.setDescription(bean.getDescription());
// change name of the copied folder to match the title (append the timestamp to avoid ties)
- ((WorkspaceFolder)copiedFolder).rename(org.gcube.datacatalogue.ckanutillibrary.utils.UtilMethods.fromProductTitleToName(bean.getTitle()) + "_" + System.currentTimeMillis());
+ long referenceTime = System.currentTimeMillis();
+ ((WorkspaceFolder)copiedFolder).rename(org.gcube.datacatalogue.ckanutillibrary.utils.UtilMethods.fromProductTitleToName(bean.getTitle()) + "_" + referenceTime);
// copy only the selected ones
for(ResourceElementBean resource : resourcesToAdd){
if (resource.isToBeAdded()) {
+ logger.debug("Resource to add is " + resource);
+
// ok it is a file, so copy it into the copiedFolder
WorkspaceItem copiedFile = userCatalogue.addWorkspaceItem(resource.getOriginalIdInWorkspace(), copiedFolder.getId());
@@ -74,15 +77,13 @@ public class WorkspaceUtils {
copiedFile.getDescription(),
copiedFile.getId(),
userName,
- null, // to be set
+ null, // dataset id, to be set
((FolderItem)copiedFile).getMimeType()));
// postpone rename operation
- copiedFile.rename(resource.getName() + "_" + System.currentTimeMillis());
+ copiedFile.rename(resource.getName() + "_" + referenceTime);
}
}
-
- // return
return resources;
}
@@ -128,22 +129,23 @@ public class WorkspaceUtils {
* @throws Exception
*/
public static ResourceElementBean getTreeFromFolder(String workspaceFolderId, Workspace ws) throws Exception{
-
- // start tree construction
ResourceElementBean rootElem = new ResourceElementBean();
String pathSeparator = ws.getPathSeparator();
try{
- WorkspaceItem initialItemWS = ws.getItem(workspaceFolderId);
- String fullPathBase = initialItemWS.getPath();
+ WorkspaceItem initialItem = ws.getItem(workspaceFolderId);
+ String fullPathBase = initialItem.getPath();
fullPathBase = fullPathBase.endsWith(ws.getPathSeparator()) ? fullPathBase : fullPathBase + ws.getPathSeparator();
- rootElem.setFolder(initialItemWS.isFolder());
- rootElem.setFullPath(initialItemWS.getPath().replace(fullPathBase, ""));
+ rootElem.setFolder(initialItem.isFolder());
+ rootElem.setFullPath(initialItem.getPath().replace(fullPathBase, ""));
rootElem.setParent(null);
- rootElem.setName(initialItemWS.getName());
- rootElem.setOriginalIdInWorkspace(initialItemWS.getId());
- replaceFullPath(rootElem, pathSeparator);
- // start visiting
- visit(rootElem, initialItemWS, fullPathBase, pathSeparator);
+ rootElem.setName(initialItem.getName());
+ rootElem.setOriginalIdInWorkspace(initialItem.getId());
+ rootElem.setDescription(initialItem.getDescription());
+ extractEditableNameFromPath(rootElem, pathSeparator);
+
+ // recursive visiting
+ if(initialItem.isFolder())
+ visit(rootElem, initialItem, fullPathBase, pathSeparator);
}catch(Exception e){
logger.error("Failed to build the resource tree", e);
return null;
@@ -151,44 +153,47 @@ public class WorkspaceUtils {
return rootElem;
}
- /**
- * Replaces the "/" char with a custom one
- * @param rootElem
- * @param pathSeparatorInWs
- */
- private static void replaceFullPath(ResourceElementBean rootElem, String pathSeparatorInWs) {
-
- if(rootElem == null)
- return;
-
- String elemName = rootElem.getName();
- int lastIndex = rootElem.getFullPath().lastIndexOf(elemName);
- String fullPath = rootElem.getFullPath().substring(0, lastIndex);
- fullPath = fullPath.replaceAll(pathSeparatorInWs, RESOURCES_NAME_SEPARATOR) + elemName;
- rootElem.setFullPath(fullPath);
- }
-
/**
* Recursive visit of a workspace item
* @param rootElem
* @param initialItemWS
* @throws InternalErrorException
*/
- private static void visit(ResourceElementBean rootElem, WorkspaceItem initialItemWS, String fullPathBase, String pathSeparator) throws InternalErrorException {
+ private static void visit(ResourceElementBean parent, WorkspaceItem initialItemWS, String fullPathBase, String pathSeparator) throws InternalErrorException {
List extends WorkspaceItem> children = initialItemWS.getChildren();
ArrayList childrenInTree = new ArrayList(children.size());
- for (WorkspaceItem workspaceItem : children) {
+ for (WorkspaceItem item : children) {
ResourceElementBean elem = new ResourceElementBean();
- elem.setFolder(workspaceItem.isFolder());
- elem.setOriginalIdInWorkspace(workspaceItem.getId());
- elem.setFullPath(workspaceItem.getPath().replace(fullPathBase, ""));
- elem.setParent(rootElem);
- elem.setName(workspaceItem.getName());
- replaceFullPath(elem, pathSeparator);
+ elem.setFolder(item.isFolder());
+ elem.setOriginalIdInWorkspace(item.getId());
+ elem.setFullPath(item.getPath().replace(fullPathBase, ""));
+ elem.setParent(parent);
+ elem.setName(item.getName());
+ elem.setDescription(item.getDescription());
+ extractEditableNameFromPath(elem, pathSeparator);
childrenInTree.add(elem);
- visit(elem, workspaceItem, fullPathBase, pathSeparator);
+ if(item.isFolder())
+ visit(elem, item, fullPathBase, pathSeparator);
}
- rootElem.setChildren(childrenInTree);
+ // add these list as child of the rootElem
+ parent.setChildren(childrenInTree);
+ }
+
+ /**
+ * Replaces the "/" char with a custom one
+ * @param rootElem
+ * @param pathSeparatorInWs
+ */
+ private static void extractEditableNameFromPath(ResourceElementBean rootElem, String pathSeparatorInWs) {
+
+ if(rootElem == null)
+ return;
+
+ String elemName = rootElem.getName();
+ int lastIndex = rootElem.getFullPath().lastIndexOf(elemName);
+ String fullPath = rootElem.getFullPath().substring(0, lastIndex);
+ fullPath = fullPath.replaceAll(pathSeparatorInWs, RESOURCES_NAME_SEPARATOR) + elemName;
+ rootElem.setEditableName(fullPath);
}
}
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/shared/ResourceElementBean.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/shared/ResourceElementBean.java
index f13c257..e722094 100644
--- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/shared/ResourceElementBean.java
+++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/shared/ResourceElementBean.java
@@ -15,16 +15,17 @@ public class ResourceElementBean implements Comparable, Ser
private static final long serialVersionUID = -1230871392599580669L;
private int identifierGWT;
private String name;
+ private String editableName;
private boolean toBeAdded;
private boolean isFolder;
- private ResourceElementBean parent;
- private List children;
private String fullPath;
private String originalIdInWorkspace;
private String mimeType;
private String url;
private String description;
private String organizationNameDatasetParent; // the organization name in which the parent dataset was created
+ private ResourceElementBean parent;
+ private List children;
// to generate the identifiers
private static int nextId = 0;
@@ -45,6 +46,9 @@ public class ResourceElementBean implements Comparable, Ser
*/
public ResourceElementBean(ResourceElementBean another) {
this.name = another.name;
+ this.toBeAdded = another.toBeAdded;
+ this.fullPath = another.fullPath;
+ this.editableName = another.editableName;
this.originalIdInWorkspace = another.originalIdInWorkspace;
this.mimeType = another.mimeType;
this.url = another.url;
@@ -206,6 +210,14 @@ public class ResourceElementBean implements Comparable, Ser
this.originalIdInWorkspace = originalIdInWorkspace;
}
+ public String getEditableName() {
+ return editableName;
+ }
+
+ public void setEditableName(String newName) {
+ this.editableName = newName;
+ }
+
@Override
public boolean equals(Object o) {
boolean toReturn = false;
@@ -216,21 +228,22 @@ public class ResourceElementBean implements Comparable, Ser
return toReturn;
}
- @Override
- public String toString() {
- return "ResourceElementBean [identifierGWT=" + identifierGWT
- + ", name=" + name + ", toBeAdded=" + toBeAdded + ", isFolder="
- + isFolder + ", parent=" + parent + ", children number=" + (children == null ? 0 : children.size())
- + ", fullPath=" + fullPath + ", originalIdInWorkspace="
- + originalIdInWorkspace + ", mimeType=" + mimeType + ", url="
- + url + ", description=" + description
- + ", organizationNameDatasetParent="
- + organizationNameDatasetParent + "]";
- }
-
@Override
public int compareTo(ResourceElementBean o) {
int toReturn = (o == null || o.fullPath == null) ? -1 : -o.fullPath.compareTo(fullPath);
return toReturn;
}
+
+ @Override
+ public String toString() {
+ return "ResourceElementBean [identifierGWT=" + identifierGWT
+ + ", name=" + name + ", editableName=" + editableName
+ + ", toBeAdded=" + toBeAdded + ", isFolder=" + isFolder
+ + ", fullPath=" + fullPath + ", originalIdInWorkspace="
+ + originalIdInWorkspace + ", mimeType=" + mimeType + ", url="
+ + url + ", description=" + description
+ + ", organizationNameDatasetParent="
+ + organizationNameDatasetParent + ", parent=" + parent
+ + ", children number=" + (children == null ? 0 : children.size()) + "]";
+ }
}