Merge branch 'master' of gitlab.eudat.eu:dmp/OpenAIRE-EUDAT-DMP-service-pilot

This commit is contained in:
annampak 2017-10-04 16:32:27 +03:00
commit c34f99cb0e
29 changed files with 1010 additions and 161 deletions

View File

@ -6,10 +6,13 @@ import java.util.UUID;
import dao.Dao;
import entities.DMP;
import entities.Organisation;
import entities.responses.IDLabelPair;
public interface DMPDao extends Dao<DMP, UUID> {
public List<UUID> listAllIDs();
List<IDLabelPair> listAllIDsLabels();

View File

@ -2,11 +2,15 @@ package dao.entities;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
import javax.persistence.TypedQuery;
import org.hibernate.query.Query;
import dao.JpaDao;
import entities.DMP;
import entities.responses.IDLabelPair;
public class DMPDaoImpl extends JpaDao<DMP, UUID> implements DMPDao {
@ -22,5 +26,16 @@ public class DMPDaoImpl extends JpaDao<DMP, UUID> implements DMPDao {
return typedQuery.getResultList();
}
@Override
public List<IDLabelPair> listAllIDsLabels() {
String queryString = "SELECT dmp.id, dmp.label FROM DMP dmp";
Query query = (Query) entityManager.createQuery(queryString);
List<Object[]> rows = query.list();
return rows.stream().map(row -> {
return new IDLabelPair(row[0].toString(), row[1].toString());
})
.collect(Collectors.toList());
}
}

View File

@ -1,10 +1,16 @@
package dao.entities;
import java.util.List;
import java.util.UUID;
import dao.Dao;
import entities.DMPProfile;
import entities.responses.IDLabelPair;
public interface DMPProfileDao extends Dao<DMPProfile, UUID> {
List<UUID> listAllIDs();
List<IDLabelPair> listAllIDsLabels();
}

View File

@ -1,17 +1,41 @@
package dao.entities;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
import javax.persistence.TypedQuery;
import org.hibernate.query.Query;
import dao.JpaDao;
import entities.DMPProfile;
import entities.responses.IDLabelPair;
public class DMPProfileDaoImpl extends JpaDao<DMPProfile, UUID> implements DMPProfileDao {
public DMPProfile loadDetails(DMPProfile t) {
// TODO Auto-generated method stub
return null;
}
@Override
public List<UUID> listAllIDs() {
String queryString = "SELECT dmpProfile.id FROM DMPProfile dmpProfile";
TypedQuery<UUID> typedQuery = entityManager.createQuery(queryString, UUID.class);
return typedQuery.getResultList();
}
@Override
public List<IDLabelPair> listAllIDsLabels() {
String queryString = "SELECT dmpProfile.id, dmpProfile.label FROM DMPProfile dmpProfile";
Query query = (Query) entityManager.createQuery(queryString);
List<Object[]> rows = query.list();
return rows.stream().map(row -> {
return new IDLabelPair(row[0].toString(), row[1].toString());
})
.collect(Collectors.toList());
}
}

View File

@ -1,10 +1,16 @@
package dao.entities;
import java.util.List;
import java.util.UUID;
import dao.Dao;
import entities.DataRepository;
import entities.responses.IDLabelPair;
public interface DataRepositoryDao extends Dao<DataRepository, UUID> {
List<UUID> listAllIDs();
List<IDLabelPair> listAllIDsLabels();
}

View File

@ -1,10 +1,16 @@
package dao.entities;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
import javax.persistence.TypedQuery;
import org.hibernate.query.Query;
import dao.JpaDao;
import entities.DataRepository;
import entities.responses.IDLabelPair;
public class DataRepositoryDaoImpl extends JpaDao<DataRepository, UUID> implements DataRepositoryDao {
@ -13,5 +19,24 @@ public class DataRepositoryDaoImpl extends JpaDao<DataRepository, UUID> implemen
return null;
}
@Override
public List<UUID> listAllIDs() {
String queryString = "SELECT dataRepository.id FROM DataRepository dataRepository";
TypedQuery<UUID> typedQuery = entityManager.createQuery(queryString, UUID.class);
return typedQuery.getResultList();
}
@Override
public List<IDLabelPair> listAllIDsLabels() {
String queryString = "SELECT dataRepository.id, dataRepository.label FROM DataRepository dataRepository";
Query query = (Query) entityManager.createQuery(queryString);
List<Object[]> rows = query.list();
return rows.stream().map(row -> {
return new IDLabelPair(row[0].toString(), row[1].toString());
})
.collect(Collectors.toList());
}
}

View File

@ -5,10 +5,13 @@ import java.util.UUID;
import dao.Dao;
import entities.Dataset;
import entities.responses.IDLabelPair;
public interface DatasetDao extends Dao<Dataset, UUID> {
public List<UUID> listAllIDs();
List<IDLabelPair> listAllIDsLabels();
}

View File

@ -2,12 +2,16 @@ package dao.entities;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
import javax.persistence.TypedQuery;
import javax.transaction.Transactional;
import org.hibernate.query.Query;
import dao.JpaDao;
import entities.Dataset;
import entities.responses.IDLabelPair;
public class DatasetDaoImpl extends JpaDao<Dataset, UUID> implements DatasetDao {
@ -22,5 +26,17 @@ public class DatasetDaoImpl extends JpaDao<Dataset, UUID> implements DatasetDao
TypedQuery<UUID> typedQuery = entityManager.createQuery(queryString, UUID.class);
return typedQuery.getResultList();
}
@Override
public List<IDLabelPair> listAllIDsLabels() {
String queryString = "SELECT dataset.id, dataset.label FROM Dataset dataset";
Query query = (Query) entityManager.createQuery(queryString);
List<Object[]> rows = query.list();
return rows.stream().map(row -> {
return new IDLabelPair(row[0].toString(), row[1].toString());
})
.collect(Collectors.toList());
}
}

