in progress on registerFileSet
This commit is contained in:
parent
b4ec07371b
commit
3bda56a55c
|
@ -12,6 +12,7 @@
|
|||
|
||||
|
||||
|
||||
|
||||
<wb-module deploy-name="geoportal-data-entry-app-2.0.0-SNAPSHOT">
|
||||
|
||||
|
||||
|
@ -26,6 +27,7 @@
|
|||
|
||||
|
||||
|
||||
|
||||
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
|
||||
|
||||
|
||||
|
@ -40,6 +42,7 @@
|
|||
|
||||
|
||||
|
||||
|
||||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||
|
||||
|
||||
|
@ -54,6 +57,7 @@
|
|||
|
||||
|
||||
|
||||
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||
|
||||
|
||||
|
@ -68,6 +72,7 @@
|
|||
|
||||
|
||||
|
||||
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
||||
<dependent-module archiveName="geoportal-data-common-1.2.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/geoportal-data-common/geoportal-data-common">
|
||||
<dependency-type>uses</dependency-type>
|
||||
|
@ -85,6 +90,7 @@
|
|||
|
||||
|
||||
|
||||
|
||||
<property name="context-root" value="geoportal-data-entry-app"/>
|
||||
|
||||
|
||||
|
@ -99,6 +105,7 @@
|
|||
|
||||
|
||||
|
||||
|
||||
<property name="java-output-path" value="/geoportal-data-entry-app/target/geoportal-data-entry-app-2.0.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
|
||||
|
||||
|
@ -113,6 +120,7 @@
|
|||
|
||||
|
||||
|
||||
|
||||
</wb-module>
|
||||
|
||||
|
||||
|
@ -127,4 +135,5 @@
|
|||
|
||||
|
||||
|
||||
|
||||
</project-modules>
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.List;
|
|||
|
||||
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
|
||||
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.content.WorkspaceContentDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.paths.FileSetPathsDV;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport;
|
||||
|
@ -124,5 +125,6 @@ public interface GeoportalDataEntryService extends RemoteService {
|
|||
* @throws Exception the exception
|
||||
*/
|
||||
ConcessioneDV updateSectionForRecord(String itemId, String recordType, String section, int pathIndex,
|
||||
GenericDatasetBean gDBean) throws Exception;
|
||||
List<WorkspaceContentDV> keepCurrentContent, GenericDatasetBean gDBean) throws Exception;
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.List;
|
|||
|
||||
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
|
||||
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.content.WorkspaceContentDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.paths.FileSetPathsDV;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport;
|
||||
|
@ -71,5 +72,6 @@ public interface GeoportalDataEntryServiceAsync
|
|||
|
||||
|
||||
void updateSectionForRecord(String itemId, String recordType, String section, int pathIndex,
|
||||
GenericDatasetBean gDBean, AsyncCallback<ConcessioneDV> callback);
|
||||
List<WorkspaceContentDV> keepCurrentContent, GenericDatasetBean gDBean,
|
||||
AsyncCallback<ConcessioneDV> callback);
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
addStyleNames="{style.button-save-style}"
|
||||
ui:field="buttonJSONUpdate">UPDATE</b:Button>
|
||||
</b:Tab>
|
||||
<b:Tab icon="UPLOAD_ALT" heading="Update File/s"
|
||||
<b:Tab icon="UPLOAD_ALT" heading="Manage File/s"
|
||||
ui:field="tabUploadFiles">
|
||||
<b:Heading size="3">Manage the file/s</b:Heading>
|
||||
<b:Label type="INFO">You can choose a section (e.g. "piante") and
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.gcube.portlets.user.geoportaldataentry.client.ui.edit;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -14,6 +15,9 @@ import org.gcube.application.geoportalcommon.shared.products.model.RelazioneScav
|
|||
import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.GeoPortalDataEntryApp;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.GeoportalDataEntryServiceAsync;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.DialogConfirm;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.DialogInform;
|
||||
import org.gcube.portlets.widgets.mpformbuilder.client.form.MetaDataField;
|
||||
import org.gcube.portlets.widgets.mpformbuilder.client.ui.metadata.MetaDataFieldSkeleton;
|
||||
import org.gcube.portlets.widgets.mpformbuilder.client.ui.upload.DialogUpload;
|
||||
|
@ -30,11 +34,13 @@ import com.github.gwtbootstrap.client.ui.ListBox;
|
|||
import com.github.gwtbootstrap.client.ui.constants.IconType;
|
||||
import com.github.gwtbootstrap.client.ui.constants.LabelType;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.dom.client.Document;
|
||||
import com.google.gwt.dom.client.Style.Unit;
|
||||
import com.google.gwt.event.dom.client.ChangeEvent;
|
||||
import com.google.gwt.event.dom.client.ChangeHandler;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.event.dom.client.DomEvent;
|
||||
import com.google.gwt.event.shared.HandlerManager;
|
||||
import com.google.gwt.uibinder.client.UiBinder;
|
||||
import com.google.gwt.uibinder.client.UiField;
|
||||
|
@ -104,6 +110,7 @@ public class UpdateFileset extends Composite {
|
|||
|
||||
private Map<Integer, WorkspaceContentDV> mapForCCUploading = null;
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new update fileset.
|
||||
*
|
||||
|
@ -175,6 +182,71 @@ public class UpdateFileset extends Composite {
|
|||
GWT.log("Content index selected: " + pathIndex);
|
||||
GWT.log("FileUploaded selected: " + gdb.getFilesUploaded());
|
||||
|
||||
List<WorkspaceContentDV> listCurrentContent = new ArrayList<WorkspaceContentDV>();
|
||||
if (mapForCCUploading != null) {
|
||||
Collection<WorkspaceContentDV> currentContent = mapForCCUploading.values();
|
||||
if (currentContent != null)
|
||||
listCurrentContent.addAll(currentContent);
|
||||
}
|
||||
|
||||
String htmlMsg = "Going to update the section " + listBoxPaths.getSelectedItemText() + ":";
|
||||
htmlMsg += "<ul>";
|
||||
htmlMsg += "<li>keeping " + listCurrentContent.size() + " current file/s </li>";
|
||||
htmlMsg += "<li>uploading " + listFilesUploaded.size() + " new file/s </li>";
|
||||
htmlMsg += "</ul>";
|
||||
htmlMsg += "<br>";
|
||||
htmlMsg += "This operation cannot be undone. Would you like to proceed?";
|
||||
|
||||
GWT.log(htmlMsg);
|
||||
|
||||
final DialogConfirm dialogConfirm = new DialogConfirm(null, "Update Confirm?", htmlMsg);
|
||||
dialogConfirm.getElement().getStyle().setZIndex(100000);
|
||||
dialogConfirm.getYesButton().addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
dialogConfirm.hide();
|
||||
buttonUpdate.setEnabled(false);
|
||||
|
||||
final DialogInform dialogInf = new DialogInform(null, "Updating Project", "");
|
||||
dialogInf.setZIndex(100000);
|
||||
dialogInf.showLoader("updating file/s for project: "+fullConcessione.getNome());
|
||||
//dialogInf.setWidth("400px");
|
||||
dialogInf.center();
|
||||
|
||||
GeoportalDataEntryServiceAsync.Util.getInstance().updateSectionForRecord(
|
||||
fullConcessione.getItemId(), fullConcessione.getRecordType(),
|
||||
listBoxPaths.getSelectedItemText(), pathIndex, listCurrentContent, gdb,
|
||||
new AsyncCallback<ConcessioneDV>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
dialogInf.hideLoader();
|
||||
dialogInf.setMsg(
|
||||
"Sorry error occurred during project update. Error reported: "
|
||||
+ caught.getMessage());
|
||||
buttonUpdate.setEnabled(true);
|
||||
showUploadFileGUI();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(ConcessioneDV result) {
|
||||
dialogInf.hideLoader();
|
||||
dialogInf.setText("Project updated!");
|
||||
dialogInf.setMsg(result.getNome() + " updated correclty");
|
||||
dialogInf.center();
|
||||
fullConcessione = result;
|
||||
buttonUpdate.setEnabled(true);
|
||||
showUploadFileGUI();
|
||||
|
||||
}
|
||||
});
|
||||
dialogInf.center();
|
||||
}
|
||||
});
|
||||
dialogConfirm.center();
|
||||
|
||||
} else {
|
||||
Window.alert(errorMsg);
|
||||
}
|
||||
|
@ -265,10 +337,11 @@ public class UpdateFileset extends Composite {
|
|||
|
||||
controlsContent.add(listBoxContentIndex);
|
||||
|
||||
if (listBoxContentIndex.getItemCount() == 2) {
|
||||
// listBoxContentIndex.setSelectedIndex(1);
|
||||
listBoxContentIndex.setSelectedValue(listBoxContentIndex.getItemText(1));
|
||||
|
||||
if(listBoxContentIndex.getItemCount()==1) {
|
||||
listBoxContentIndex.setSelectedIndex(0);
|
||||
listBoxContentIndex.setSelectedValue(listBoxContentIndex.getItemText(0));
|
||||
DomEvent.fireNativeEvent(Document.get().createChangeEvent(), listBoxContentIndex);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -360,7 +433,7 @@ public class UpdateFileset extends Composite {
|
|||
|
||||
MetadataFieldWrapper uploadField = new MetadataFieldWrapper();
|
||||
uploadField.setFieldName("File");
|
||||
uploadField.setMandatory(true);
|
||||
uploadField.setMandatory(false);
|
||||
uploadField.setType(DataTypeWrapper.File);
|
||||
uploadField.setMaxOccurs(1000);
|
||||
|
||||
|
|
|
@ -3,9 +3,6 @@
|
|||
*/
|
||||
package org.gcube.portlets.user.geoportaldataentry.client.ui.utils;
|
||||
|
||||
|
||||
|
||||
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.resource.Images;
|
||||
|
||||
import com.google.gwt.dom.client.Style.Unit;
|
||||
|
@ -22,12 +19,10 @@ import com.google.gwt.user.client.ui.Image;
|
|||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
|
||||
|
||||
/**
|
||||
* The Class DialogConfirm.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Feb 19, 2015
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Feb 19, 2015
|
||||
*/
|
||||
public class DialogConfirm extends DialogBox implements ClickHandler {
|
||||
|
||||
|
@ -37,6 +32,7 @@ public class DialogConfirm extends DialogBox implements ClickHandler {
|
|||
private ImageResource loading = Images.ICONS.loading();
|
||||
private HorizontalPanel hpButtons = new HorizontalPanel();
|
||||
private Button noButton;
|
||||
|
||||
/**
|
||||
* Instantiates a new dialog confirm.
|
||||
*
|
||||
|
@ -81,7 +77,6 @@ public class DialogConfirm extends DialogBox implements ClickHandler {
|
|||
|
||||
dock.add(vpContainer, DockPanel.CENTER);
|
||||
setWidget(dock);
|
||||
// add(dock);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -104,7 +99,8 @@ public class DialogConfirm extends DialogBox implements ClickHandler {
|
|||
public void loader(String message) {
|
||||
try {
|
||||
dock.remove(hpButtons);
|
||||
}catch(Exception e){}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
vpContainer.clear();
|
||||
HorizontalPanel hpMask = new HorizontalPanel();
|
||||
hpMask.add(new Image(loading));
|
||||
|
|
|
@ -0,0 +1,172 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.geoportaldataentry.client.ui.utils;
|
||||
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.resource.Images;
|
||||
|
||||
import com.google.gwt.dom.client.Style.Unit;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.resources.client.ImageResource;
|
||||
import com.google.gwt.user.client.ui.Button;
|
||||
import com.google.gwt.user.client.ui.DialogBox;
|
||||
import com.google.gwt.user.client.ui.DockPanel;
|
||||
import com.google.gwt.user.client.ui.HTML;
|
||||
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
|
||||
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||
import com.google.gwt.user.client.ui.Image;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
|
||||
/**
|
||||
* The Class DialogInform.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Oct 5, 2021
|
||||
*/
|
||||
public class DialogInform extends DialogBox implements ClickHandler {
|
||||
|
||||
private DockPanel dock = new DockPanel();
|
||||
private Button okButton;
|
||||
private VerticalPanel vpContainer = new VerticalPanel();
|
||||
private ImageResource loading = Images.ICONS.loading();
|
||||
private HorizontalPanel hpButtons = new HorizontalPanel();
|
||||
private HorizontalPanel hpMask = new HorizontalPanel();
|
||||
private DialogInform instance = this;
|
||||
|
||||
/**
|
||||
* Instantiates a new dialog inform.
|
||||
*
|
||||
* @param img the img
|
||||
* @param caption the caption
|
||||
* @param msg the msg
|
||||
*/
|
||||
public DialogInform(Image img, String caption, String msg) {
|
||||
// getElement().setClassName("gwt-DialogBoxNew");
|
||||
dock.setSpacing(4);
|
||||
dock.setWidth("100%");
|
||||
setText(caption);
|
||||
// setHeading(caption);
|
||||
|
||||
okButton = new Button("OK");
|
||||
|
||||
vpContainer.getElement().getStyle().setMargin(20.0, Unit.PX);
|
||||
vpContainer.add(new HTML(msg));
|
||||
hpButtons = new HorizontalPanel();
|
||||
hpButtons.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
|
||||
// hpButtons.getElement().getStyle().setMarginTop(20.0, Unit.PX);
|
||||
hpButtons.setSpacing(3);
|
||||
okButton.getElement().getStyle().setMarginRight(20.0, Unit.PX);
|
||||
hpButtons.add(okButton);
|
||||
|
||||
okButton.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
instance.hide();
|
||||
}
|
||||
});
|
||||
|
||||
dock.add(hpButtons, DockPanel.SOUTH);
|
||||
dock.setCellHorizontalAlignment(hpButtons, DockPanel.ALIGN_CENTER);
|
||||
|
||||
if (img != null)
|
||||
dock.add(img, DockPanel.WEST);
|
||||
|
||||
vpContainer.add(hpMask);
|
||||
dock.add(vpContainer, DockPanel.CENTER);
|
||||
setWidget(dock);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the msg.
|
||||
*
|
||||
* @param msg the new msg
|
||||
*/
|
||||
public void setMsg(String msg) {
|
||||
vpContainer.clear();
|
||||
vpContainer.add(new HTML(msg));
|
||||
hpButtons.setVisible(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* On click.
|
||||
*
|
||||
* @param event the event
|
||||
*/
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.google.gwt.event.dom.client.ClickHandler#onClick(com.google.gwt.event
|
||||
* .dom.client.ClickEvent)
|
||||
*/
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
// hide();
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide loader.
|
||||
*/
|
||||
public void hideLoader() {
|
||||
hpMask.clear();
|
||||
hpButtons.setVisible(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loader.
|
||||
*
|
||||
* @param message the message
|
||||
*/
|
||||
public void showLoader(String message) {
|
||||
try {
|
||||
hpButtons.setVisible(false);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
hpMask.clear();
|
||||
hpMask.add(new Image(loading));
|
||||
HTML html = new HTML(message);
|
||||
html.getElement().getStyle().setMarginLeft(5, Unit.PX);
|
||||
hpMask.add(html);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the to center panel.
|
||||
*
|
||||
* @param w the w
|
||||
*/
|
||||
public void addToCenterPanel(Widget w) {
|
||||
vpContainer.add(w);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the dock.
|
||||
*
|
||||
* @return the dock
|
||||
*/
|
||||
public DockPanel getDock() {
|
||||
return dock;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the yes button.
|
||||
*
|
||||
* @return the yes button
|
||||
*/
|
||||
public Button getOKButton() {
|
||||
return okButton;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the z index.
|
||||
*
|
||||
* @param value the new z index
|
||||
*/
|
||||
public void setZIndex(int value) {
|
||||
this.getElement().getStyle().setZIndex(value);
|
||||
}
|
||||
|
||||
}
|
|
@ -22,6 +22,7 @@ import org.gcube.application.geoportalcommon.GeoportalCommon;
|
|||
import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile;
|
||||
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
|
||||
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.content.WorkspaceContentDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.model.ValidationReportDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.paths.FileSetPathsDV;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConcessioniFormCardTitle;
|
||||
|
@ -650,7 +651,6 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the JSON record.
|
||||
*
|
||||
|
@ -684,7 +684,6 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the record.
|
||||
*
|
||||
|
@ -735,30 +734,49 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
|||
* Update record.
|
||||
*
|
||||
* @param itemId the item id
|
||||
* @param jsonUpdate the json update
|
||||
* @param recordType the record type
|
||||
* @param section the section
|
||||
* @param pathIndex the path index
|
||||
* @param keepCurrentContent the keep current content
|
||||
* @param gDBean the g D bean
|
||||
* @return the updated JSON string representing the itemId
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Override
|
||||
public ConcessioneDV updateSectionForRecord(String itemId, String recordType, String section, int pathIndex, GenericDatasetBean gDBean) throws Exception {
|
||||
LOG.info("updateSectionForRecord called with itemId: " + itemId + ", section: " + section+", pathIndex: " + pathIndex+", gDBean: " + gDBean, "");
|
||||
public ConcessioneDV updateSectionForRecord(String itemId, String recordType, String section, int pathIndex,
|
||||
List<WorkspaceContentDV> keepCurrentContent, GenericDatasetBean gDBean) throws Exception {
|
||||
LOG.info("updateSectionForRecord called with itemId: " + itemId + ", section: " + section + ", pathIndex: "
|
||||
+ pathIndex + ", gDBean: " + gDBean, "");
|
||||
try {
|
||||
|
||||
if (itemId == null)
|
||||
throw new Exception("Item id is null");
|
||||
|
||||
if (recordType.equals(RECORD_TYPE.CONCESSIONE)) {
|
||||
if (recordType.equalsIgnoreCase(RECORD_TYPE.CONCESSIONE.name())) {
|
||||
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
|
||||
MongoServiceUtil serviceUtil = new MongoServiceUtil();
|
||||
MongoConcessioni clientMongo = serviceUtil.getInstanceMongoConcessioni();
|
||||
|
||||
String toEditPath = null;
|
||||
AddSectionToConcessioneRequest request = null;
|
||||
List<TempFile> files = new ArrayList<TempFile>();
|
||||
|
||||
List<TempFile> files = serviceUtil.toTemFiles(gDBean.getFilesUploaded());
|
||||
if(files==null || files.isEmpty())
|
||||
throw new Exception("Sorry, an error occurred on reading temp files. Refresh and try again");
|
||||
// Managing files already present as current content and kept by user
|
||||
List<TempFile> keepFiles = serviceUtil.toTemFilesFromWSC(keepCurrentContent);
|
||||
if (keepFiles != null) {
|
||||
files.addAll(keepFiles);
|
||||
LOG.debug(keepFiles.size() +" current corrent file/s has/have been added to list of files");
|
||||
}
|
||||
|
||||
// Managing new files uploaded by user
|
||||
List<TempFile> newFiles = serviceUtil.toTemFiles(gDBean.getFilesUploaded());
|
||||
if (newFiles != null) {
|
||||
files.addAll(newFiles);
|
||||
LOG.debug(newFiles.size() +" new file/s has/have been added to list of files");
|
||||
}
|
||||
|
||||
// if (files == null || files.isEmpty())
|
||||
// throw new Exception("Sorry, an error occurred on reading temp files. Refresh and try again");
|
||||
|
||||
if (section.contains("abstract_relazione")) {
|
||||
|
||||
|
@ -775,32 +793,36 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
|||
|
||||
} else if (section.contains("posizionamentoScavo")) {
|
||||
toEditPath = Paths.POSIZIONAMENTO;
|
||||
request = new AddSectionToConcessioneRequest(toEditPath,
|
||||
files);
|
||||
request = new AddSectionToConcessioneRequest(toEditPath, files);
|
||||
|
||||
} else if (section.contains("piante")) {
|
||||
toEditPath = Paths.piantaByIndex(pathIndex);
|
||||
request = new AddSectionToConcessioneRequest(
|
||||
toEditPath, files);
|
||||
request = new AddSectionToConcessioneRequest(toEditPath, files);
|
||||
}
|
||||
// Unpublish
|
||||
System.out.println("Unpublishing "+itemId);
|
||||
LOG.info("Unpublishing " + itemId);
|
||||
clientMongo.unPublish(itemId);
|
||||
|
||||
// update Fileset
|
||||
System.out.println("Removing old fileset.. ");
|
||||
clientMongo.cleanFileSet(itemId,toEditPath);
|
||||
|
||||
System.out.println("Sending new Fileset ..");
|
||||
LOG.info("Removing old fileset.. ");
|
||||
Concessione concessione = clientMongo.cleanFileSet(itemId, toEditPath);
|
||||
|
||||
LOG.debug("Sending new Fileset ..");
|
||||
if(files.size()>0) {
|
||||
// StorageUtils storage=new StorageUtils();
|
||||
// Building TempFile
|
||||
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
|
||||
LOG.info("Registering FileSet into recordId " + itemId + " with request path: " +toEditPath + " and: " + files.size()
|
||||
+ " file/s");
|
||||
Concessione concessione = clientMongo.registerFileSet(itemId,request);
|
||||
LOG.info("Registering FileSet into recordId " + itemId + " with request path: " + toEditPath + " and: "
|
||||
+ files.size() + " file/s");
|
||||
concessione = clientMongo.registerFileSet(itemId, request);
|
||||
}else {
|
||||
LOG.info("Fileset is empty, skipping registerFileSet");
|
||||
}
|
||||
|
||||
LOG.info("Publishings itemId: "+itemId);
|
||||
concessione = clientMongo.publish(itemId);
|
||||
|
||||
LOG.trace("returning concessione: "+concessione);
|
||||
return ConvertToDataViewModel.toConcessione(concessione);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,9 @@ import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.mon
|
|||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
@ -14,12 +16,12 @@ import org.gcube.application.geoportal.common.rest.MongoConcessioni;
|
|||
import org.gcube.application.geoportal.common.rest.TempFile;
|
||||
import org.gcube.application.geoportal.common.utils.StorageUtils;
|
||||
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.content.WorkspaceContentDV;
|
||||
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||
import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploaded;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
/**
|
||||
* The Class MongoServiceUtil.
|
||||
*
|
||||
|
@ -87,6 +89,33 @@ public class MongoServiceUtil {
|
|||
return files;
|
||||
}
|
||||
|
||||
/**
|
||||
* To tem files from WSC.
|
||||
*
|
||||
* @param listFiles the list files
|
||||
* @return the list
|
||||
*/
|
||||
public List<TempFile> toTemFilesFromWSC(List<WorkspaceContentDV> listFiles) {
|
||||
LOG.debug("toTemFilesFromWSC called");
|
||||
if (listFiles == null || listFiles.isEmpty())
|
||||
return null;
|
||||
|
||||
// Building TempFile
|
||||
List<TempFile> files = new ArrayList<TempFile>(listFiles.size());
|
||||
for (WorkspaceContentDV fileUploaded : listFiles) {
|
||||
InputStream is;
|
||||
try {
|
||||
is = new URL(fileUploaded.getLink()).openStream();
|
||||
// Creating TempFile
|
||||
TempFile storageTempFile = createTempFileOnStorage(is, fileUploaded.getName());
|
||||
files.add(storageTempFile);
|
||||
} catch (IOException e) {
|
||||
LOG.error("Error on creating temp file from URL: " + fileUploaded.getLink(), e);
|
||||
}
|
||||
}
|
||||
return files;
|
||||
}
|
||||
|
||||
/**
|
||||
* To JSON.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue