From f4846b0a668a4716c2e89e486e4415fd797d777e Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Tue, 9 Mar 2021 19:02:26 +0100 Subject: [PATCH] in progress on "Manage Resources" --- .../client/CKanMetadataPublisher.java | 4 +- .../ResourceInfoForm.ui.xml | 118 ++++++++++-------- .../client/ui/form/CreateDatasetForm.java | 18 +-- .../client/ui/utils/InfoIconsLabels.java | 4 +- .../EditPublishingResourceEvent.java | 62 +++++++++ .../EditPublishingResourceEventHandler.java | 22 ++++ .../RemovePublishingResourceEvent.java | 59 +++++++++ .../RemovePublishingResourceEventHandler.java | 22 ++++ .../SelectResourceByWEMainPanel.java | 102 +++++++++++++-- .../SelectResourceByWEMainPanel.ui.xml | 44 +++++-- .../ui/workspace/SelectResourceWidget.java | 41 +++++- .../server/utils/WorkspaceUtils.java | 12 +- 12 files changed, 411 insertions(+), 97 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/EditPublishingResourceEvent.java create mode 100644 src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/EditPublishingResourceEventHandler.java create mode 100644 src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/RemovePublishingResourceEvent.java create mode 100644 src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/RemovePublishingResourceEventHandler.java diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/CKanMetadataPublisher.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/CKanMetadataPublisher.java index 2cbba2b..c75ec32 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/CKanMetadataPublisher.java +++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/CKanMetadataPublisher.java @@ -266,10 +266,10 @@ public class CKanMetadataPublisher implements EntryPoint { m.getElement().getStyle().setMarginLeft(-30, Unit.PCT); ResourceElementBean r = new ResourceElementBean(); r.setFolder(false); - r.setName("Root"); + r.setName("Mangiacrapra_Introducing_myself.pptx"); r.setParent(null); r.setChildrenSize(5); - r.setOriginalIdInWorkspace("31d7ec0c-8d31-47d7-9139-c52b5e124349"); + r.setOriginalIdInWorkspace("8489e2ab-7487-404f-97ff-5aecc35c241f"); ResourceElementBean parent = new ResourceElementBean(); parent.setOriginalIdInWorkspace("91409eba-0bf6-4aa5-8d73-3536bf181587"); diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/TwinColumnSelection/ResourceInfoForm.ui.xml b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/TwinColumnSelection/ResourceInfoForm.ui.xml index c9d29ce..bc64abf 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/TwinColumnSelection/ResourceInfoForm.ui.xml +++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/TwinColumnSelection/ResourceInfoForm.ui.xml @@ -1,6 +1,7 @@ + xmlns:g="urn:import:com.google.gwt.user.client.ui" + xmlns:b="urn:import:com.github.gwtbootstrap.client.ui"> .legend-style { width: 100%; @@ -28,61 +29,68 @@ .control-group { margin-bottom: 0px !important; } + + .custom-input { + + } + - - - - - Resource Information - - - - - Name: - - - - - - - - Path: - - - - - - - - Description: - - - - - - - - Format: - - - - - - - - Update - - + + + + + Resource Information + + + + + Name: + + + + + + + + Path: + + + + + + + + Description: + + + + + + + + Format: + + + + + + + + Update + + \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/CreateDatasetForm.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/CreateDatasetForm.java index 456fa0a..b93f95f 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/CreateDatasetForm.java +++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/CreateDatasetForm.java @@ -1247,15 +1247,15 @@ public class CreateDatasetForm extends Composite{ ); // resources field -// InfoIconsLabels.preparePopupPanelAndPopover( -// InfoIconsLabels.RESOURCES_INFO_ID_POPUP, -// InfoIconsLabels.RESOURCES_INFO_TEXT, -// InfoIconsLabels.RESOURCES_INFO_CAPTION, -// infoIconResources, -// popoverResources, -// focusPanelResources, -// popupOpenedIds -// ); + InfoIconsLabels.preparePopupPanelAndPopover( + InfoIconsLabels.RESOURCES_INFO_ID_POPUP, + InfoIconsLabels.RESOURCES_INFO_TEXT, + InfoIconsLabels.RESOURCES_INFO_CAPTION, + infoIconResources, + popoverResources, + focusPanelResources, + popupOpenedIds + ); // title InfoIconsLabels.preparePopupPanelAndPopover( 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 09e3787..7f3f316 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 @@ -70,8 +70,8 @@ public class InfoIconsLabels { // RESOURCES public static final String RESOURCES_INFO_ID_POPUP = "resouces-popup-panel-info"; public static final String RESOURCES_INFO_CAPTION = "Manage resource items"; - public static final String RESOURCES_INFO_TEXT = "Move the files you want to attach to the item 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."; + public static final String RESOURCES_INFO_TEXT = "Select the files you want to attach to the publishing item. Click on 'Trash' to remote it. Click on 'Edit' for changing resource's name or description." + + " You can add others files by using the 'Add files from...' facility. To navigate a folder perform a 'double click' on it. 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"; diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/EditPublishingResourceEvent.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/EditPublishingResourceEvent.java new file mode 100644 index 0000000..64d292b --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/EditPublishingResourceEvent.java @@ -0,0 +1,62 @@ +package org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.workspace; + +import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.ResourceElementBean; + +import com.google.gwt.event.shared.GwtEvent; + + +// TODO: Auto-generated Javadoc +/** + * The Class EditPublishingResourceEvent. + * + * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) + * + * Mar 9, 2021 + */ +public class EditPublishingResourceEvent extends GwtEvent { + + /** The type. */ + public static Type TYPE = new Type(); + + /** The resource. */ + private ResourceElementBean resource; + + + /** + * Instantiates a new edits the publishing resource event. + * + * @param resource the resource + */ + public EditPublishingResourceEvent(ResourceElementBean resource) { + this.resource = resource; + } + + /** + * Gets the resource. + * + * @return the resource + */ + public ResourceElementBean getResource() { + return resource; + } + + /** + * Gets the associated type. + * + * @return the associated type + */ + @Override + public Type getAssociatedType() { + return TYPE; + } + + /** + * Dispatch. + * + * @param handler the handler + */ + @Override + protected void dispatch(EditPublishingResourceEventHandler handler) { + handler.onEditResource(this); + } +} diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/EditPublishingResourceEventHandler.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/EditPublishingResourceEventHandler.java new file mode 100644 index 0000000..333fa76 --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/EditPublishingResourceEventHandler.java @@ -0,0 +1,22 @@ +package org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.workspace; + +import com.google.gwt.event.shared.EventHandler; + + +// TODO: Auto-generated Javadoc +/** + * The Interface EditPublishingResourceEventHandler. + * + * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) + * + * Mar 9, 2021 + */ +public interface EditPublishingResourceEventHandler extends EventHandler { + + /** + * On edit resource. + * + * @param editResourceEvent the edit resource event + */ + void onEditResource(EditPublishingResourceEvent editResourceEvent); +} diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/RemovePublishingResourceEvent.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/RemovePublishingResourceEvent.java new file mode 100644 index 0000000..c3973e1 --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/RemovePublishingResourceEvent.java @@ -0,0 +1,59 @@ +package org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.workspace; + +import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.ResourceElementBean; + +import com.google.gwt.event.shared.GwtEvent; + +/** + * The Class RemovePublishingResourceEvent. + * + * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) + * + * Mar 9, 2021 + */ +public class RemovePublishingResourceEvent extends GwtEvent { + + /** The type. */ + public static Type TYPE = new Type(); + + /** The resource. */ + private ResourceElementBean resource; + + /** + * Instantiates a new removes the publishing resource event. + * + * @param resource the resource + */ + public RemovePublishingResourceEvent(ResourceElementBean resource) { + this.resource = resource; + } + + /** + * Gets the resource. + * + * @return the resource + */ + public ResourceElementBean getResource() { + return resource; + } + + /** + * Gets the associated type. + * + * @return the associated type + */ + @Override + public Type getAssociatedType() { + return TYPE; + } + + /** + * Dispatch. + * + * @param handler the handler + */ + @Override + protected void dispatch(RemovePublishingResourceEventHandler handler) { + handler.onRemoveResource(this); + } +} diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/RemovePublishingResourceEventHandler.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/RemovePublishingResourceEventHandler.java new file mode 100644 index 0000000..93c2031 --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/RemovePublishingResourceEventHandler.java @@ -0,0 +1,22 @@ +package org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.workspace; + +import com.google.gwt.event.shared.EventHandler; + + +// TODO: Auto-generated Javadoc +/** + * The Interface RemovePublishingResourceEventHandler. + * + * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) + * + * Mar 9, 2021 + */ +public interface RemovePublishingResourceEventHandler extends EventHandler { + + /** + * On remove resource. + * + * @param removeResourceEvent the remove resource event + */ + void onRemoveResource(RemovePublishingResourceEvent removeResourceEvent); +} diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/SelectResourceByWEMainPanel.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/SelectResourceByWEMainPanel.java index 1a24e3e..b8b20d4 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/SelectResourceByWEMainPanel.java +++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/SelectResourceByWEMainPanel.java @@ -3,6 +3,7 @@ package org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.workspace; import java.util.HashMap; import java.util.Map; +import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.TwinColumnSelection.ResourceInfoForm; import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.ResourceElementBean; import org.gcube.portlets.widgets.wsexplorer.client.explore.WorkspaceResourcesExplorerPanel; import org.gcube.portlets.widgets.wsexplorer.client.notification.WorkspaceExplorerSelectNotification.WorskpaceExplorerSelectNotificationListener; @@ -12,10 +13,14 @@ import org.gcube.portlets.widgets.wsexplorer.shared.Item; import com.github.gwtbootstrap.client.ui.AccordionGroup; import com.github.gwtbootstrap.client.ui.Alert; import com.github.gwtbootstrap.client.ui.Button; +import com.github.gwtbootstrap.client.ui.Label; import com.github.gwtbootstrap.client.ui.constants.AlertType; +import com.github.gwtbootstrap.client.ui.constants.LabelType; import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; +import com.google.gwt.event.dom.client.HasAllDragAndDropHandlers; +import com.google.gwt.event.shared.HandlerManager; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.user.client.Timer; @@ -57,8 +62,16 @@ public class SelectResourceByWEMainPanel extends Composite { @UiField HTMLPanel containerPickResources; + @UiField + Label labelNothing; + + @UiField + HTMLPanel editPanel; + private Item selectedWEItem; + public final static HandlerManager eventBus = new HandlerManager(null); + Map mapSelectedResources = new HashMap(); /** @@ -76,30 +89,33 @@ public class SelectResourceByWEMainPanel extends Composite { */ public SelectResourceByWEMainPanel(ResourceElementBean initialBean) { initWidget(uiBinder.createAndBindUi(this)); - - this.frozen = false; - + SelectResourceByWEMainPanel.frozen = false; this.initialBean = initialBean; - //this.buttPickResources.setType(ButtonType.LINK); - - WorkspaceResourcesExplorerPanel rp = null; - - DISPLAY_FIELD[] displayFields = new DISPLAY_FIELD[] { DISPLAY_FIELD.ICON, DISPLAY_FIELD.NAME, - DISPLAY_FIELD.OWNER, DISPLAY_FIELD.CREATION_DATE}; + this.labelNothing.setType(LabelType.INFO); + try { String wsRootId = null; + String rootName = null; if(initialBean.isFolder()) { wsRootId = initialBean.getOriginalIdInWorkspace(); + rootName = initialBean.getName(); }else { //is file - wsRootId= initialBean.getParent()!=null? initialBean.getParent().getOriginalIdInWorkspace():null; + + if(initialBean.getParent()!=null) { + wsRootId = initialBean.getParent().getOriginalIdInWorkspace(); + rootName = initialBean.getParent().getName(); + } } //loads the WE only if the root is not null if(wsRootId!=null) { + DISPLAY_FIELD[] displayFields = new DISPLAY_FIELD[] { DISPLAY_FIELD.ICON, DISPLAY_FIELD.NAME, + DISPLAY_FIELD.OWNER, DISPLAY_FIELD.CREATION_DATE}; + WorkspaceResourcesExplorerPanel workspaceExplorerPanel = new WorkspaceResourcesExplorerPanel(wsRootId,false,null, null,false,null,displayFields); WorskpaceExplorerSelectNotificationListener wsResourceExplorerListener = new WorskpaceExplorerSelectNotificationListener() { @@ -132,6 +148,10 @@ public class SelectResourceByWEMainPanel extends Composite { }else { containerPickResources.setVisible(false); } + + if(rootName!=null) { + buttPickResources.setHeading("Add files from "+rootName); + } } catch (Exception e) { @@ -141,7 +161,12 @@ public class SelectResourceByWEMainPanel extends Composite { if(!initialBean.isFolder()) { addSelectResource(initialBean.getOriginalIdInWorkspace(), initialBean.getName(),initialBean.getFullPath()); } + + addHandlers(); + } + + private void addHandlers() { buttSelectResource.addClickHandler(new ClickHandler() { @@ -154,8 +179,54 @@ public class SelectResourceByWEMainPanel extends Composite { } }); + eventBus.addHandler(RemovePublishingResourceEvent.TYPE, new RemovePublishingResourceEventHandler() { + + @Override + public void onRemoveResource(RemovePublishingResourceEvent removeResourceEvent) { + if(removeResourceEvent.getResource()!=null) { + removePublishingResource(removeResourceEvent.getResource()); + } + } + + }); + + eventBus.addHandler(EditPublishingResourceEvent.TYPE, new EditPublishingResourceEventHandler() { + + @Override + public void onEditResource(EditPublishingResourceEvent editResourceEvent) { + if(editResourceEvent.getResource()!=null) { + editPublishingResource(editResourceEvent.getResource()); + } + + } + + + }); + } + private void editPublishingResource(ResourceElementBean resource) { + + SelectResourceWidget theRW = mapSelectedResources.get(resource.getOriginalIdInWorkspace()); + if(theRW!=null) { + + ResourceInfoForm rif = new ResourceInfoForm(resource, null); + editPanel.add(rif); + } + + } + + private void removePublishingResource(ResourceElementBean resource) { + + SelectResourceWidget theRW = mapSelectedResources.get(resource.getOriginalIdInWorkspace()); + if(theRW!=null) { + selectResourcesContainer.remove(theRW); + mapSelectedResources.remove(resource.getOriginalIdInWorkspace()); + } + + showNothingResourceSelected(); + } + public void addSelectResource(String wsItemId, String name, String path) { SelectResourceWidget selWidg = mapSelectedResources.get(wsItemId); @@ -163,7 +234,7 @@ public class SelectResourceByWEMainPanel extends Composite { showAlertMsg(AlertType.WARNING,"Item '" + name + "' already selected",true); return; } - + ResourceElementBean rb = new ResourceElementBean(); rb.setOriginalIdInWorkspace(wsItemId); rb.setName(name); @@ -174,6 +245,15 @@ public class SelectResourceByWEMainPanel extends Composite { mapSelectedResources.put(wsItemId, selWidg); selectResourcesContainer.add(selWidg); + showNothingResourceSelected(); + + } + + private void showNothingResourceSelected() { + if(mapSelectedResources.size()==0) { + labelNothing.setVisible(true); + }else + labelNothing.setVisible(false); } private void showAlertMsg(AlertType type, String txt, boolean autoHide) { diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/SelectResourceByWEMainPanel.ui.xml b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/SelectResourceByWEMainPanel.ui.xml index 82aec99..2ab7607 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/SelectResourceByWEMainPanel.ui.xml +++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/SelectResourceByWEMainPanel.ui.xml @@ -7,33 +7,55 @@ font-weight: bold; } - .margin-bottom-40 { - margin-bottom: 40px; + .custom-header { + margin-top: 0px !important; + } + + .custom-header h1 { + font-size: 18px !important; } .max-height-250 { max-height: 250px; overflow-y: auto; } + + .no-border { + border: 0px !important; + } + + .margin-top-10 { + margin-top: 10px; + } + + .margin-top-20 { + margin-top: 20px; + } - - Selected - - + + Publishing Resources + + + Nothing + + + - + + + heading="Add files from..." defaultOpen="false" + addStyleNames="{style.no-border}"> - Select + Select - - \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/SelectResourceWidget.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/SelectResourceWidget.java index 7be131d..e5d677e 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/SelectResourceWidget.java +++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/SelectResourceWidget.java @@ -5,6 +5,8 @@ import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.ResourceElement import com.github.gwtbootstrap.client.ui.Button; import com.github.gwtbootstrap.client.ui.constants.ButtonType; import com.google.gwt.core.client.GWT; +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.user.client.ui.Composite; @@ -24,26 +26,53 @@ public class SelectResourceWidget extends Composite { @UiField Button buttonDelete; - + @UiField Button buttonEdit; - + @UiField Label fieldName; private ResourceElementBean resourceBean; - public SelectResourceWidget(ResourceElementBean rb) { initWidget(uiBinder.createAndBindUi(this)); - + this.resourceBean = rb; - + this.fieldName.setText(rb.getEditableName()); - + buttonEdit.setType(ButtonType.LINK); + buttonDelete.setType(ButtonType.LINK); + addHandlers(); + + } + + private void addHandlers() { + + buttonEdit.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + SelectResourceByWEMainPanel.eventBus.fireEvent(new EditPublishingResourceEvent(resourceBean)); + + } + }); + + buttonDelete.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + SelectResourceByWEMainPanel.eventBus.fireEvent(new RemovePublishingResourceEvent(resourceBean)); + } + }); + + } + + public ResourceElementBean getResourceBean() { + return resourceBean; } } 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 b11e45f..2330412 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 @@ -159,7 +159,17 @@ public class WorkspaceUtils { //setting parent id ResourceElementBean theParent = new ResourceElementBean(); - theParent.setOriginalIdInWorkspace(originalFolderOrFile.getParentId()); + + if(originalFolderOrFile.getParentId()!=null) { + try { + WorkspaceItem parentItem = workspace.getItem(originalFolderOrFile.getParentId()); + theParent.setOriginalIdInWorkspace(parentItem.getId()); + theParent.setName(parentItem.getName()); + }catch (Exception e) { + logger.warn("Error on loading the parent item with id: "+originalFolderOrFile.getParentId()+" skipping it"); + } + } + resourceEB.setParent(theParent); bean.setResourceRoot(resourceEB); }