Get File from Url
This commit is contained in:
parent
fdd5c4845c
commit
00536fc8b4
|
@ -11,10 +11,11 @@ import org.gcube.application.geoportal.common.faults.InvalidRequestException;
|
|||
public class TempFile {
|
||||
|
||||
private String id;
|
||||
private String url;
|
||||
private String filename;
|
||||
|
||||
public void validate()throws InvalidRequestException {
|
||||
if(id==null || id.isEmpty()) throw new InvalidRequestException("Invalid temp file "+this+" : ID null or empty");
|
||||
if((id==null || id.isEmpty() )&&(url==null||url.isEmpty())) throw new InvalidRequestException("Invalid temp file "+this+" : ID null or empty and no url defined");
|
||||
if(filename==null || filename.isEmpty()) throw new InvalidRequestException("Invalid temp file "+this+" : filename null or empty");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -792,7 +792,11 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
|
|||
InputStream is=null;
|
||||
try{
|
||||
log.debug("Opening temp file {}",f);
|
||||
String fileUrl=storage.getURL(f.getId());
|
||||
String fileUrl=null;
|
||||
if(f.getId()==null||f.getId().isEmpty())
|
||||
fileUrl=f.getUrl();
|
||||
else fileUrl=storage.getURL(f.getId());
|
||||
|
||||
log.debug("Got URL {} from ID {}",fileUrl,f.getId());
|
||||
is=new URL(fileUrl).openStream();
|
||||
RegisteredFile registered=ws.registerFile(new WorkspaceManager.FileOptions(f.getFilename(),is,
|
||||
|
|
|
@ -62,16 +62,16 @@ public class DummyProjectTest extends AbstractProfiledDocumentsTests{
|
|||
public void testUploadFileSet() throws Exception {
|
||||
assumeTrue(GCubeTest.isTestInfrastructureEnabled());
|
||||
Document baseDoc=new Document();
|
||||
baseDoc.put("relazioneScavo",new Document("title","My Title"));
|
||||
baseDoc.put("section",new Document("title","My Title"));
|
||||
|
||||
Project doc = createNew(baseDoc);
|
||||
assertTrue(doc.getTheDocument().containsKey("relazioneScavo"));
|
||||
assertTrue(doc.getTheDocument().containsKey("section"));
|
||||
|
||||
|
||||
// Try set releazione scavo
|
||||
String parentPath="relazioneScavo";
|
||||
String parentPath="section";
|
||||
String fieldName="fileset";
|
||||
String fieldDefinition="relazioneScavo."+Field.CHILDREN+"[?(@.fileset)]";
|
||||
String fieldDefinition="section."+Field.CHILDREN+"[?(@.fileset)]";
|
||||
|
||||
String filename = "relazione.pdf";
|
||||
|
||||
|
|
Loading…
Reference in New Issue