1. Change hash function on piwik.

2. Bug fixes on repository / broker / validator api
3/ Add field on simple subscription domain.
This commit is contained in:
Panagiotis Kanakakis 2018-02-27 13:41:12 +00:00
parent f8a2dbae90
commit edd2e4aa02
8 changed files with 44 additions and 50 deletions

View File

@ -72,8 +72,8 @@ public interface BrokerApi {
@ResponseBody
EventsPage getNotificationsBySubscriptionId(String subscriptionId,String page,String size) throws BrokerException;
@RequestMapping(value = "/getSubscriptionsOfUser/{userEmail}" , method = RequestMethod.GET
/*@RequestMapping(value = "/getSubscriptionsOfUser/{userEmail}" , method = RequestMethod.GET
,produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
@ResponseBody*/
Map<String, List<Subscription>> getSubscriptionsOfUser(String userEmail) throws BrokerException;
}

View File

@ -367,8 +367,8 @@ public class BrokerApiImpl implements BrokerApi {
return resp.getBody();
}
@Override
public Map<String, List<Subscription>> getSubscriptionsOfUser(@PathVariable("userEmail") String userEmail)
//@Override
public Map<String, List<Subscription>> getSubscriptionsOfUser(/*@PathVariable("userEmail")*/ String userEmail)
throws BrokerException {
Map<String, List<SimpleSubscriptionDesc>> simpleSubs = getSimpleSubscriptionsOfUser(userEmail);

View File

@ -2,6 +2,7 @@ package eu.dnetlib.repo.manager.service.controllers;
import eu.dnetlib.domain.data.PiwikInfo;
import eu.dnetlib.utils.md5.MD5;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.dao.EmptyResultDataAccessException;
@ -79,16 +80,8 @@ public class PiWikApiImpl implements PiWikApi{
@Override
public String getOpenaireId(@PathVariable("repositoryId") String repositoryId) {
LOGGER.debug("Getting openaire id for repository: " + repositoryId);
try {
if (repositoryId != null && repositoryId.contains("::")) {
return repositoryId.split("::")[0] + "::" + MD5.encrypt2Hex(repositoryId.split("::")[1]);
}
else
return null;
} catch (NoSuchAlgorithmException e) {
LOGGER.debug(e);
}
if (repositoryId != null && repositoryId.contains("::"))
return repositoryId.split("::")[0] + "::" + DigestUtils.md5Hex(repositoryId.split("::")[1]);
return null;
}

View File

@ -65,7 +65,7 @@ public interface RepositoryApi {
@RequestMapping(value = "/addRepository", method = RequestMethod.POST,
consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
void addRepository(String datatype, Repository repository) throws Exception;
Repository addRepository(String datatype, Repository repository) throws Exception;
@RequestMapping(value = "/deleteInterface", method = RequestMethod.DELETE)

View File

@ -227,12 +227,14 @@ public class RepositoryApiImpl implements RepositoryApi {
public Repository getRepositoryById(@PathVariable("id") String id) throws JSONException {
LOGGER.debug("Retreiving repositories with id : " + id );
Repository repo = null;
UriComponents uriComponents = searchDatasource("0","100");
RequestFilter requestFilter = new RequestFilter();
requestFilter.setId(id);
String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
JSONArray jsonArray = (JSONArray) new JSONObject(rs).get("datasourceInfo");
Repository repo = Converter.jsonToRepositoryObject(jsonArray.getJSONObject(0));
if(jsonArray.length() > 0)
repo = Converter.jsonToRepositoryObject(jsonArray.getJSONObject(0));
if (repo != null)
getRepositoryInfo(repo);
return repo;
@ -294,23 +296,9 @@ public class RepositoryApiImpl implements RepositoryApi {
}
@Override
public void addRepository(@RequestParam("datatype") String datatype,
@RequestBody Repository repository) throws Exception {
public Repository addRepository(@RequestParam("datatype") String datatype,
@RequestBody Repository repository) throws Exception {
/*JSONObject json_params = new JSONObject(params);
String datatype = json_params.getString("datatype");
String json_repository = json_params.getString("repository");
Repository repository = null;*/
ObjectMapper mapper = new ObjectMapper();
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
try {
String json_repo = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(repository);
LOGGER.debug("repository -> " + json_repo);
// repository = mapper.readValue(json_repository, Repository.class);
} catch (Exception e) {
LOGGER.debug("Error parsing repository ", e);
throw e;
}
repository = this.setRepositoryFeatures(datatype,repository);
LOGGER.debug("storing " + datatype + " repository with id: " + repository.getId());
@ -346,6 +334,7 @@ public class RepositoryApiImpl implements RepositoryApi {
}
}
}
return repository;
}
private void updateRepository(Repository repository) {
@ -451,7 +440,7 @@ public class RepositoryApiImpl implements RepositoryApi {
iFace.setRemovable(true);
iFace.setAccessProtocol("oai");
iFace.setMetadataIdentifierPath("//*[local-name()='header']/*[local-name()='identifier']");
// iFace.setId("api_________::" + repo.getId() + "::" + UUID.randomUUID().toString().substring(0, 8));
iFace.setId("api_________::" + repo.getId() + "::" + UUID.randomUUID().toString().substring(0, 8));
if (iFace.getAccessSet().isEmpty()) {
LOGGER.debug("set is empty: " + iFace.getAccessSet());
iFace.removeAccessSet();
@ -488,21 +477,6 @@ public class RepositoryApiImpl implements RepositoryApi {
public RepositoryInterface addRepositoryInterface(@RequestParam("datatype") String datatype,
@RequestParam("repoId") String repoId,
@RequestBody RepositoryInterface repositoryInterface) throws JSONException {
/* JSONObject json_params = new JSONObject(params);
// LOGGER.debug(params);
//TODO iFace parameter from gui. Object to json
String datatype = json_params.getString("datatype");
String repoId = json_params.getString("repoId");
String json_iFace = json_params.getString("iFace");
RepositoryInterface iFace = null;
ObjectMapper mapper = new ObjectMapper();
try {
iFace = mapper.readValue(json_iFace, RepositoryInterface.class);
} catch (Exception e1) {
LOGGER.debug("Error parsing repository interface ", e1);
}*/
return registerRepositoryInterface(repoId,repositoryInterface,datatype);
}
@ -511,7 +485,6 @@ public class RepositoryApiImpl implements RepositoryApi {
try {
e = this.getRepositoryById(repoId);
iFace = createRepositoryInterface(e,iFace,datatype);
ObjectMapper mapper = new ObjectMapper();
String json_interface = Converter.repositoryInterfaceObjectToJson(e,iFace);
LOGGER.debug("iFace equals -> " + json_interface);

View File

@ -58,7 +58,7 @@ public interface ValidatorApi {
@ResponseBody
int getStoredJobsTotalNumberNew(String user, String jobType, String validationStatus) throws ValidatorServiceException;
@RequestMapping(value = "/getInterfaceInformation/" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/getInterfaceInformation" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
InterfaceInformation getInterfaceInformation(String baseUrl) throws ValidationServiceException;
}

View File

@ -2,6 +2,8 @@ package eu.dnetlib.repo.manager.shared.broker;
import com.google.gwt.user.client.rpc.IsSerializable;
import java.util.Date;
/**
* Created by stefanos on 10-Mar-17.
*/
@ -11,6 +13,8 @@ public class SimpleSubscriptionDesc implements IsSerializable {
private String datasource;
private String topic;
private long count;
private Date creationDate;
private Date lastNotificationDate;
public SimpleSubscriptionDesc() {
}
@ -54,4 +58,19 @@ public class SimpleSubscriptionDesc implements IsSerializable {
this.count = count;
}
public Date getCreationDate() {
return creationDate;
}
public void setCreationDate(Date creationDate) {
this.creationDate = creationDate;
}
public Date getLastNotificationDate() {
return lastNotificationDate;
}
public void setLastNotificationDate(Date lastNotificationDate) {
this.lastNotificationDate = lastNotificationDate;
}
}

View File

@ -25,6 +25,8 @@ public class Subscription implements IsSerializable {
private Date lastNotificationDate;
private Date creationDate;
private String conditions;
private List<MapConditions> conditionsAsList;
@ -96,5 +98,12 @@ public class Subscription implements IsSerializable {
this.conditionsAsList = conditionsAsList;
}
public Date getCreationDate() {
return creationDate;
}
public void setCreationDate(Date creationDate) {
this.creationDate = creationDate;
}
}