|
|
|
@ -17,7 +17,6 @@ import javax.ws.rs.InternalServerErrorException;
|
|
|
|
|
import javax.ws.rs.NotAllowedException;
|
|
|
|
|
import javax.ws.rs.WebApplicationException;
|
|
|
|
|
import javax.ws.rs.core.MultivaluedMap;
|
|
|
|
|
import javax.ws.rs.core.UriInfo;
|
|
|
|
|
|
|
|
|
|
import org.apache.http.MethodNotSupportedException;
|
|
|
|
|
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
|
|
|
@ -169,7 +168,8 @@ public class CKANPackage extends CKAN implements Moderated {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected CKANOrganization checkGotOrganization(String gotOrganization) throws ForbiddenException {
|
|
|
|
|
//protected CKANOrganization checkGotOrganization(String gotOrganization) throws ForbiddenException {
|
|
|
|
|
protected void checkGotOrganization(String gotOrganization) throws ForbiddenException {
|
|
|
|
|
if(!configuration.getSupportedOrganizations().contains(gotOrganization)) {
|
|
|
|
|
String error = String.format(
|
|
|
|
|
"IS Configuration does not allow to publish in %s organizations. Allowed organization are: %s",
|
|
|
|
@ -177,13 +177,20 @@ public class CKANPackage extends CKAN implements Moderated {
|
|
|
|
|
throw new ForbiddenException(error);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CKANOrganization ckanOrganization = new CKANOrganization();
|
|
|
|
|
ckanOrganization.setName(gotOrganization);
|
|
|
|
|
ckanOrganization.read();
|
|
|
|
|
/*
|
|
|
|
|
* It seem not needed. Add a cache if we want this check
|
|
|
|
|
*
|
|
|
|
|
* CKANOrganization ckanOrganization = new CKANOrganization();
|
|
|
|
|
* ckanOrganization.setName(gotOrganization);
|
|
|
|
|
* ckanOrganization.read();
|
|
|
|
|
*
|
|
|
|
|
* return ckanOrganization;
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
return ckanOrganization;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
protected CKANOrganization getPublishingOrganization(ObjectNode objectNode) throws ForbiddenException {
|
|
|
|
|
CKANOrganization ckanOrganization = null;
|
|
|
|
|
if(objectNode.has(OWNER_ORG_KEY)) {
|
|
|
|
@ -200,6 +207,18 @@ public class CKANPackage extends CKAN implements Moderated {
|
|
|
|
|
|
|
|
|
|
return ckanOrganization;
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
protected void getPublishingOrganization(ObjectNode objectNode) throws ForbiddenException {
|
|
|
|
|
if(objectNode.has(OWNER_ORG_KEY)) {
|
|
|
|
|
String gotOrganizationName = objectNode.get(OWNER_ORG_KEY).asText();
|
|
|
|
|
checkGotOrganization(gotOrganizationName);
|
|
|
|
|
}else {
|
|
|
|
|
String organizationFromContext = configuration.getDefaultOrganization();
|
|
|
|
|
checkGotOrganization(organizationFromContext);
|
|
|
|
|
objectNode.put(OWNER_ORG_KEY, organizationFromContext);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ObjectNode checkBaseInformation(String json) throws Exception {
|
|
|
|
|
return checkBaseInformation(json, false);
|
|
|
|
@ -631,6 +650,7 @@ public class CKANPackage extends CKAN implements Moderated {
|
|
|
|
|
* I need to investigate better this part.
|
|
|
|
|
*
|
|
|
|
|
int i=1;
|
|
|
|
|
stringWriter.append("(");
|
|
|
|
|
for(String organizationName : configuration.getSupportedOrganizations()) {
|
|
|
|
|
stringWriter.append(String.format(GCatConstants.ORGANIZATION_FILTER_TEMPLATE, organizationName));
|
|
|
|
|
if(i!=configuration.getSupportedOrganizations().size()) {
|
|
|
|
@ -640,6 +660,7 @@ public class CKANPackage extends CKAN implements Moderated {
|
|
|
|
|
}
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
stringWriter.append(")");
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
return stringWriter.toString();
|
|
|
|
|