View File

@ -1,11 +1,16 @@
package dao.entities;
import java.util.List;
import java.util.UUID;
import dao.Dao;
import entities.Organisation;
import entities.responses.IDLabelPair;
public interface OrganisationDao extends Dao<Organisation, UUID> {
public List<UUID> listAllIDs();
List<IDLabelPair> listAllIDsLabels();
}

View File

@ -1,13 +1,16 @@
package dao.entities;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
import javax.persistence.Query;
import javax.transaction.Transactional;
import javax.persistence.TypedQuery;
import org.hibernate.query.Query;
import dao.JpaDao;
import entities.Organisation;
import entities.responses.IDLabelPair;
public class OrganisationDaoImpl extends JpaDao<Organisation, UUID> implements OrganisationDao {
@ -15,6 +18,25 @@ public class OrganisationDaoImpl extends JpaDao<Organisation, UUID> implements O
// TODO Auto-generated method stub
return null;
}
@Override
public List<UUID> listAllIDs() {
String queryString = "SELECT organisation.id FROM Organisation organisation";
TypedQuery<UUID> typedQuery = entityManager.createQuery(queryString, UUID.class);
return typedQuery.getResultList();
}
@Override
public List<IDLabelPair> listAllIDsLabels() {
String queryString = "SELECT organisation.id, organisation.label FROM Organisation organisation";
Query query = (Query) entityManager.createQuery(queryString);
List<Object[]> rows = query.list();
return rows.stream().map(row -> {
return new IDLabelPair(row[0].toString(), row[1].toString());
})
.collect(Collectors.toList());
}
}

View File

@ -5,9 +5,12 @@ import java.util.UUID;
import dao.Dao;
import entities.Project;
import entities.responses.IDLabelPair;
public interface ProjectDao extends Dao<Project, UUID> {
public List<UUID> listAllIDs();
public List<IDLabelPair> listAllIDsLabels();
}

View File

@ -2,11 +2,15 @@ package dao.entities;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
import javax.persistence.TypedQuery;
import org.hibernate.query.Query;
import dao.JpaDao;
import entities.Project;
import entities.responses.IDLabelPair;
public class ProjectDaoImpl extends JpaDao<Project, UUID> implements ProjectDao {
@ -22,5 +26,17 @@ public class ProjectDaoImpl extends JpaDao<Project, UUID> implements ProjectDao
return typedQuery.getResultList();
}
@Override
public List<IDLabelPair> listAllIDsLabels() {
String queryString = "SELECT project.id, project.label FROM Project project";
Query query = (Query) entityManager.createQuery(queryString);
List<Object[]> rows = query.list();
return rows.stream().map(row -> {
return new IDLabelPair(row[0].toString(), row[1].toString());
})
.collect(Collectors.toList());
}
}

View File

@ -1,10 +1,16 @@
package dao.entities;
import java.util.List;
import java.util.UUID;
import dao.Dao;
import entities.Registry;
import entities.responses.IDLabelPair;
public interface RegistryDao extends Dao<Registry, UUID> {
List<UUID> listAllIDs();
List<IDLabelPair> listAllIDsLabels();
}

View File

@ -1,10 +1,16 @@
package dao.entities;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
import javax.persistence.TypedQuery;
import org.hibernate.query.Query;
import dao.JpaDao;
import entities.Registry;
import entities.responses.IDLabelPair;
public class RegistryDaoImpl extends JpaDao<Registry, UUID> implements RegistryDao {
@ -13,5 +19,24 @@ public class RegistryDaoImpl extends JpaDao<Registry, UUID> implements RegistryD
return null;
}
@Override
public List<UUID> listAllIDs() {
String queryString = "SELECT registry.id FROM Registry registry";
TypedQuery<UUID> typedQuery = entityManager.createQuery(queryString, UUID.class);
return typedQuery.getResultList();
}
@Override
public List<IDLabelPair> listAllIDsLabels() {
String queryString = "SELECT registry.id, registry.label FROM Registry registry";
Query query = (Query) entityManager.createQuery(queryString);
List<Object[]> rows = query.list();
return rows.stream().map(row -> {
return new IDLabelPair(row[0].toString(), row[1].toString());
})
.collect(Collectors.toList());
}
}

View File

@ -1,10 +1,16 @@
package dao.entities;
import java.util.List;
import java.util.UUID;
import dao.Dao;
import entities.Researcher;
import entities.responses.IDLabelPair;
public interface ResearcherDao extends Dao<Researcher, UUID> {
List<UUID> listAllIDs();
List<IDLabelPair> listAllIDsLabels();
}

View File

@ -1,10 +1,16 @@
package dao.entities;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
import javax.persistence.TypedQuery;
import org.hibernate.query.Query;
import dao.JpaDao;
import entities.Researcher;
import entities.responses.IDLabelPair;
public class ResearcherDaoImpl extends JpaDao<Researcher, UUID> implements ResearcherDao {
@ -14,4 +20,24 @@ public class ResearcherDaoImpl extends JpaDao<Researcher, UUID> implements Resea
}
@Override
public List<UUID> listAllIDs() {
String queryString = "SELECT researcher.id FROM Researcher researcher";
TypedQuery<UUID> typedQuery = entityManager.createQuery(queryString, UUID.class);
return typedQuery.getResultList();
}
@Override
public List<IDLabelPair> listAllIDsLabels() {
String queryString = "SELECT researcher.id, researcher.label FROM Researcher researcher";
Query query = (Query) entityManager.createQuery(queryString);
List<Object[]> rows = query.list();
return rows.stream().map(row -> {
return new IDLabelPair(row[0].toString(), row[1].toString());
})
.collect(Collectors.toList());
}
}

