Removed old uneeded code
This commit is contained in:
parent
d93000d280
commit
1e6fa8b9f6
10
pom.xml
10
pom.xml
|
@ -47,11 +47,11 @@
|
|||
<version>2.5.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>eu.trentorise.opendata</groupId>
|
||||
<artifactId>jackan</artifactId>
|
||||
<version>0.4.2</version>
|
||||
</dependency>
|
||||
<!-- <dependency> -->
|
||||
<!-- <groupId>eu.trentorise.opendata</groupId> -->
|
||||
<!-- <artifactId>jackan</artifactId> -->
|
||||
<!-- <version>0.4.2</version> -->
|
||||
<!-- </dependency> -->
|
||||
|
||||
<!-- smartgears -->
|
||||
<dependency>
|
||||
|
|
|
@ -10,6 +10,5 @@ public class CKanConnector extends ResourceConfig {
|
|||
public CKanConnector(){
|
||||
packages("org.gcube.data.access.ckanconnector");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -14,9 +14,6 @@ import javax.ws.rs.QueryParam;
|
|||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.NewCookie;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.Response.Status;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.gcube.common.authorization.library.provider.AuthorizationProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
|
@ -26,14 +23,7 @@ import org.python.core.PyObject;
|
|||
import org.python.core.PyString;
|
||||
import org.python.util.PythonInterpreter;
|
||||
|
||||
import eu.trentorise.opendata.jackan.CkanClient;
|
||||
import eu.trentorise.opendata.jackan.internal.org.apache.http.HttpResponse;
|
||||
import eu.trentorise.opendata.jackan.internal.org.apache.http.HttpStatus;
|
||||
import eu.trentorise.opendata.jackan.internal.org.apache.http.client.methods.HttpPost;
|
||||
import eu.trentorise.opendata.jackan.internal.org.apache.http.entity.StringEntity;
|
||||
import eu.trentorise.opendata.jackan.internal.org.apache.http.impl.client.CloseableHttpClient;
|
||||
import eu.trentorise.opendata.jackan.internal.org.apache.http.impl.client.HttpClientBuilder;
|
||||
import eu.trentorise.opendata.jackan.model.CkanUser;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Path("/")
|
||||
@Slf4j
|
||||
|
@ -93,7 +83,7 @@ public class ConnectorManager {
|
|||
int internalPort = Integer.parseInt(context.getInitParameter("internalPort"));
|
||||
String localhostName = "http://127.0.0.1:"+internalPort;
|
||||
long startCheckUser = System.currentTimeMillis();
|
||||
CkanClient ckanClient = new CkanClient(localhostName, ckanKey);
|
||||
// CkanClient ckanClient = new CkanClient(localhostName, ckanKey);
|
||||
|
||||
// try {
|
||||
// User user = new User();
|
||||
|
|
|
@ -1,28 +1,11 @@
|
|||
package org.gcube.data.access.ckanconnector;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.WebApplicationException;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.Response.Status;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.gcube.common.authorization.library.provider.AuthorizationProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import eu.trentorise.opendata.jackan.CkanClient;
|
||||
import eu.trentorise.opendata.jackan.exceptions.CkanNotFoundException;
|
||||
import eu.trentorise.opendata.jackan.model.CkanOrganization;
|
||||
|
||||
|
||||
@Path("organization")
|
||||
@Slf4j
|
||||
|
@ -30,58 +13,58 @@ public class OrganizationManager {
|
|||
|
||||
@Context ServletContext context;
|
||||
|
||||
@PUT
|
||||
@Path("/{name}")
|
||||
public Response create(@PathParam("name") String organizationName) {
|
||||
log.info("create called");
|
||||
try{
|
||||
|
||||
// This is done by smartgears
|
||||
// if (AuthorizationProvider.instance.get()==null || AuthorizationProvider.instance.get().getClient() == null ) return Response.status(Status.UNAUTHORIZED).build();
|
||||
|
||||
String ckanKey = context.getInitParameter("ckanKey");
|
||||
int internalPort = Integer.parseInt(context.getInitParameter("internalPort"));
|
||||
CkanClient ckanClient = new CkanClient("http://127.0.0.1:"+internalPort, ckanKey);
|
||||
|
||||
CkanOrganization org = new CkanOrganization(organizationName.replaceAll(" ", "_").replace(".", "_").toLowerCase());
|
||||
org.setDisplayName(organizationName);
|
||||
org.setTitle(organizationName);
|
||||
ckanClient.createOrganization(org);
|
||||
|
||||
log.info("create organizzation {} called from user {} in scope {}",organizationName, AuthorizationProvider.instance.get().getClient().getId(), ScopeProvider.instance.get());
|
||||
return Response.ok().build();
|
||||
}catch(Exception e){
|
||||
log.error("error trying to create organization "+organizationName,e);
|
||||
return Response.serverError().entity(e.getMessage()).build();
|
||||
}
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/{name}")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public String get(@PathParam("name") String organizationName) {
|
||||
log.info("get called with name {}", organizationName);
|
||||
|
||||
// This is done by smartgears
|
||||
// if (AuthorizationProvider.instance.get()==null || AuthorizationProvider.instance.get().getClient() == null ) throw new WebApplicationException("user authentication needed",Response.Status.UNAUTHORIZED);
|
||||
|
||||
String ckanKey = context.getInitParameter("ckanKey");
|
||||
int internalPort = Integer.parseInt(context.getInitParameter("internalPort"));
|
||||
|
||||
try{
|
||||
CkanClient ckanClient = new CkanClient("http://127.0.0.1:"+internalPort, ckanKey);
|
||||
CkanOrganization org = ckanClient.getOrganization(organizationName.replaceAll(" ", "_").replace(".", "_").toLowerCase());
|
||||
log.trace("organization {} found",organizationName);
|
||||
return new Gson().toJson(org);
|
||||
}catch(CkanNotFoundException e){
|
||||
log.error("organization {} doesn't exist",organizationName);
|
||||
throw new WebApplicationException("organization "+organizationName+" doesn't exist",Response.Status.NOT_FOUND);
|
||||
} catch (Exception e) {
|
||||
log.error("error trying to contect ckan",e);
|
||||
throw new WebApplicationException("error trying to contect ckan",Response.Status.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// @PUT
|
||||
// @Path("/{name}")
|
||||
// public Response create(@PathParam("name") String organizationName) {
|
||||
// log.info("create called");
|
||||
// try{
|
||||
//
|
||||
//// This is done by smartgears
|
||||
//// if (AuthorizationProvider.instance.get()==null || AuthorizationProvider.instance.get().getClient() == null ) return Response.status(Status.UNAUTHORIZED).build();
|
||||
//
|
||||
// String ckanKey = context.getInitParameter("ckanKey");
|
||||
// int internalPort = Integer.parseInt(context.getInitParameter("internalPort"));
|
||||
// CkanClient ckanClient = new CkanClient("http://127.0.0.1:"+internalPort, ckanKey);
|
||||
//
|
||||
// CkanOrganization org = new CkanOrganization(organizationName.replaceAll(" ", "_").replace(".", "_").toLowerCase());
|
||||
// org.setDisplayName(organizationName);
|
||||
// org.setTitle(organizationName);
|
||||
// ckanClient.createOrganization(org);
|
||||
//
|
||||
// log.info("create organizzation {} called from user {} in scope {}",organizationName, AuthorizationProvider.instance.get().getClient().getId(), ScopeProvider.instance.get());
|
||||
// return Response.ok().build();
|
||||
// }catch(Exception e){
|
||||
// log.error("error trying to create organization "+organizationName,e);
|
||||
// return Response.serverError().entity(e.getMessage()).build();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @GET
|
||||
// @Path("/{name}")
|
||||
// @Produces(MediaType.APPLICATION_JSON)
|
||||
// public String get(@PathParam("name") String organizationName) {
|
||||
// log.info("get called with name {}", organizationName);
|
||||
//
|
||||
//// This is done by smartgears
|
||||
//// if (AuthorizationProvider.instance.get()==null || AuthorizationProvider.instance.get().getClient() == null ) throw new WebApplicationException("user authentication needed",Response.Status.UNAUTHORIZED);
|
||||
//
|
||||
// String ckanKey = context.getInitParameter("ckanKey");
|
||||
// int internalPort = Integer.parseInt(context.getInitParameter("internalPort"));
|
||||
//
|
||||
// try{
|
||||
// CkanClient ckanClient = new CkanClient("http://127.0.0.1:"+internalPort, ckanKey);
|
||||
// CkanOrganization org = ckanClient.getOrganization(organizationName.replaceAll(" ", "_").replace(".", "_").toLowerCase());
|
||||
// log.trace("organization {} found",organizationName);
|
||||
// return new Gson().toJson(org);
|
||||
// }catch(CkanNotFoundException e){
|
||||
// log.error("organization {} doesn't exist",organizationName);
|
||||
// throw new WebApplicationException("organization "+organizationName+" doesn't exist",Response.Status.NOT_FOUND);
|
||||
// } catch (Exception e) {
|
||||
// log.error("error trying to contect ckan",e);
|
||||
// throw new WebApplicationException("error trying to contect ckan",Response.Status.INTERNAL_SERVER_ERROR);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue