improved code
This commit is contained in:
parent
6d00320353
commit
6fad1ba8d1
|
@ -64,7 +64,7 @@ public class CKANResource extends CKAN {
|
|||
/* TODO Remove this code ASAP. It requires a function from Storage HUB */
|
||||
private static final String URI_RESOLVER_STORAGE_HUB_HOST_PROD = "data.d4science.org";
|
||||
private static final String URI_RESOLVER_STORAGE_HUB_HOST_PRE = "data-pre.d4science.org";
|
||||
private static final String URI_RESOLVER_STORAGE_HUB_HOST_DEV = "data-d.d4science.org";
|
||||
private static final String URI_RESOLVER_STORAGE_HUB_HOST_DEV = "data.dev.d4science.org";
|
||||
|
||||
public static final String URI_RESOLVER_STORAGE_HUB_HOST;
|
||||
public static final String URI_RESOLVER_STORAGE_HUB_PATH = "/shub/";
|
||||
|
|
|
@ -2,7 +2,6 @@ package org.gcube.gcat.workspace;
|
|||
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.text.ParseException;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.common.gxhttp.request.GXHTTPStringRequest;
|
||||
|
@ -36,8 +35,8 @@ public class CatalogueStorageHubManagement {
|
|||
this.storageHubManagement = new StorageHubManagement();
|
||||
}
|
||||
|
||||
protected String getOriginalFileName(HttpURLConnection httpURLConnection) throws ParseException {
|
||||
String contentDisposition = httpURLConnection.getHeaderFields().get("content-disposition").get(0);
|
||||
protected String getOriginalFileName(HttpURLConnection httpURLConnection) throws Exception {
|
||||
String contentDisposition = httpURLConnection.getHeaderField("Content-Disposition");
|
||||
contentDisposition = contentDisposition.replaceAll("= ", "=").replaceAll(" =", "=");
|
||||
ContentDisposition formDataContentDisposition = new ContentDisposition(contentDisposition);
|
||||
return formDataContentDisposition.getFileName();
|
||||
|
@ -60,6 +59,9 @@ public class CatalogueStorageHubManagement {
|
|||
metadata);
|
||||
mimeType = storageHubManagement.getMimeType();
|
||||
return persistedURL;
|
||||
} catch (Exception e) {
|
||||
logger.error("Error while trying to persists the resource", e);
|
||||
throw e;
|
||||
} finally {
|
||||
applicationMode.end();
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.gcube.gcat.ContextTest;
|
|||
import org.gcube.gcat.utils.Constants;
|
||||
import org.gcube.storagehub.ApplicationMode;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -46,9 +47,11 @@ public class CKANResourceTest extends ContextTest {
|
|||
applicationMode.end();
|
||||
}
|
||||
|
||||
// @Test
|
||||
@Ignore
|
||||
@Test
|
||||
public void testCopyStorageResource() throws Exception {
|
||||
URL url = new URL("https://goo.gl/HcUWni");
|
||||
// ContextTest.setContextByName("/d4science.research-infrastructures.eu/D4Research/AGINFRAplusDev");
|
||||
URL url = new URL("https://data.d4science.net/gS9k");
|
||||
|
||||
String itemID = UUID.randomUUID().toString();
|
||||
CKANResource ckanResource = new CKANResource(itemID);
|
||||
|
@ -58,6 +61,7 @@ public class CKANResourceTest extends ContextTest {
|
|||
ckanResource.deleteStorageResource(finalURL, ckanResource.resourceID, ckanResource.mimeType);
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testCreate() throws Exception {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
|
Loading…
Reference in New Issue