View File

@ -1,10 +1,16 @@
package dao.entities;
import java.util.List;
import java.util.UUID;
import dao.Dao;
import entities.Service;
import entities.responses.IDLabelPair;
public interface ServiceDao extends Dao<Service, UUID> {
List<UUID> listAllIDs();
List<IDLabelPair> listAllIDsLabels();
}

View File

@ -1,10 +1,16 @@
package dao.entities;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
import javax.persistence.TypedQuery;
import org.hibernate.query.Query;
import dao.JpaDao;
import entities.Service;
import entities.responses.IDLabelPair;
public class ServiceDaoImpl extends JpaDao<Service, UUID> implements ServiceDao {
@ -13,5 +19,24 @@ public class ServiceDaoImpl extends JpaDao<Service, UUID> implements ServiceDao
return null;
}
@Override
public List<UUID> listAllIDs() {
String queryString = "SELECT service.id FROM Service service";
TypedQuery<UUID> typedQuery = entityManager.createQuery(queryString, UUID.class);
return typedQuery.getResultList();
}
@Override
public List<IDLabelPair> listAllIDsLabels() {
String queryString = "SELECT service.id, service.label FROM Service service";
Query query = (Query) entityManager.createQuery(queryString);
List<Object[]> rows = query.list();
return rows.stream().map(row -> {
return new IDLabelPair(row[0].toString(), row[1].toString());
})
.collect(Collectors.toList());
}
}

View File

