Compare commits
1 Commits
feature/23
...
master
Author | SHA1 | Date |
---|---|---|
luca.frosini | 0b6dfd8123 |
|
@ -1 +1,2 @@
|
|||
target
|
||||
/.DS_Store
|
||||
|
|
|
@ -3,11 +3,6 @@
|
|||
All notable changes to this project will be documented in this file.
|
||||
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [v2.0.0-SNAPSHOT]
|
||||
|
||||
- Complete refactor of connector [#23454]
|
||||
- Changed groupId
|
||||
|
||||
## [v1.4.0]
|
||||
|
||||
- Removed old code which set the user role in ckan [#23310]
|
||||
|
|
|
@ -21,7 +21,6 @@ See [Releases](https://code-repo.d4science.org/gCubeSystem/ckan-connector/releas
|
|||
|
||||
## Authors
|
||||
|
||||
* **Luca Frosini** ([ORCID](https://orcid.org/0000-0003-3183-2291)) - [ISTI-CNR Infrascience Group](http://nemis.isti.cnr.it/groups/infrascience)
|
||||
* **Lucio Lelii** ([ISTI-CNR Infrascience Group](http://nemis.isti.cnr.it/groups/infrascience)
|
||||
|
||||
|
||||
|
|
13
pom.xml
13
pom.xml
|
@ -9,12 +9,12 @@
|
|||
<version>1.1.0</version>
|
||||
</parent>
|
||||
|
||||
<groupId>org.gcube.data-catalogue</groupId>
|
||||
<groupId>org.gcube.data.access</groupId>
|
||||
<artifactId>ckan-connector</artifactId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
<version>1.4.0</version>
|
||||
<packaging>war</packaging>
|
||||
<name>Ckan connector</name>
|
||||
<description>Ckan connector for automatic login</description>
|
||||
<name>ckan connector</name>
|
||||
<description>a ckan connector for automatic login</description>
|
||||
|
||||
<scm>
|
||||
<connection>scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}.git</connection>
|
||||
|
@ -23,9 +23,8 @@
|
|||
</scm>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<webappDirectory>${project.basedir}${file.separator}src${file.separator}main${file.separator}webapp${file.separator}WEB-INF</webappDirectory>
|
||||
<enunciate.version>2.14.0</enunciate.version>
|
||||
<webappDirectory>${project.basedir}/src/main/webapp/WEB-INF</webappDirectory>
|
||||
<distroDirectory>${project.basedir}/distro</distroDirectory>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
package org.gcube.ckanconnector;
|
||||
|
||||
import javax.ws.rs.ApplicationPath;
|
||||
|
||||
import org.gcube.ckanconnector.rest.ConnectorManager;
|
||||
import org.glassfish.jersey.server.ResourceConfig;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
* @author Lucio Lelii (ISTI - CNR)
|
||||
*/
|
||||
@ApplicationPath("/gcube/service/")
|
||||
public class CKanConnector extends ResourceConfig {
|
||||
|
||||
public CKanConnector(){
|
||||
packages(ConnectorManager.class.getPackage().toString());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package org.gcube.data.access.ckanconnector;
|
||||
|
||||
import javax.ws.rs.ApplicationPath;
|
||||
|
||||
import org.glassfish.jersey.server.ResourceConfig;
|
||||
|
||||
@ApplicationPath("/gcube/service/")
|
||||
public class CKanConnector extends ResourceConfig {
|
||||
|
||||
public CKanConnector(){
|
||||
packages("org.gcube.data.access.ckanconnector");
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package org.gcube.ckanconnector.rest;
|
||||
package org.gcube.data.access.ckanconnector;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
|
@ -15,7 +15,6 @@ import javax.ws.rs.core.Context;
|
|||
import javax.ws.rs.core.NewCookie;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import org.gcube.ckanconnector.utils.RandomString;
|
||||
import org.gcube.common.authorization.library.provider.AuthorizationProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.gcat.client.User;
|
||||
|
@ -23,22 +22,18 @@ import org.python.core.PyLong;
|
|||
import org.python.core.PyObject;
|
||||
import org.python.core.PyString;
|
||||
import org.python.util.PythonInterpreter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
* @author Lucio Lelii (ISTI - CNR)
|
||||
*/
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Path("/")
|
||||
@Slf4j
|
||||
public class ConnectorManager {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ConnectorManager.class);
|
||||
|
||||
@Context ServletContext context;
|
||||
|
||||
RandomString randomString = new RandomString(12);
|
||||
|
||||
|
||||
@Path("disconnect")
|
||||
@GET
|
||||
public Response disconnect(@Context HttpServletRequest req) {
|
|
@ -0,0 +1,70 @@
|
|||
package org.gcube.data.access.ckanconnector;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
|
||||
@Path("organization")
|
||||
@Slf4j
|
||||
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);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// }
|
||||
|
||||
}
|
|
@ -1,11 +1,7 @@
|
|||
package org.gcube.ckanconnector.utils;
|
||||
package org.gcube.data.access.ckanconnector;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
* @author Lucio Lelii (ISTI - CNR)
|
||||
*/
|
||||
public class RandomString {
|
||||
|
||||
private static final char[] symbols;
|
|
@ -6,7 +6,6 @@ import javax.net.ssl.HttpsURLConnection;
|
|||
import javax.ws.rs.core.Application;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import org.gcube.ckanconnector.rest.ConnectorManager;
|
||||
import org.glassfish.jersey.server.ResourceConfig;
|
||||
import org.glassfish.jersey.test.JerseyTest;
|
||||
import org.junit.Test;
|
||||
|
|
Loading…
Reference in New Issue