commit 32f3301dd19e67f5331b63a9fb91a196bde3ae70 Author: Cesare Date: Wed Oct 21 10:08:48 2020 +0200 first commit diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..c2913ce --- /dev/null +++ b/pom.xml @@ -0,0 +1,235 @@ + + 4.0.0 + eu.sshoc + citation + 0.0.2-SNAPSHOT + war + CitationService + The Citation Service of the SSHOC system + + true + 0.0.1-SNPSHOT + eu.sshoc.citation.service.CitationServiceStart + + + org.springframework.boot + spring-boot-starter-parent + 1.5.1.RELEASE + + + + + + + + com.rabbitmq + rabbitmq-client + 1.3.0 + + + junit + junit + 4.12 + test + + + org.springframework + spring-context-support + 4.1.6.RELEASE + + + + + org.springframework + spring-aop + 4.3.6.RELEASE + + + + springframework + spring-orm + 1.2.6 + + + javax.transaction + jta + 1.1 + + + + org.springframework.boot + spring-boot-starter-web + 1.5.1.RELEASE + + + + org.springframework.boot + spring-boot-starter-tomcat + provided + + + + org.springframework.boot + spring-boot-starter-thymeleaf + + + + + + io.springfox + springfox-swagger2 + 2.6.1 + + + + + io.springfox + springfox-data-rest + 2.6.1 + + + + io.springfox + springfox-bean-validators + 2.6.1 + + + io.springfox + springfox-swagger-ui + 2.6.1 + + + + org.springframework.boot + spring-boot-starter-activemq + + + log4j + log4j + 1.2.16 + + + org.springframework.boot + spring-boot-starter-data-mongodb + + + + org.springframework.boot + spring-boot-starter-test + test + + + + org.apache.curator + apache-curator + 3.3.0 + pom + + + org.apache.curator + curator-client + 3.3.0 + + + org.apache.curator + curator-framework + 3.3.0 + + + org.json + json + 20180130 + + + org.apache.maven.plugins + maven-shade-plugin + 3.1.0 + + + com.auth0 + java-jwt + 3.3.0 + + + + org.apache.curator + curator-x-discovery + 4.0.1 + + + + org.apache.curator + curator-x-async + 4.0.1 + + + org.apache.curator + curator-recipes + 4.0.1 + + + + + + data-local + data + file://${project.basedir}/repo + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + repackage + + + + + + + + + maven-war-plugin + + + false + + + true + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.1.0 + + + + + \ No newline at end of file diff --git a/src/main/java/eu/sshoc/citation/service/CitationContextListener.java b/src/main/java/eu/sshoc/citation/service/CitationContextListener.java new file mode 100644 index 0000000..b5edf3c --- /dev/null +++ b/src/main/java/eu/sshoc/citation/service/CitationContextListener.java @@ -0,0 +1,28 @@ +package eu.sshoc.citation.service; + +import javax.servlet.ServletContextEvent; +import javax.servlet.ServletContextListener; +import javax.servlet.annotation.WebListener; + +import org.springframework.context.annotation.Configuration; + +@Configuration +@WebListener +public class CitationContextListener implements ServletContextListener { + + @Override + + public void contextDestroyed(ServletContextEvent arg0) { + System.out.println("******************CitationService context stopping "); + + } + + @Override + + public void contextInitialized(ServletContextEvent arg0) { + System.out.println("******************CitationService context initialized " + this); + + } + + + } \ No newline at end of file diff --git a/src/main/java/eu/sshoc/citation/service/CitationServiceStart.java b/src/main/java/eu/sshoc/citation/service/CitationServiceStart.java new file mode 100644 index 0000000..16105a0 --- /dev/null +++ b/src/main/java/eu/sshoc/citation/service/CitationServiceStart.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2018 VRE4EIC Consortium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *******************************************************************************/ +package eu.sshoc.citation.service; + +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; +import org.springframework.boot.SpringApplication; + + + +//@Configuration +//@ComponentScan + +//@EnableAutoConfiguration +@SpringBootApplication +@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class}) + +public class CitationServiceStart { + + + /*private static AuthModule module; + private static MDModule MDmodule; +*/ + public static void main(String[] args) { + + //ZKServer.init(); + + + SpringApplication.run(CitationServiceStart.class, args); + + + + } +} diff --git a/src/main/java/eu/sshoc/citation/service/CitationServiceWAR.java b/src/main/java/eu/sshoc/citation/service/CitationServiceWAR.java new file mode 100644 index 0000000..784a126 --- /dev/null +++ b/src/main/java/eu/sshoc/citation/service/CitationServiceWAR.java @@ -0,0 +1,18 @@ + +package eu.sshoc.citation.service; + + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.boot.web.support.SpringBootServletInitializer; + +//@SpringBootApplication +public class CitationServiceWAR extends SpringBootServletInitializer { + + @Override + protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { + return application.sources(CitationServiceStart.class); + } + + +} diff --git a/src/main/java/eu/sshoc/citation/service/SwaggerConfig.java b/src/main/java/eu/sshoc/citation/service/SwaggerConfig.java new file mode 100644 index 0000000..2df6bdb --- /dev/null +++ b/src/main/java/eu/sshoc/citation/service/SwaggerConfig.java @@ -0,0 +1,80 @@ +package eu.sshoc.citation.service; + + + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.common.base.Predicate; + +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; +import static springfox.documentation.builders.PathSelectors.*; + +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; + + +import static com.google.common.base.Predicates.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@Configuration +//@SpringBootApplication +@EnableSwagger2 +//@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class}) +public class SwaggerConfig { + private Logger log = LoggerFactory.getLogger(this.getClass()); + @Bean + public Docket api() { + return new Docket(DocumentationType.SWAGGER_2) + .groupName("citationservice-api") + .apiInfo(apiInfo()) + .select() + //.apis(!(RequestHandlerSelectors.withClassAnnotation(JsonIgnore.class)) + .apis(RequestHandlerSelectors.any()) + //.paths(PathSelectors.any()) + //.paths(PathSelectors.regex("/user.*")) + .paths(paths()) + .build() + .pathMapping("/"); + } + + private Predicate paths() { + //return or(PathSelectors.regex("/wfservice.*"), + // PathSelectors.regex("/wfservice.*")); + return or(PathSelectors.regex("/citservice.*"), + PathSelectors.regex("/citharvester.*")); + } + private ApiInfo apiInfo() { + InputStream in; + Properties property = new Properties(); + try { + in = this.getClass().getClassLoader() + .getResourceAsStream("Settings.properties"); + property.load(in); + in.close(); + } catch (FileNotFoundException e) { + + log.error(e.getMessage()); + } catch (IOException e) { + log.error(e.getMessage()); + } + return new ApiInfoBuilder() + .title("SSHOC Citation Service") + .description("This page shows the Web Services entry points for the SSHOC Citation Service.") + .version(property.getProperty("Version_default")) + .termsOfServiceUrl("http://terms-of-services.sshoc") + .license("Apache License, Version 2.0") + .licenseUrl("https://www.apache.org/licenses/LICENSE-2.0") + .build(); + } +} \ No newline at end of file diff --git a/src/main/java/eu/sshoc/citation/service/TestGetCitation.java b/src/main/java/eu/sshoc/citation/service/TestGetCitation.java new file mode 100644 index 0000000..594be66 --- /dev/null +++ b/src/main/java/eu/sshoc/citation/service/TestGetCitation.java @@ -0,0 +1,13 @@ +package eu.sshoc.citation.service; + +import eu.sshoc.citation.service.wfconfigurator.impl.CitationHarvesterImpl; +public class TestGetCitation { + + public static void main(String[] args) { + CitationHarvesterImpl chi= new CitationHarvesterImpl(); + + chi.getCitation("test", "test", "test"); + + } + +} diff --git a/src/main/java/eu/sshoc/citation/service/services/CitationHarvester.java b/src/main/java/eu/sshoc/citation/service/services/CitationHarvester.java new file mode 100644 index 0000000..3628b16 --- /dev/null +++ b/src/main/java/eu/sshoc/citation/service/services/CitationHarvester.java @@ -0,0 +1,87 @@ +package eu.sshoc.citation.service.services; + + + +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.util.List; +import java.util.Properties; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import eu.sshoc.citation.service.wfconfigurator.impl.CitationHarvesterImpl; +import io.swagger.annotations.ApiOperation; + + + +/** + * + * @author Cesare + * + */ + +@RestController +public class CitationHarvester { + + Properties property = new Properties(); + CitationHarvesterImpl wfc= new CitationHarvesterImpl(); + public CitationHarvester() { + super(); + + /*InputStream in; + + try { + in = this.getClass().getClassLoader() + .getResourceAsStream("Settings.properties"); + property.load(in); + in.close(); + } catch (FileNotFoundException e) { + + } catch (IOException e) { + + }*/ + } + + @ApiOperation(value = "Returns a list of citations from specific citation source", + notes = "A client with a valid identifier can invoke this web service to obtain a list of citations from a specified source", + response = String.class) + @RequestMapping(value="/citharvester/getcitationlist", method=RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + public String getCitationList(@RequestParam(value="sourceid") String sourceid, @RequestParam(value="token") String token) { + + return wfc.getCitationList(sourceid, token); + } + + + @ApiOperation(value = "Retrieves the metadata of a citation via the API of the specified DOI Registration Agency", + notes = "A client with a valid identifier can invoke this web service to retrieve the citation metadata using the API provided by the DOI Registration Agency", + response = String.class) + @RequestMapping(value="/citharvester/getmetadataapi", method=RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + public String getCitation(@RequestParam(value="doira") String sourceid, @RequestParam(value="pid") String pid, @RequestParam(value="token") String token) { + + return wfc.getCitation(sourceid, pid, token).toString(); + } + + @ApiOperation(value = "Returns a metadata of a citation via Content Negotiated requests", + notes = "A client with a valid identifier can invoke this web service to to retrieve the citation metadata using DOI content negotiated requests", + response = String.class) + @RequestMapping(value="/citharvester/getmetadatacn", method=RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + public String getCitationMD(@RequestParam(value="pid") String pid, @RequestParam(value="token") String token) { + + return wfc.getCitationMetadata(pid, token).toString(); + } + + @ApiOperation(value = "Returns formatted citation using via content negotiated request", + notes = "A client with a valid identifier can invoke this web service to obtain a formatted citation, the text/bibliography content type is used ", + response = String.class) + @RequestMapping(value="/citharvester/getformcit", method=RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + public String getCitationCSL(@RequestParam(value="pid") String pid, @RequestParam(value="token") String token) { + + return wfc.getCitationCSL(pid, token).toString(); + } + +} diff --git a/src/main/java/eu/sshoc/citation/service/services/CitationService.java b/src/main/java/eu/sshoc/citation/service/services/CitationService.java new file mode 100644 index 0000000..012ebe6 --- /dev/null +++ b/src/main/java/eu/sshoc/citation/service/services/CitationService.java @@ -0,0 +1,103 @@ +/******************************************************************************* + * Copyright (c) 2018 VRE4EIC Consortium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *******************************************************************************/ + +package eu.sshoc.citation.service.services; + + + +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.util.List; +import java.util.Properties; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import eu.sshoc.citation.service.wfconfigurator.impl.CitationServiceImpl; +import io.swagger.annotations.ApiOperation; + + + +/** + * + * @author Cesare + * + */ + +@RestController +public class CitationService { + + Properties property = new Properties(); + CitationServiceImpl wfc= new CitationServiceImpl(); + public CitationService() { + super(); + + /*InputStream in; + + try { + in = this.getClass().getClassLoader() + .getResourceAsStream("Settings.properties"); + property.load(in); + in.close(); + } catch (FileNotFoundException e) { + + } catch (IOException e) { + + }*/ + } + + @ApiOperation(value = "Returns a list of citations", + notes = "A client with a valid identifier can invoke this web service to obtain a list of citations stored in SSHOC citation repository", + response = String.class) + @RequestMapping(value="/citservice/getcitation", method=RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + public String getServiceDescriptions(@RequestParam(value="sshocid") String sshocid, @RequestParam(value="token") String token) { + + return wfc.getServiceDescriptions(sshocid, token); + } + + @ApiOperation(value = "Search for citation", + notes = "A client with a valid identifier can invoke this web service to search the SSHOC repository for citations", + response = String.class) + @RequestMapping(value="/citservice/searchcitation", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + public String searchServiceDescriptions(@RequestParam(value="sshocid") String sshocid, @RequestParam(value="query") String query, @RequestParam(value="token") String token){ + + return null; + } + + @ApiOperation(value = "Save a citation", + notes = "A client with a valid identifier can invoke this web service to save the citation in the SSHOC repository", + response = String.class) + @RequestMapping(value="/citservice/savecitation", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + public String saveCitations(@RequestParam(value="sshocid") String sshocid, @RequestParam(value="description") String description, @RequestParam(value="token") String token){ + + + return wfc.saveCitations(sshocid, description, token); + } + @ApiOperation(value = "Search for citations ", + notes = "A client with a valid identifier can invoke this web service to search the SSHOC repository for citations", + response = String.class) + @RequestMapping(value="/citservice/searchcite", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + public String searchWfDescriptions(@RequestParam(value="sshocid") String sshocid, @RequestParam(value="query") String query, @RequestParam(value="token") String token){ + + return wfc.getCitations(sshocid, query, token); + } + + +} diff --git a/src/main/java/eu/sshoc/citation/service/services/CitationServiceController.java b/src/main/java/eu/sshoc/citation/service/services/CitationServiceController.java new file mode 100644 index 0000000..774d4c9 --- /dev/null +++ b/src/main/java/eu/sshoc/citation/service/services/CitationServiceController.java @@ -0,0 +1,80 @@ +/******************************************************************************* + * Copyright (c) 2018 VRE4EIC Consortium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *******************************************************************************/ + +package eu.sshoc.citation.service.services; + + + +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.util.List; +import java.util.Properties; + +import javax.servlet.http.HttpSession; + +import org.springframework.http.MediaType; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + + +import io.swagger.annotations.ApiOperation; + + + +/** + * This class contains methods for managing users. + * @author Cesare + * + */ + +@Controller +public class CitationServiceController { + + private static final String RELEASE = "release"; + private static final String WELCOME_PAGE = "welcome"; + Properties property = new Properties(); + public CitationServiceController() { + super(); + + InputStream in; + + try { + in = this.getClass().getClassLoader() + .getResourceAsStream("Settings.properties"); + property.load(in); + in.close(); + } catch (FileNotFoundException e) { + + } catch (IOException e) { + + } + } + + //@JsonIgnore + @RequestMapping(value="/", method=RequestMethod.GET) + public String WelcomePage(ModelMap model, HttpSession session) { + + session.setAttribute(RELEASE, property.getProperty("Version_default")); + + return WELCOME_PAGE; + } + +} diff --git a/src/main/java/eu/sshoc/citation/service/wfconfigurator/impl/CitationHarvesterImpl.java b/src/main/java/eu/sshoc/citation/service/wfconfigurator/impl/CitationHarvesterImpl.java new file mode 100644 index 0000000..c7f3083 --- /dev/null +++ b/src/main/java/eu/sshoc/citation/service/wfconfigurator/impl/CitationHarvesterImpl.java @@ -0,0 +1,133 @@ +package eu.sshoc.citation.service.wfconfigurator.impl; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.ProtocolException; +import java.net.URL; +import java.net.URLEncoder; +import java.nio.charset.Charset; + +import javax.net.ssl.HttpsURLConnection; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + + + +public class CitationHarvesterImpl { + + + public CitationHarvesterImpl(){ + + + } + + private static String readAll(Reader rd) throws IOException { + StringBuilder sb = new StringBuilder(); + int cp; + while ((cp = rd.read()) != -1) { + sb.append((char) cp); + } + return sb.toString(); + } + + public static JSONObject readJsonFromUrl(String url) throws IOException, JSONException { + InputStream is = new URL(url).openStream(); + try { + BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8"))); + String jsonText = readAll(rd); + JSONObject json = new JSONObject(jsonText); + return json; + } finally { + is.close(); + } + } + private static String getStandardCitation(String citurl) throws IOException{ + URL myURL = new URL(citurl); + HttpURLConnection myURLConnection = (HttpURLConnection)myURL.openConnection(); + myURLConnection.setRequestProperty("Accept", "text/x-bibliography; style=harvard3; locale=fr-FR"); + InputStream mis = myURLConnection.getInputStream(); + BufferedReader rd = new BufferedReader(new InputStreamReader(mis, Charset.forName("UTF-8"))); + return (readAll(rd)); + + } + public String getCitationList(String id, String token){ + return null; + } + + public JSONObject getCitation(String id, String pid, String token){ + JSONObject jsondata=null; + try { + String sid="10.1007/s11082-018-1327-1"; + if (pid!=null && pid.trim()!="" && !pid.trim().equalsIgnoreCase("test")) + sid=pid.trim(); + + jsondata = readJsonFromUrl("https://api.test.datacite.org/dois/"+sid); + System.out.println(jsondata.toString()); + // System.out.println(json.get("id")); + } catch (IOException | JSONException e) { + + e.printStackTrace(); + } + + return jsondata; + } + public JSONObject getCitationMetadata(String pid, String token){ + JSONObject jsondata=null; + try { + String sid="10.1007/s11082-018-1327-1"; + if (pid!=null && pid.trim()!="" && !pid.trim().equalsIgnoreCase("test")) + sid=pid.trim(); + URL myURL = new URL("https://doi.org/"+sid); + HttpURLConnection myURLConnection = (HttpURLConnection)myURL.openConnection(); + myURLConnection.setRequestProperty("Accept", "application/rdf+xml;q=0.5, application/vnd.citationstyles.csl+json;q=1.0"); + InputStream mis = myURLConnection.getInputStream(); + BufferedReader rd = new BufferedReader(new InputStreamReader(mis, Charset.forName("UTF-8"))); + String jsonText = readAll(rd); + jsondata = new JSONObject(jsonText); + System.out.println(jsondata.toString()); + //JSONObject jsoncit = new JSONObject(); + //jsondata.put("citation", getStandardCitation("https://doi.org/"+sid)); + + } catch (Exception e) { + + e.printStackTrace(); + } + + return jsondata; + } + + public JSONObject getCitationCSL(String pid, String token){ + String jsonText=""; + JSONObject jsondata=null; + try { + String sid="10.1007/s11082-018-1327-1"; //10.1126/science.169.3946.635 + if (pid!=null && pid.trim()!="" && !pid.trim().equalsIgnoreCase("test")) + sid=pid.trim(); + URL myURL = new URL("https://doi.org/"+sid); + //URL myURL = new URL("https://doi.org/10.1126/science.169.3946.635"); + HttpURLConnection myURLConnection = (HttpURLConnection)myURL.openConnection(); + myURLConnection.setRequestProperty("Accept", "text/x-bibliography; style=harvard3; locale=en-EN"); + InputStream mis = myURLConnection.getInputStream(); + BufferedReader rd = new BufferedReader(new InputStreamReader(mis, Charset.forName("UTF-8"))); + jsonText = readAll(rd); + + System.out.println(jsonText); + jsondata = new JSONObject(); + jsondata.put("citation", jsonText); + + } catch (Exception e) { + + e.printStackTrace(); + } + + return jsondata; + } + +} diff --git a/src/main/java/eu/sshoc/citation/service/wfconfigurator/impl/CitationServiceImpl.java b/src/main/java/eu/sshoc/citation/service/wfconfigurator/impl/CitationServiceImpl.java new file mode 100644 index 0000000..37b377f --- /dev/null +++ b/src/main/java/eu/sshoc/citation/service/wfconfigurator/impl/CitationServiceImpl.java @@ -0,0 +1,38 @@ +package eu.sshoc.citation.service.wfconfigurator.impl; + +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.ProtocolException; +import java.net.URL; +import java.net.URLEncoder; + +import javax.net.ssl.HttpsURLConnection; + +import org.json.JSONArray; +import org.json.JSONObject; + + + +public class CitationServiceImpl { + + + public CitationServiceImpl(){ + + + } + + public String getServiceDescriptions(String id, String token){ + return null; + } + + public String saveCitations(String userId, String citation, String token){ + return null; + } + public String getCitations(String userId, String query, String token){ + return null; + } + +} diff --git a/src/main/java/eu/sshoc/citation/service/wfconfigurator/impl/MDListener.javazzi b/src/main/java/eu/sshoc/citation/service/wfconfigurator/impl/MDListener.javazzi new file mode 100644 index 0000000..b8f714a --- /dev/null +++ b/src/main/java/eu/sshoc/citation/service/wfconfigurator/impl/MDListener.javazzi @@ -0,0 +1,61 @@ +/******************************************************************************* + * Copyright (c) 2018 VRE4EIC Consortium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *******************************************************************************/ +package eu.sshoc.citation.service.wfconfigurator.impl; + +import java.time.LocalDateTime; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import eu.vre4eic.evre.core.messages.AuthenticationMessage; +import eu.vre4eic.evre.core.messages.MetadataMessage; +import eu.vre4eic.evre.nodeservice.modules.metadata.MDModule; +import eu.vre4eic.evre.core.comm.MessageListener; + +/** + * + * Class used to receive asynchronous messages related to users authenticated by the system. + * The authentication message can represent Login or Logout operations and contains token which must be used by users for each service invocation. + * @author francesco + * + */ +public class MDListener implements MessageListener{ + + private MDModule module; + private Logger log = LoggerFactory.getLogger(this.getClass()); + + public MDListener(MDModule mdModule) { + this.module = mdModule; + } + + /* (non-Javadoc) + * @see javax.jms.MessageListener#onMessage(javax.jms.Message) + */ + @Override + public void onMessage(MetadataMessage message) { + + log.info("##### metadata message arrived #####"); + //log.info("token: " + am.getToken()); + //log.info("time limit: "+ am.getTimeLimit()); + + log.info(message.getToken()+" "+message.getMessage()); + + + } + + + +} diff --git a/src/main/resources/META-INF/spring/app-context.xml b/src/main/resources/META-INF/spring/app-context.xml new file mode 100644 index 0000000..32768ac --- /dev/null +++ b/src/main/resources/META-INF/spring/app-context.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/NodeService-0.0.3-SNAPSHOT.jar b/src/main/resources/NodeService-0.0.3-SNAPSHOT.jar new file mode 100644 index 0000000..da48487 Binary files /dev/null and b/src/main/resources/NodeService-0.0.3-SNAPSHOT.jar differ diff --git a/src/main/resources/Settings.properties b/src/main/resources/Settings.properties new file mode 100644 index 0000000..7df6e9c --- /dev/null +++ b/src/main/resources/Settings.properties @@ -0,0 +1,31 @@ +# Orchestra Repository Settings + +ZooKeeper_default=localhost:2181 + +Version_path=/evre/settings/version +Version_default=0.0.1 + + +TokenTimeout_path=/evre/settings/authentication/token_timeout +TokenTimeout_default=60 + +TokenSecret_path=/evre/services/authentication/token_secret + +CodeTimeout_path=/evre/settings/authentication/code_timeout +CodeTimeout_default=60 + +MessageBroker_path=/evre/services/MessageBroker/URL +MessageBroker_default=tcp://v4e-lab.isti.cnr.it:61616 + + +ProfileStorage_path=/evre/services/ProfileStorage/URL +ProfileStorage_default=127.0.0.1 + +ProfileStoragePort_path=/evre/services/ProfileStorage/Port +ProfileStoragePort_default=27017 + +AAAI_login=/evre/services/ProfileStorage/login +AAAI_login_default=user_test + +AAAI_pwd=/evre/services/ProfileStorage/pwd +AAAI_pwd_default=pwd_test \ No newline at end of file diff --git a/src/main/resources/templates/logo.png b/src/main/resources/templates/logo.png new file mode 100644 index 0000000..57fb00b Binary files /dev/null and b/src/main/resources/templates/logo.png differ diff --git a/src/main/resources/templates/main_index.html b/src/main/resources/templates/main_index.html new file mode 100644 index 0000000..3911340 --- /dev/null +++ b/src/main/resources/templates/main_index.html @@ -0,0 +1,36 @@ + + + + e-VRE + + + + + + +
+
+

Welcome to e-VRE system.

+

The following e-VRE services are available: +

+

+

+
+
+ + + + diff --git a/src/main/resources/templates/welcome.html b/src/main/resources/templates/welcome.html new file mode 100644 index 0000000..78daefa --- /dev/null +++ b/src/main/resources/templates/welcome.html @@ -0,0 +1,29 @@ + + + + SSHOC: Citation Service description page + + + + + +
+

Welcome to SSHOC Citation Service (release )

+

+

+

+ The Web Services API documentation

+

The Citation Viewer example

+ + + +
+ + + +