@ -46,7 +46,7 @@ public class Dataset implements Serializable {
@OneToOne(fetch = FetchType.EAGER, cascade=CascadeType.ALL)
// @Cascade(value=org.hibernate.annotations.CascadeType.ALL)
@JoinColumn(name = "\"DMP\"", nullable = false)
@JoinColumn(name = "\"DMP\"", nullable = true)
private DMP dmp;
@ -59,8 +59,8 @@ public class Dataset implements Serializable {
@OneToOne(fetch = FetchType.EAGER, cascade=CascadeType.ALL)
@Cascade(value=org.hibernate.annotations.CascadeType.ALL)
@JoinColumn(name = "\"Profile\"", nullable = false)
//@Cascade(value=org.hibernate.annotations.CascadeType.ALL)
@JoinColumn(name = "\"Profile\"", nullable = true)
private DatasetProfile profile;

View File

@ -44,18 +44,18 @@ public class DatasetProfile implements Serializable {
@Column(name = "\"Label\"")
private String label;
@OneToOne(fetch = FetchType.EAGER, mappedBy = "profile", cascade = CascadeType.ALL)
@OneToOne(fetch = FetchType.EAGER, mappedBy = "profile")
private Dataset dataset;
@OneToOne(fetch = FetchType.EAGER, cascade=CascadeType.ALL)
@OneToOne(fetch = FetchType.EAGER)
// @Cascade(value=org.hibernate.annotations.CascadeType.ALL)
@JoinColumn(name = "\"Ruleset\"", nullable = false)
@JoinColumn(name = "\"Ruleset\"", nullable = true)
private DatasetProfileRuleset ruleset;
@OneToOne(fetch = FetchType.EAGER, cascade=CascadeType.ALL)
@OneToOne(fetch = FetchType.EAGER)
// @Cascade(value=org.hibernate.annotations.CascadeType.ALL)
@JoinColumn(name = "\"Viewstyle\"", nullable = false)
@JoinColumn(name = "\"Viewstyle\"", nullable = true)
private DatasetProfileViewstyle viewstyle;
@ -113,6 +113,12 @@ public class DatasetProfile implements Serializable {
this.dataset = dataset;
}
@Override
public String toString() {
return "DatasetProfile [id=" + id + ", label=" + label + ", dataset=" + dataset + ", ruleset=" + ruleset
+ ", viewstyle=" + viewstyle + ", definition=" + definition + "]";
}
}

View File

@ -0,0 +1,43 @@
package entities.responses;
import java.io.Serializable;
import javax.persistence.Column;
public class IDLabelPair implements Serializable {
private static final long serialVersionUID = 4539082928100004914L;
@Column(name = "\"ID\"")
private String id;
@Column(name = "\"Label\"")
private String label;
public IDLabelPair(String id, String label) {
super();
this.id = id;
this.label = label;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
}

View File

@ -0,0 +1,32 @@
package responses;
public class RestResponse {
private String message;
private String objID;
public RestResponse(String message, String objID) {
super();
this.message = message;
this.objID = objID;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getObjID() {
return objID;
}
public void setObjID(String objID) {
this.objID = objID;
}
@Override
public String toString() {
return "{\"message\":\"" + message + "\", \"objID\":\"" + objID + "\"}";
}
}

View File

@ -14,9 +14,11 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
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.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import dao.entities.DMPDao;
@ -33,13 +35,17 @@ import dao.entities.ResearcherDao;
import dao.entities.ServiceDao;
import entities.DMP;
import entities.Dataset;
import entities.DatasetProfile;
import entities.DatasetProfileRuleset;
import entities.Project;
import entities.responses.IDLabelPair;
import helpers.Transformers;
import responses.RestResponse;
@RestController
@CrossOrigin
public class BackendInterface {
public class DMPs {
@Autowired private DataRepositoryDao dataRepositoryDao;
@Autowired private DatasetDao datasetDao;
@ -69,6 +75,17 @@ public class BackendInterface {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Serialization issue: "+ex.getMessage());
}
}
@RequestMapping(method = RequestMethod.GET, value = { "/listDMPLabelID" }, produces="text/plain")
public @ResponseBody ResponseEntity<Object> listDmpLabelID(){
try {
List<IDLabelPair> allIDLabels = dMPDao.listAllIDsLabels();
return ResponseEntity.status(HttpStatus.OK).body(new ObjectMapper().writeValueAsString(allIDLabels));
}
catch(Exception ex) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Serialization issue: "+ex.getMessage());
}
}
@RequestMapping(method = RequestMethod.GET, value = { "/DMP/{id}" }, produces="application/json")
@ -197,122 +214,5 @@ public class BackendInterface {
// FETCH BY DATASET(S)
@RequestMapping(method = RequestMethod.GET, value = { "/dataset" })
public @ResponseBody ResponseEntity<Object> listDatasets(){
try {
List<UUID> allIDs = datasetDao.listAllIDs();
return ResponseEntity.status(HttpStatus.OK).body(new ObjectMapper().writeValueAsString(allIDs));
}
catch(Exception ex) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Serialization issue: "+ex.getMessage());
}
}
@RequestMapping(method = RequestMethod.GET, value = { "/dataset/{id}" })
public @ResponseBody ResponseEntity<Object> getDataset(@PathVariable("id") String id) {
try {
Dataset ds = datasetDao.read(UUID.fromString(id));
return ResponseEntity.status(HttpStatus.OK).body(new ObjectMapper().writeValueAsString(ds));
}
catch(Exception ex) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Erroneous input: "+ex.getMessage());
}
}
/**
* This should be called on extreme cases. It's computationally intensive
*/
@RequestMapping(method = RequestMethod.GET, value = { "/getAllDatasets" })
public @ResponseBody ResponseEntity<Object> getAllDatasets(){
try {
List<Dataset> allDatasets = datasetDao.getAll();
return ResponseEntity.status(HttpStatus.OK).body(new ObjectMapper().writeValueAsString(allDatasets));
}
catch(Exception ex) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Serialization issue: "+ex.getMessage());
}
}
@RequestMapping(method = RequestMethod.POST, value = { "/setDataset" }, consumes = "application/json")
public @ResponseBody ResponseEntity<Object> setDataset(@RequestBody Dataset dataset) {
String reason = "";
Dataset storedDataset = null;
//try first to create
try {
storedDataset = datasetDao.create(dataset);
return ResponseEntity.status(HttpStatus.CREATED).body("Created Dataset with id: " + storedDataset.getId());
}
catch(Exception e) {
reason += e.getMessage();
//try updating
try {
storedDataset = datasetDao.update(dataset);
return ResponseEntity.status(HttpStatus.CREATED).body("Updated Dataset with id: " + storedDataset.getId());
}
catch(Exception ex) {
reason += (System.lineSeparator()+e.getMessage());
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Could not create or update Dataset! Reason: " + reason);
}
}
}
// FETCH BY PROJECT(S)
@RequestMapping(method = RequestMethod.GET, value = { "/project" })
public @ResponseBody ResponseEntity<Object> listProjects(){
try {
List<UUID> allIDs = projectDao.listAllIDs();
return ResponseEntity.status(HttpStatus.OK).body(new ObjectMapper().writeValueAsString(allIDs));
}
catch(Exception ex) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Serialization issue: "+ex.getMessage());
}
}
@RequestMapping(method = RequestMethod.GET, value = { "/project/{id}" })
public @ResponseBody ResponseEntity<Object> getProject(@PathVariable("id") String id) {
try {
Project project = projectDao.read(UUID.fromString(id));
return ResponseEntity.status(HttpStatus.OK).body(new ObjectMapper().writeValueAsString(project));
}
catch(Exception ex) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Erroneous input: "+ex.getMessage());
}
}
@RequestMapping(method = RequestMethod.POST, value = { "/setProject" }, consumes = "application/json")
public @ResponseBody ResponseEntity<Object> setProject(@RequestBody Project project) {
String reason = "";
Project storedProject = null;
//try first to create
try {
storedProject = projectDao.create(project);
return ResponseEntity.status(HttpStatus.CREATED).body("Created project with id: " + storedProject.getId());
}
catch(Exception e) {
reason += e.getMessage();
//try updating
try {
storedProject = projectDao.update(project);
return ResponseEntity.status(HttpStatus.CREATED).body("Updated project with id: " + storedProject.getId());
}
catch(Exception ex) {
reason += (System.lineSeparator()+e.getMessage());
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Could not create or update project! Reason: " + reason);
}
}
}
}

View File

@ -0,0 +1,231 @@
package rest;
import java.util.List;
import java.util.UUID;
import org.apache.commons.lang3.SerializationUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
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.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import dao.entities.DMPDao;
import dao.entities.DMPProfileDao;
import dao.entities.DataRepositoryDao;
import dao.entities.DatasetDao;
import dao.entities.DatasetProfileDao;
import dao.entities.DatasetProfileRulesetDao;
import dao.entities.DatasetProfileViewstyleDao;
import dao.entities.OrganisationDao;
import dao.entities.ProjectDao;
import dao.entities.RegistryDao;
import dao.entities.ResearcherDao;
import dao.entities.ServiceDao;
import entities.DMP;
import entities.Dataset;
import entities.DatasetProfile;
import entities.DatasetProfileRuleset;
import entities.Project;
import helpers.Transformers;
import responses.RestResponse;
@RestController
@CrossOrigin
public class Datasets {
@Autowired private DataRepositoryDao dataRepositoryDao;
@Autowired private DatasetDao datasetDao;
@Autowired private DatasetProfileDao datasetProfileDao;
@Autowired private DatasetProfileRulesetDao datasetProfileRulesetDao;
@Autowired private DatasetProfileViewstyleDao datasetProfileViewstyleDao;
@Autowired private DMPDao dMPDao;
@Autowired private DMPProfileDao dMPProfileDao;
@Autowired private OrganisationDao organisationDao;
@Autowired private ProjectDao projectDao;
@Autowired private RegistryDao registryDao;
@Autowired private ResearcherDao researcherDao;
@Autowired private ServiceDao serviceDao;
// FETCH BY DATASET(S)
@RequestMapping(method = RequestMethod.GET, value = { "/dataset" })
public @ResponseBody ResponseEntity<Object> listDatasets(){
try {
List<UUID> allIDs = datasetDao.listAllIDs();
return ResponseEntity.status(HttpStatus.OK).body(new ObjectMapper().writeValueAsString(allIDs));
}
catch(Exception ex) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Serialization issue: "+ex.getMessage());
}
}
@RequestMapping(method = RequestMethod.GET, value = { "/dataset/{id}" })
public @ResponseBody ResponseEntity<Object> getDataset(@PathVariable("id") String id) {
try {
Dataset ds = datasetDao.read(UUID.fromString(id));
return ResponseEntity.status(HttpStatus.OK).body(new ObjectMapper().writeValueAsString(ds));
}
catch(Exception ex) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Erroneous input: "+ex.getMessage());
}
}
/**
* This should be called on extreme cases. It's computationally intensive
*/
@RequestMapping(method = RequestMethod.GET, value = { "/getAllDatasets" })
public @ResponseBody ResponseEntity<Object> getAllDatasets(){
try {
List<Dataset> allDatasets = datasetDao.getAll();
return ResponseEntity.status(HttpStatus.OK).body(new ObjectMapper().writeValueAsString(allDatasets));
}
catch(Exception ex) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Serialization issue: "+ex.getMessage());
}
}
@RequestMapping(method = RequestMethod.POST, value = { "/setDataset" }, consumes = "application/json")
public @ResponseBody ResponseEntity<Object> setDataset(@RequestBody Dataset dataset) {
String reason = "";
Dataset storedDataset = null;
//try first to create
try {
storedDataset = datasetDao.create(dataset);
RestResponse rr = new RestResponse("Created dataset with id: "+storedDataset.toString(), storedDataset.getId().toString());
return ResponseEntity.status(HttpStatus.CREATED).body(rr.toString());
}
catch(Exception e) {
e.printStackTrace();
reason += e.getMessage();
//try updating
try {
storedDataset = datasetDao.update(dataset);
RestResponse rr = new RestResponse("Updated dataset with id: "+storedDataset.toString(), storedDataset.getId().toString());
return ResponseEntity.status(HttpStatus.CREATED).body(rr.toString());
}
catch(Exception ex) {
ex.printStackTrace();
reason += (System.lineSeparator()+e.getMessage());
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Could not create or update Dataset! Reason: " + reason);
}
}
}
@RequestMapping(method = RequestMethod.POST, value = { "/deleteDataset" }, consumes = "application/json")
public @ResponseBody ResponseEntity<Object> deleteDataset(@RequestBody Dataset dataset) {
//if we want to make sure it won't cascade up to other (child) components, we can just unhook them by setting them = new ones
// e.g: DMP dmp = new DMP() and then dataset.setDMP(dmp)
try {
datasetDao.delete(dataset);
RestResponse rr = new RestResponse("Deleted dataset with id: "+dataset.getId().toString(), dataset.getId().toString());
return ResponseEntity.status(HttpStatus.OK).body(rr.toString());
}
catch(Exception e) {
e.printStackTrace();
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Could not delete Dataset! Reason: " + e.getMessage());
}
}
/*
@RequestMapping(method = RequestMethod.GET, value = { "/createEmptyDataset" })
public @ResponseBody ResponseEntity<Object> createEmptyDataset() {
Dataset dataset = new Dataset();
dataset.setLabel("");
try {
dataset = datasetDao.create(dataset);
}
catch(Exception e) {
e.printStackTrace();
try {
dataset = datasetDao.update(dataset);
}
catch(Exception ex) {
ex.printStackTrace();
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("FAILED: reason: "+e.getMessage());
}
}
return ResponseEntity.status(HttpStatus.CREATED).body("Created Dataset with id: " + dataset.getId());
}
*/
//FETCH BY DATASET PROFILE
@RequestMapping(method = RequestMethod.GET, value = { "/datasetprofile/{id}" })
public @ResponseBody ResponseEntity<Object> getDatasetProfile(@PathVariable("id") String id) {
try {
DatasetProfile profile = datasetProfileDao.read(UUID.fromString(id));
return ResponseEntity.status(HttpStatus.OK).body(new ObjectMapper().writeValueAsString(profile));
}
catch(Exception ex) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Erroneous input: "+ex.getMessage());
}
}
@RequestMapping(method = RequestMethod.POST, value = { "/setDatasetProfile" }, consumes = "application/json")
public @ResponseBody ResponseEntity<Object> setDatasetProfile(@RequestBody DatasetProfile datasetProfile) {
String reason = "";
DatasetProfile storedDatasetProfile = null;
//try first to create
try {
storedDatasetProfile = datasetProfileDao.create(datasetProfile);
return ResponseEntity.status(HttpStatus.CREATED).body("Created DatasetProfile with id: " + storedDatasetProfile.getId());
}
catch(Exception e) {
reason += e.getMessage();
//try updating
try {
storedDatasetProfile = datasetProfileDao.update(datasetProfile);
return ResponseEntity.status(HttpStatus.CREATED).body("Updated DatasetProfile with id: " + storedDatasetProfile.getId());
}
catch(Exception ex) {
reason += (System.lineSeparator()+e.getMessage());
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Could not create or update DatasetProfile! Reason: " + reason);
}
}
}
@RequestMapping(method = RequestMethod.GET, value = { "/createEmptyDatasetProfile" })
public @ResponseBody ResponseEntity<Object> createEmptyDatasetProfile() {
DatasetProfile datasetProfile = new DatasetProfile();
datasetProfile.setLabel("");
datasetProfile.setDefinition("");
try {
datasetProfile = datasetProfileDao.create(datasetProfile);
}
catch(Exception e) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("FAILED: reason: "+e.getMessage());
}
return ResponseEntity.status(HttpStatus.CREATED).body("Created DatasetProfile with id: " + datasetProfile.getId());
}
}

View File

@ -0,0 +1,419 @@
package rest;
import java.util.List;
import java.util.UUID;
import org.apache.commons.lang3.SerializationUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
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.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import dao.entities.DMPDao;
import dao.entities.DMPProfileDao;
import dao.entities.DataRepositoryDao;
import dao.entities.DatasetDao;
import dao.entities.DatasetProfileDao;
import dao.entities.DatasetProfileRulesetDao;
import dao.entities.DatasetProfileViewstyleDao;
import dao.entities.OrganisationDao;
import dao.entities.ProjectDao;
import dao.entities.RegistryDao;
import dao.entities.ResearcherDao;
import dao.entities.ServiceDao;
import entities.DMP;
import entities.DMPProfile;
import entities.DataRepository;
import entities.Dataset;
import entities.DatasetProfile;
import entities.DatasetProfileRuleset;
import entities.Organisation;
import entities.Project;
import entities.Registry;
import entities.Researcher;
import entities.Service;
import helpers.Transformers;
import responses.RestResponse;
@RestController
@CrossOrigin
public class LoneTables {
@Autowired private DataRepositoryDao dataRepositoryDao;
@Autowired private DatasetDao datasetDao;
@Autowired private DatasetProfileDao datasetProfileDao;
@Autowired private DatasetProfileRulesetDao datasetProfileRulesetDao;
@Autowired private DatasetProfileViewstyleDao datasetProfileViewstyleDao;
@Autowired private DMPDao dMPDao;
@Autowired private DMPProfileDao dMPProfileDao;
@Autowired private OrganisationDao organisationDao;
@Autowired private ProjectDao projectDao;
@Autowired private RegistryDao registryDao;
@Autowired private ResearcherDao researcherDao;
@Autowired private ServiceDao serviceDao;
// MANAGE PROJECT(S)
@RequestMapping(method = RequestMethod.GET, value = { "/project" })
public @ResponseBody ResponseEntity<Object> listProjects(){
try {
List<UUID> allIDs = projectDao.listAllIDs();
return ResponseEntity.status(HttpStatus.OK).body(new ObjectMapper().writeValueAsString(allIDs));
}
catch(Exception ex) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Serialization issue: "+ex.getMessage());
}
}
@RequestMapping(method = RequestMethod.GET, value = { "/project/{id}" })
public @ResponseBody ResponseEntity<Object> getProject(@PathVariable("id") String id) {
try {
Project project = projectDao.read(UUID.fromString(id));
return ResponseEntity.status(HttpStatus.OK).body(new ObjectMapper().writeValueAsString(project));
}
catch(Exception ex) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Erroneous input: "+ex.getMessage());
}
}
@RequestMapping(method = RequestMethod.POST, value = { "/setProject" }, consumes = "application/json")
public @ResponseBody ResponseEntity<Object> setProject(@RequestBody Project project) {
String reason = "";
Project storedProject = null;
//try first to create
try {
storedProject = projectDao.create(project);
return ResponseEntity.status(HttpStatus.CREATED).body("Created project with id: " + storedProject.getId());
}
catch(Exception e) {
reason += e.getMessage();
//try updating
try {
storedProject = projectDao.update(project);
return ResponseEntity.status(HttpStatus.CREATED).body("Updated project with id: " + storedProject.getId());
}
catch(Exception ex) {
reason += (System.lineSeparator()+e.getMessage());
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Could not create or update project! Reason: " + reason);
}
}
}
// MANAGE ORGANISATIONS(S)
@RequestMapping(method = RequestMethod.GET, value = { "/organizations" })
public @ResponseBody ResponseEntity<Object> listOrganisations(){
try {
List<UUID> allIDs = organisationDao.listAllIDs();
return ResponseEntity.status(HttpStatus.OK).body(new ObjectMapper().writeValueAsString(allIDs));
}
catch(Exception ex) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Serialization issue: "+ex.getMessage());
}
}
@RequestMapping(method = RequestMethod.GET, value = { "/organizations/{id}" })
public @ResponseBody ResponseEntity<Object> getOrganisations(@PathVariable("id") String id) {
try {
Organisation organisation = organisationDao.read(UUID.fromString(id));
return ResponseEntity.status(HttpStatus.OK).body(new ObjectMapper().writeValueAsString(organisation));
}
catch(Exception ex) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Erroneous input: "+ex.getMessage());
}
}
@RequestMapping(method = RequestMethod.POST, value = { "/setOrganisation" }, consumes = "application/json")
public @ResponseBody ResponseEntity<Object> setOrganisation(@RequestBody Organisation organisation) {
String reason = "";
Organisation storedOrganisation = null;
//try first to create
try {
storedOrganisation = organisationDao.create(organisation);
return ResponseEntity.status(HttpStatus.CREATED).body("Created organisation with id: " + storedOrganisation.getId());
}
catch(Exception e) {
reason += e.getMessage();
//try updating
try {
storedOrganisation = organisationDao.update(organisation);
return ResponseEntity.status(HttpStatus.CREATED).body("Updated organisation with id: " + storedOrganisation.getId());
}
catch(Exception ex) {
reason += (System.lineSeparator()+e.getMessage());
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Could not create or update organisation! Reason: " + reason);
}
}
}
// MANAGE RESEARCHER(S)
@RequestMapping(method = RequestMethod.GET, value = { "/researchers" })
public @ResponseBody ResponseEntity<Object> listResearchers(){
try {
List<UUID> allIDs = researcherDao.listAllIDs();
return ResponseEntity.status(HttpStatus.OK).body(new ObjectMapper().writeValueAsString(allIDs));
}
catch(Exception ex) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Serialization issue: "+ex.getMessage());
}
}
@RequestMapping(method = RequestMethod.GET, value = { "/researchers/{id}" })
public @ResponseBody ResponseEntity<Object> getResearchers(@PathVariable("id") String id) {
try {
Researcher researcher = researcherDao.read(UUID.fromString(id));
return ResponseEntity.status(HttpStatus.OK).body(new ObjectMapper().writeValueAsString(researcher));
}
catch(Exception ex) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Erroneous input: "+ex.getMessage());
}
}
@RequestMapping(method = RequestMethod.POST, value = { "/setResearcher" }, consumes = "application/json")
public @ResponseBody ResponseEntity<Object> setResearcher(@RequestBody Researcher researcher) {
String reason = "";
Researcher storedResearcher = null;
//try first to create
try {
storedResearcher = researcherDao.create(researcher);
return ResponseEntity.status(HttpStatus.CREATED).body("Created researcher with id: " + storedResearcher.getId());
}
catch(Exception e) {
reason += e.getMessage();
//try updating
try {
storedResearcher = researcherDao.update(researcher);
return ResponseEntity.status(HttpStatus.CREATED).body("Updated researcher with id: " + storedResearcher.getId());
}
catch(Exception ex) {
reason += (System.lineSeparator()+e.getMessage());
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Could not create or update researcher! Reason: " + reason);
}
}
}
// MANAGE SERVICE(S)
@RequestMapping(method = RequestMethod.GET, value = { "/services" })
public @ResponseBody ResponseEntity<Object> listServices(){
try {
List<UUID> allIDs = serviceDao.listAllIDs();
return ResponseEntity.status(HttpStatus.OK).body(new ObjectMapper().writeValueAsString(allIDs));
}
catch(Exception ex) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Serialization issue: "+ex.getMessage());
}
}
@RequestMapping(method = RequestMethod.GET, value = { "/services/{id}" })
public @ResponseBody ResponseEntity<Object> getServices(@PathVariable("id") String id) {
try {
Service service = serviceDao.read(UUID.fromString(id));
return ResponseEntity.status(HttpStatus.OK).body(new ObjectMapper().writeValueAsString(service));
}
catch(Exception ex) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Erroneous input: "+ex.getMessage());
}
}
@RequestMapping(method = RequestMethod.POST, value = { "/setService" }, consumes = "application/json")
public @ResponseBody ResponseEntity<Object> setService(@RequestBody Service service) {
String reason = "";
Service storedService = null;
//try first to create
try {
storedService = serviceDao.create(service);
return ResponseEntity.status(HttpStatus.CREATED).body("Created service with id: " + storedService.getId());
}
catch(Exception e) {
reason += e.getMessage();
//try updating
try {
storedService = serviceDao.update(service);
return ResponseEntity.status(HttpStatus.CREATED).body("Updated service with id: " + storedService.getId());
}
catch(Exception ex) {
reason += (System.lineSeparator()+e.getMessage());
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Could not create or update service! Reason: " + reason);
}
}
}
// MANAGE REGISTRY(IES)
@RequestMapping(method = RequestMethod.GET, value = { "/registries" })
public @ResponseBody ResponseEntity<Object> listRegistries(){
try {
List<UUID> allIDs = registryDao.listAllIDs();
return ResponseEntity.status(HttpStatus.OK).body(new ObjectMapper().writeValueAsString(allIDs));
}
catch(Exception ex) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Serialization issue: "+ex.getMessage());
}
}
@RequestMapping(method = RequestMethod.GET, value = { "/registries/{id}" })
public @ResponseBody ResponseEntity<Object> getRegistries(@PathVariable("id") String id) {
try {
Registry registry = registryDao.read(UUID.fromString(id));
return ResponseEntity.status(HttpStatus.OK).body(new ObjectMapper().writeValueAsString(registry));
}
catch(Exception ex) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Erroneous input: "+ex.getMessage());
}
}
@RequestMapping(method = RequestMethod.POST, value = { "/setRegistry" }, consumes = "application/json")
public @ResponseBody ResponseEntity<Object> setRegistry(@RequestBody Registry registry) {
String reason = "";
Registry storedRegistry = null;
//try first to create
try {
storedRegistry = registryDao.create(registry);
return ResponseEntity.status(HttpStatus.CREATED).body("Created registry with id: " + storedRegistry.getId());
}
catch(Exception e) {
reason += e.getMessage();
//try updating
try {
storedRegistry = registryDao.update(registry);
return ResponseEntity.status(HttpStatus.CREATED).body("Updated registry with id: " + storedRegistry.getId());
}
catch(Exception ex) {
reason += (System.lineSeparator()+e.getMessage());
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Could not create or update registry! Reason: " + reason);
}
}
}
// MANAGE DATAREPOSITORy(IES)
@RequestMapping(method = RequestMethod.GET, value = { "/datarepositories" })
public @ResponseBody ResponseEntity<Object> listDataRepositories(){
try {
List<UUID> allIDs = dataRepositoryDao.listAllIDs();
return ResponseEntity.status(HttpStatus.OK).body(new ObjectMapper().writeValueAsString(allIDs));
}
catch(Exception ex) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Serialization issue: "+ex.getMessage());
}
}
@RequestMapping(method = RequestMethod.GET, value = { "/datarepositories/{id}" })
public @ResponseBody ResponseEntity<Object> getDataRepository(@PathVariable("id") String id) {
try {
DataRepository dataRepository = dataRepositoryDao.read(UUID.fromString(id));
return ResponseEntity.status(HttpStatus.OK).body(new ObjectMapper().writeValueAsString(dataRepository));
}
catch(Exception ex) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Erroneous input: "+ex.getMessage());
}
}
@RequestMapping(method = RequestMethod.POST, value = { "/setDataRepository" }, consumes = "application/json")
public @ResponseBody ResponseEntity<Object> setDataRepository(@RequestBody DataRepository dataRepository) {
String reason = "";
DataRepository storedDataRepository = null;
//try first to create
try {
storedDataRepository = dataRepositoryDao.create(dataRepository);
return ResponseEntity.status(HttpStatus.CREATED).body("Created dataRepository with id: " + storedDataRepository.getId());
}
catch(Exception e) {
reason += e.getMessage();
//try updating
try {
storedDataRepository = dataRepositoryDao.update(dataRepository);
return ResponseEntity.status(HttpStatus.CREATED).body("Updated dataRepository with id: " + storedDataRepository.getId());
}
catch(Exception ex) {
reason += (System.lineSeparator()+e.getMessage());
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Could not create or update dataRepository! Reason: " + reason);
}
}
}
// MANAGE DMPPROFILE(S)
@RequestMapping(method = RequestMethod.GET, value = { "/dmpprofiles" })
public @ResponseBody ResponseEntity<Object> listDmpProfiles(){
try {
List<UUID> allIDs = dMPProfileDao.listAllIDs();
return ResponseEntity.status(HttpStatus.OK).body(new ObjectMapper().writeValueAsString(allIDs));
}
catch(Exception ex) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Serialization issue: "+ex.getMessage());
}
}
@RequestMapping(method = RequestMethod.GET, value = { "/dmpprofiles/{id}" })
public @ResponseBody ResponseEntity<Object> getDmpProfile(@PathVariable("id") String id) {
try {
DMPProfile dmpProfile = dMPProfileDao.read(UUID.fromString(id));
return ResponseEntity.status(HttpStatus.OK).body(new ObjectMapper().writeValueAsString(dmpProfile));
}
catch(Exception ex) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Erroneous input: "+ex.getMessage());
}
}
@RequestMapping(method = RequestMethod.POST, value = { "/setDmpProfile" }, consumes = "application/json")
public @ResponseBody ResponseEntity<Object> setDmpProfile(@RequestBody DMPProfile dmpProfile) {
String reason = "";
DMPProfile storedDMPProfile = null;
//try first to create
try {
storedDMPProfile = dMPProfileDao.create(dmpProfile);
return ResponseEntity.status(HttpStatus.CREATED).body("Created dmpProfile with id: " + storedDMPProfile.getId());
}
catch(Exception e) {
reason += e.getMessage();
//try updating
try {
storedDMPProfile = dMPProfileDao.update(dmpProfile);
return ResponseEntity.status(HttpStatus.CREATED).body("Updated dmpProfile with id: " + storedDMPProfile.getId());
}
catch(Exception ex) {
reason += (System.lineSeparator()+e.getMessage());
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Could not create or update dmpProfile! Reason: " + reason);
}
}
}
}

View File

@ -5,15 +5,12 @@ import java.util.ArrayList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.authentication.AuthenticationServiceException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.stereotype.Component;
import dao.entities.security.UserInfoDao;
import entities.security.UserInfo;
import exceptions.NonValidTokenException;
@Component
public class CustomAuthenticationProvider implements AuthenticationProvider {
@ -49,6 +46,7 @@ public class CustomAuthenticationProvider implements AuthenticationProvider {
throw new AuthenticationServiceException("Authentication failed");
*/
//DELETE THIS, USE THE ABOVE
return new UsernamePasswordAuthenticationToken("", "", new ArrayList<>());

View File

@ -28,7 +28,8 @@ public class TokenAuthenticationFilter extends GenericFilterBean {
//just pass the token into the credentials object of the UsernamePasswordAuthenticationToken class
final UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken("google-user", accessToken);
SecurityContextHolder.getContext().setAuthentication(authentication);
/*
*/
chain.doFilter(request, response);
}

View File

@ -1,3 +1,4 @@
<!--
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans
xmlns="http://www.springframework.org/schema/security"
@ -13,21 +14,11 @@
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd">
<!--
-->
<context:component-scan base-package="security.*" />
<!--
<http auto-config='true'>
<intercept-url pattern="/**" access="ROLE_USER" />
</http>
-->
<http use-expressions="true" create-session="stateless" auto-config='true'>
<custom-filter after="BASIC_AUTH_FILTER" ref="tokenAuthenticationFilter" />
<!-- is authenticated means that they can see even if no correct creds provided -->
<!-- <intercept-url pattern="/customers/**" access="isAuthenticated()" /> -->
<intercept-url pattern="/**" access="isAuthenticated()" />
<http-basic/>
</http>
@ -37,19 +28,9 @@
<authentication-provider ref="customAuthenticationProvider" />
</authentication-manager>
<!--
<authentication-manager>
<authentication-provider>
<user-service>
<user name="mkyong" password="123456" authorities="ROLE_USER" />
</user-service>
</authentication-provider>
</authentication-manager>
-->
<beans:bean id="tokenFilter" class="security.TokenAuthenticationFilter"/>
</beans:beans>
</beans:beans>
-->

View File

@ -28,10 +28,10 @@
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- ,/WEB-INF/spring-security.xml -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml,/WEB-INF/spring-security.xml
<param-value>/WEB-INF/applicationContext.xml
</param-value>
</context-param>
<session-config>
@ -39,6 +39,7 @@
</session-config>
<!-- THIS FILTER IS FOR SPRING SECURITY -->
<!--
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
@ -48,7 +49,6 @@
<url-pattern>/*</url-pattern>
</filter-mapping>
-->
</web-app>