> converters) {
- converters.add(new MappingJackson2HttpMessageConverter());
- converters.add(new MappingJackson2XmlHttpMessageConverter());
- converters.add(new StringHttpMessageConverter(StandardCharsets.UTF_8));
- }
-}
diff --git a/metis-core/metis-core-rest/src/main/java/eu/europeana/metis/core/rest/config/properties/MetisCoreConfigurationProperties.java b/metis-core/metis-core-rest/src/main/java/eu/europeana/metis/core/rest/config/properties/MetisCoreConfigurationProperties.java
deleted file mode 100644
index c264ff69fc..0000000000
--- a/metis-core/metis-core-rest/src/main/java/eu/europeana/metis/core/rest/config/properties/MetisCoreConfigurationProperties.java
+++ /dev/null
@@ -1,187 +0,0 @@
-package eu.europeana.metis.core.rest.config.properties;
-
-import org.springframework.boot.context.properties.ConfigurationProperties;
-
-/**
- * Class using {@link ConfigurationProperties} loading.
- */
-@ConfigurationProperties(prefix = "metis-core")
-public class MetisCoreConfigurationProperties {
-
- private int maxConcurrentThreads;
- private int dpsMonitorCheckIntervalInSeconds;
- private int dpsConnectTimeoutInMilliseconds;
- private int dpsReadTimeoutInMilliseconds;
- private int failsafeMarginOfInactivityInSeconds;
- private int periodicFailsafeCheckInMilliseconds;
- private int periodicSchedulerCheckInMilliseconds;
- private int pollingTimeoutForCleaningCompletionServiceInMilliseconds;
- private int periodOfNoProcessedRecordsChangeInMinutes;
- private int threadLimitThrottlingLevelWeak;
- private int threadLimitThrottlingLevelMedium;
- private int threadLimitThrottlingLevelStrong;
-
- private String baseUrl;
- private int maxServedExecutionListLength;
- private int maxDepublishRecordIdsPerDataset;
-
- private int linkCheckingDefaultSamplingSize;
- private int solrCommitPeriodInMinutes;
-
- private String authenticationBaseUrl;
- private String[] allowedCorsHosts;
-
-
- public int getMaxConcurrentThreads() {
- return maxConcurrentThreads;
- }
-
- public void setMaxConcurrentThreads(int maxConcurrentThreads) {
- this.maxConcurrentThreads = maxConcurrentThreads;
- }
-
- public int getDpsMonitorCheckIntervalInSeconds() {
- return dpsMonitorCheckIntervalInSeconds;
- }
-
- public void setDpsMonitorCheckIntervalInSeconds(int dpsMonitorCheckIntervalInSeconds) {
- this.dpsMonitorCheckIntervalInSeconds = dpsMonitorCheckIntervalInSeconds;
- }
-
- public int getDpsConnectTimeoutInMilliseconds() {
- return dpsConnectTimeoutInMilliseconds;
- }
-
- public void setDpsConnectTimeoutInMilliseconds(int dpsConnectTimeoutInMilliseconds) {
- this.dpsConnectTimeoutInMilliseconds = dpsConnectTimeoutInMilliseconds;
- }
-
- public int getDpsReadTimeoutInMilliseconds() {
- return dpsReadTimeoutInMilliseconds;
- }
-
- public void setDpsReadTimeoutInMilliseconds(int dpsReadTimeoutInMilliseconds) {
- this.dpsReadTimeoutInMilliseconds = dpsReadTimeoutInMilliseconds;
- }
-
- public int getFailsafeMarginOfInactivityInSeconds() {
- return failsafeMarginOfInactivityInSeconds;
- }
-
- public void setFailsafeMarginOfInactivityInSeconds(int failsafeMarginOfInactivityInSeconds) {
- this.failsafeMarginOfInactivityInSeconds = failsafeMarginOfInactivityInSeconds;
- }
-
- public int getPeriodicFailsafeCheckInMilliseconds() {
- return periodicFailsafeCheckInMilliseconds;
- }
-
- public void setPeriodicFailsafeCheckInMilliseconds(int periodicFailsafeCheckInMilliseconds) {
- this.periodicFailsafeCheckInMilliseconds = periodicFailsafeCheckInMilliseconds;
- }
-
- public int getPeriodicSchedulerCheckInMilliseconds() {
- return periodicSchedulerCheckInMilliseconds;
- }
-
- public void setPeriodicSchedulerCheckInMilliseconds(int periodicSchedulerCheckInMilliseconds) {
- this.periodicSchedulerCheckInMilliseconds = periodicSchedulerCheckInMilliseconds;
- }
-
- public int getPollingTimeoutForCleaningCompletionServiceInMilliseconds() {
- return pollingTimeoutForCleaningCompletionServiceInMilliseconds;
- }
-
- public void setPollingTimeoutForCleaningCompletionServiceInMilliseconds(
- int pollingTimeoutForCleaningCompletionServiceInMilliseconds) {
- this.pollingTimeoutForCleaningCompletionServiceInMilliseconds = pollingTimeoutForCleaningCompletionServiceInMilliseconds;
- }
-
- public int getPeriodOfNoProcessedRecordsChangeInMinutes() {
- return periodOfNoProcessedRecordsChangeInMinutes;
- }
-
- public void setPeriodOfNoProcessedRecordsChangeInMinutes(int periodOfNoProcessedRecordsChangeInMinutes) {
- this.periodOfNoProcessedRecordsChangeInMinutes = periodOfNoProcessedRecordsChangeInMinutes;
- }
-
- public int getThreadLimitThrottlingLevelWeak() {
- return threadLimitThrottlingLevelWeak;
- }
-
- public void setThreadLimitThrottlingLevelWeak(int threadLimitThrottlingLevelWeak) {
- this.threadLimitThrottlingLevelWeak = threadLimitThrottlingLevelWeak;
- }
-
- public int getThreadLimitThrottlingLevelMedium() {
- return threadLimitThrottlingLevelMedium;
- }
-
- public void setThreadLimitThrottlingLevelMedium(int threadLimitThrottlingLevelMedium) {
- this.threadLimitThrottlingLevelMedium = threadLimitThrottlingLevelMedium;
- }
-
- public int getThreadLimitThrottlingLevelStrong() {
- return threadLimitThrottlingLevelStrong;
- }
-
- public void setThreadLimitThrottlingLevelStrong(int threadLimitThrottlingLevelStrong) {
- this.threadLimitThrottlingLevelStrong = threadLimitThrottlingLevelStrong;
- }
-
- public String getBaseUrl() {
- return baseUrl;
- }
-
- public void setBaseUrl(String baseUrl) {
- this.baseUrl = baseUrl;
- }
-
- public int getMaxServedExecutionListLength() {
- return maxServedExecutionListLength;
- }
-
- public void setMaxServedExecutionListLength(int maxServedExecutionListLength) {
- this.maxServedExecutionListLength = maxServedExecutionListLength;
- }
-
- public int getMaxDepublishRecordIdsPerDataset() {
- return maxDepublishRecordIdsPerDataset;
- }
-
- public void setMaxDepublishRecordIdsPerDataset(int maxDepublishRecordIdsPerDataset) {
- this.maxDepublishRecordIdsPerDataset = maxDepublishRecordIdsPerDataset;
- }
-
- public int getLinkCheckingDefaultSamplingSize() {
- return linkCheckingDefaultSamplingSize;
- }
-
- public void setLinkCheckingDefaultSamplingSize(int linkCheckingDefaultSamplingSize) {
- this.linkCheckingDefaultSamplingSize = linkCheckingDefaultSamplingSize;
- }
-
- public int getSolrCommitPeriodInMinutes() {
- return solrCommitPeriodInMinutes;
- }
-
- public void setSolrCommitPeriodInMinutes(int solrCommitPeriodInMinutes) {
- this.solrCommitPeriodInMinutes = solrCommitPeriodInMinutes;
- }
-
- public String getAuthenticationBaseUrl() {
- return authenticationBaseUrl;
- }
-
- public void setAuthenticationBaseUrl(String authenticationBaseUrl) {
- this.authenticationBaseUrl = authenticationBaseUrl;
- }
-
- public String[] getAllowedCorsHosts() {
- return allowedCorsHosts == null ? null : allowedCorsHosts.clone();
- }
-
- public void setAllowedCorsHosts(String[] allowedCorsHosts) {
- this.allowedCorsHosts = allowedCorsHosts == null ? null : allowedCorsHosts.clone();
- }
-}
diff --git a/metis-core/metis-core-rest/src/main/java/eu/europeana/metis/core/rest/controller/DatasetController.java b/metis-core/metis-core-rest/src/main/java/eu/europeana/metis/core/rest/controller/DatasetController.java
deleted file mode 100644
index 48b79d29e4..0000000000
--- a/metis-core/metis-core-rest/src/main/java/eu/europeana/metis/core/rest/controller/DatasetController.java
+++ /dev/null
@@ -1,695 +0,0 @@
-package eu.europeana.metis.core.rest.controller;
-
-import static eu.europeana.metis.utils.CommonStringValues.CRLF_PATTERN;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import eu.europeana.metis.authentication.rest.client.AuthenticationClient;
-import eu.europeana.metis.authentication.user.MetisUserView;
-import eu.europeana.metis.core.common.Country;
-import eu.europeana.metis.core.common.Language;
-import eu.europeana.metis.core.dataset.Dataset;
-import eu.europeana.metis.core.dataset.DatasetSearchView;
-import eu.europeana.metis.core.dataset.DatasetXslt;
-import eu.europeana.metis.core.dataset.DatasetXsltStringWrapper;
-import eu.europeana.metis.core.exceptions.DatasetAlreadyExistsException;
-import eu.europeana.metis.core.exceptions.NoDatasetFoundException;
-import eu.europeana.metis.core.exceptions.NoXsltFoundException;
-import eu.europeana.metis.core.exceptions.XsltSetupException;
-import eu.europeana.metis.core.rest.Record;
-import eu.europeana.metis.core.rest.ResponseListWrapper;
-import eu.europeana.metis.core.service.DatasetService;
-import eu.europeana.metis.core.workflow.plugins.ExecutablePluginType;
-import eu.europeana.metis.core.workflow.plugins.TransformationPlugin;
-import eu.europeana.metis.exception.BadContentException;
-import eu.europeana.metis.exception.GenericMetisException;
-import eu.europeana.metis.exception.UserUnauthorizedException;
-import eu.europeana.metis.utils.CommonStringValues;
-import eu.europeana.metis.utils.RestEndpoints;
-import java.util.List;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.MediaType;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestHeader;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.ResponseStatus;
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * Contains all the calls that are related to Datasets.
- * The {@link DatasetService} has control on how to manipulate a dataset
- */
-@RestController
-public class DatasetController {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(DatasetController.class);
-
- private final DatasetService datasetService;
- private final AuthenticationClient authenticationClient;
-
- /**
- * Autowired constructor with all required parameters.
- *
- * @param datasetService the datasetService
- * @param authenticationClient the java client to communicate with the external authentication service
- */
- @Autowired
- public DatasetController(DatasetService datasetService,
- AuthenticationClient authenticationClient) {
- this.datasetService = datasetService;
- this.authenticationClient = authenticationClient;
- }
-
- /**
- * Create a provided dataset.
- * Dataset is provided as json or xml.
- *
- * @param authorization the String provided by an HTTP Authorization header The expected input should follow the rule Bearer
- * accessTokenHere
- * @param dataset the provided dataset to be created
- * @return the dataset created including all other fields that are auto generated
- * @throws GenericMetisException which can be one of:
- *
- * - {@link DatasetAlreadyExistsException} if the dataset already exists for the organizationId and datasetName.
- * - {@link UserUnauthorizedException} if the authorization header is un-parsable or the user cannot be authenticated or authorized or the user is unauthorized.
- *
- */
- @PostMapping(value = RestEndpoints.DATASETS, consumes = {
- MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
- @ResponseStatus(HttpStatus.CREATED)
- public Dataset createDataset(@RequestHeader("Authorization") String authorization,
- @RequestBody Dataset dataset)
- throws GenericMetisException {
-
- MetisUserView metisUserView = authenticationClient.getUserByAccessTokenInHeader(authorization);
-
- Dataset createdDataset = datasetService.createDataset(metisUserView, dataset);
- LOGGER.info("Dataset with datasetId: {}, datasetName: {} and organizationId {} created",
- createdDataset.getDatasetId(), createdDataset.getDatasetName(),
- createdDataset.getOrganizationId());
- return createdDataset;
- }
-
- /**
- * Update a provided dataset including an xslt string.
- *
- * Non allowed fields, to be manually updated, will be ignored. Updating a dataset with a new xslt will only overwrite the
- * {@code Dataset#xsltId} and a new {@link DatasetXslt} object will be stored. The older {@link DatasetXslt} will still be
- * accessible.
- *
- *
- * @param authorization the String provided by an HTTP Authorization header The expected input should follow the rule Bearer
- * accessTokenHere
- * @param datasetXsltStringWrapper {@link DatasetXsltStringWrapper}
- * @throws GenericMetisException which can be one of:
- *
- * - {@link NoDatasetFoundException} if the dataset was not found for the datasetId.
- * - {@link UserUnauthorizedException} if the user is unauthorized.
- * - {@link DatasetAlreadyExistsException} if a datasetName change is requested and the datasetName for that organizationId already exists.
- *
- */
- @PutMapping(value = RestEndpoints.DATASETS, consumes = {
- MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
- @ResponseStatus(HttpStatus.NO_CONTENT)
- public void updateDataset(@RequestHeader("Authorization") String authorization,
- @RequestBody DatasetXsltStringWrapper datasetXsltStringWrapper)
- throws GenericMetisException {
-
- MetisUserView metisUserView = authenticationClient.getUserByAccessTokenInHeader(authorization);
-
- datasetService
- .updateDataset(metisUserView, datasetXsltStringWrapper.getDataset(), datasetXsltStringWrapper
- .getXslt());
- if (LOGGER.isInfoEnabled()) {
- LOGGER.info("Dataset with datasetId {} updated",
- CRLF_PATTERN.matcher(datasetXsltStringWrapper.getDataset().getDatasetId()).replaceAll(""));
- }
- }
-
- /**
- * Delete a dataset using a datasetId.
- *
- * @param authorization the String provided by an HTTP Authorization header The expected input should follow the rule Bearer
- * accessTokenHere
- * @param datasetId the identifier used to find and delete the dataset
- * @throws GenericMetisException which can be one of:
- *
- * - {@link UserUnauthorizedException} if the user is unauthorized.
- * - {@link NoDatasetFoundException} if the dataset was not found for datasetId
- *
- */
- @DeleteMapping(value = RestEndpoints.DATASETS_DATASETID)
- @ResponseStatus(HttpStatus.NO_CONTENT)
- public void deleteDataset(@RequestHeader("Authorization") String authorization,
- @PathVariable("datasetId") String datasetId)
- throws GenericMetisException {
-
- MetisUserView metisUserView = authenticationClient.getUserByAccessTokenInHeader(authorization);
-
- datasetService.deleteDatasetByDatasetId(metisUserView, datasetId);
- if (LOGGER.isInfoEnabled()) {
- LOGGER.info("Dataset with datasetId '{}' deleted",
- datasetId.replaceAll(CommonStringValues.REPLACEABLE_CRLF_CHARACTERS_REGEX, ""));
- }
- }
-
- /**
- * Get a dataset based on its datasetId
- *
- * @param authorization the String provided by an HTTP Authorization header The expected input should follow the rule Bearer
- * accessTokenHere
- * @param datasetId the identifier used to find a dataset
- * @return {@link Dataset}
- * @throws GenericMetisException which can be one of:
- *
- * - {@link NoDatasetFoundException} if the dataset was not found.
- * - {@link UserUnauthorizedException} if the user is unauthorized.
- *
- */
- @GetMapping(value = RestEndpoints.DATASETS_DATASETID, produces = {
- MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
- @ResponseStatus(HttpStatus.OK)
- public Dataset getByDatasetId(@RequestHeader("Authorization") String authorization,
- @PathVariable("datasetId") String datasetId)
- throws GenericMetisException {
-
- MetisUserView metisUserView = authenticationClient.getUserByAccessTokenInHeader(authorization);
-
- Dataset storedDataset = datasetService.getDatasetByDatasetId(metisUserView, datasetId);
- if (LOGGER.isInfoEnabled()) {
- LOGGER.info("Dataset with datasetId '{}' found",
- datasetId.replaceAll(CommonStringValues.REPLACEABLE_CRLF_CHARACTERS_REGEX, ""));
- }
- return storedDataset;
- }
-
- /**
- * Get the xslt object containing the escaped xslt string using a dataset identifier.
- *
- * @param authorization the String provided by an HTTP Authorization header The expected input should follow the rule Bearer
- * accessTokenHere
- * @param datasetId the identifier used to find a dataset
- * @return the {@link DatasetXslt} object containing the xslt as an escaped string
- * @throws GenericMetisException which can be one of:
- *
- * - {@link NoXsltFoundException} if the xslt was not found.
- * - {@link NoDatasetFoundException} if the dataset was not found.
- * - {@link UserUnauthorizedException} if the user is unauthorized.
- *
- */
- @GetMapping(value = RestEndpoints.DATASETS_DATASETID_XSLT, produces = {
- MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
- @ResponseStatus(HttpStatus.OK)
- public DatasetXslt getDatasetXsltByDatasetId(@RequestHeader("Authorization") String authorization,
- @PathVariable("datasetId") String datasetId) throws GenericMetisException {
-
- MetisUserView metisUserView = authenticationClient.getUserByAccessTokenInHeader(authorization);
-
- DatasetXslt datasetXslt = datasetService.getDatasetXsltByDatasetId(metisUserView, datasetId);
- LOGGER.info("Dataset XSLT with datasetId '{}' and xsltId: '{}' found", datasetId,
- datasetXslt.getId());
- return datasetXslt;
- }
-
- /**
- * Get the xslt string as non escaped text using an xslt identifier.
- *
- * It is a method that does not require authentication and it is meant to be used from external service to download the
- * corresponding xslt. At the point of writing, ECloud transformation topology is using it. {@link TransformationPlugin}
- *
- *
- * @param xsltId the xslt identifier
- * @return the text non escaped representation of the xslt string
- * @throws GenericMetisException which can be one of:
- *
- * - {@link NoXsltFoundException} if the xslt was not found.
- *
- */
- @GetMapping(value = RestEndpoints.DATASETS_XSLT_XSLTID, produces = {
- MediaType.TEXT_PLAIN_VALUE})
- @ResponseStatus(HttpStatus.OK)
- public String getXsltByXsltId(@PathVariable("xsltId") String xsltId)
- throws GenericMetisException {
- DatasetXslt datasetXslt = datasetService.getDatasetXsltByXsltId(xsltId);
- LOGGER.info("XSLT with xsltId '{}' found", datasetXslt.getId());
- return datasetXslt.getXslt();
- }
-
- /**
- * Create a new default xslt in the database.
- *
- * Each dataset can have it's own custom xslt but a default xslt should always be available. Creating a new default xslt will
- * create a new {@link DatasetXslt} object and the older one will still be available. The created {@link DatasetXslt} will have
- * it's {@code DatasetXslt#datasetId} as -1 to indicate that it is not related to a specific dataset.
- *
- *
- * @param authorization the String provided by an HTTP Authorization header The expected input should follow the rule Bearer
- * accessTokenHere
- * @param xsltString the text of the String representation non escaped
- * @return the created {@link DatasetXslt}
- * @throws GenericMetisException which can be one of:
- *
- * - {@link UserUnauthorizedException} if the user is unauthorized.
- *
- */
- @PostMapping(value = RestEndpoints.DATASETS_XSLT_DEFAULT, consumes = {
- MediaType.TEXT_PLAIN_VALUE}, produces = {
- MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
- @ResponseStatus(HttpStatus.CREATED)
- public DatasetXslt createDefaultXslt(@RequestHeader("Authorization") String authorization,
- @RequestBody String xsltString)
- throws GenericMetisException {
-
- MetisUserView metisUserView = authenticationClient.getUserByAccessTokenInHeader(authorization);
- DatasetXslt defaultDatasetXslt = datasetService.createDefaultXslt(metisUserView, xsltString);
- LOGGER.info("New default xslt created with xsltId: {}", defaultDatasetXslt.getId());
- return defaultDatasetXslt;
- }
-
- /**
- * Get the latest created default xslt.
- *
- * It is an method that does not require authentication and it is meant to be used from external service to download the
- * corresponding xslt. At the point of writing, ECloud transformation topology is using it. {@link TransformationPlugin}
- *
- *
- * @return the text representation of the String xslt non escaped
- * @throws GenericMetisException which can be one of:
- *
- * - {@link NoXsltFoundException} if the xslt was not found.
- *
- */
- @GetMapping(value = RestEndpoints.DATASETS_XSLT_DEFAULT, produces = {
- MediaType.TEXT_PLAIN_VALUE})
- @ResponseStatus(HttpStatus.OK)
- public String getLatestDefaultXslt() throws GenericMetisException {
- DatasetXslt datasetXslt = datasetService.getLatestDefaultXslt();
- LOGGER.info("Default XSLT with xsltId '{}' found", datasetXslt.getId());
- return datasetXslt.getXslt();
- }
-
- /**
- * Transform a list of xmls using the latest dataset xslt stored.
- *
- * This method is meant to be used after a response from
- * {@link ProxiesController#getListOfFileContentsFromPluginExecution(String, String, ExecutablePluginType, String)} to try a
- * transformation on a list of xmls just after validation external to preview an example result.
- *
- *
- * @param authorization the String provided by an HTTP Authorization header The expected input should follow the rule Bearer
- * accessTokenHere
- * @param datasetId the dataset identifier, it is required for authentication and for the dataset fields xslt injection
- * @param records the list of {@link Record} that contain the xml fields {@code Record#xmlRecord}.
- * @return a list of {@link Record}s with the field {@code Record#xmlRecord} containing the transformed xml
- * @throws GenericMetisException which can be one of:
- *
- * - {@link UserUnauthorizedException} if the authorization header is un-parsable or the user cannot be
- * authenticated or authorized.
- * - {@link NoDatasetFoundException} if the dataset was not found.
- * - {@link NoXsltFoundException} if there is no xslt found
- * - {@link XsltSetupException} if the XSL transform could not be set up
- *
- */
- @PostMapping(value = RestEndpoints.DATASETS_DATASETID_XSLT_TRANSFORM, consumes = {
- MediaType.APPLICATION_JSON_VALUE}, produces = {MediaType.APPLICATION_JSON_VALUE})
- @ResponseStatus(HttpStatus.OK)
- public List transformRecordsUsingLatestDatasetXslt(
- @RequestHeader("Authorization") String authorization,
- @PathVariable("datasetId") String datasetId,
- @RequestBody List records) throws GenericMetisException {
- MetisUserView metisUserView = authenticationClient.getUserByAccessTokenInHeader(authorization);
- return datasetService.transformRecordsUsingLatestDatasetXslt(metisUserView, datasetId, records);
- }
-
- /**
- * Transform a list of xmls using the latest default xslt stored.
- *
- * This method is meant to be used after a response from
- * {@link ProxiesController#getListOfFileContentsFromPluginExecution(String, String, ExecutablePluginType, String)} to try a
- * transformation on a list of xmls just after validation external to preview an example result.
- *
- *
- * @param authorization the String provided by an HTTP Authorization header The expected input should follow the rule Bearer
- * accessTokenHere
- * @param datasetId the dataset identifier, it is required for authentication and for the dataset fields xslt injection
- * @param records the list of {@link Record} that contain the xml fields {@code Record#xmlRecord}.
- * @return a list of {@link Record}s with the field {@code Record#xmlRecord} containing the transformed xml
- * @throws GenericMetisException which can be one of:
- *
- * - {@link UserUnauthorizedException} if the authorization header is un-parsable or the user cannot be
- * authenticated or authorized.
- * - {@link NoDatasetFoundException} if the dataset was not found.
- * - {@link NoXsltFoundException} if there is no xslt found
- * - {@link XsltSetupException} if the XSL transform could not be set up
- *
- */
- @PostMapping(value = RestEndpoints.DATASETS_DATASETID_XSLT_TRANSFORM_DEFAULT, consumes = {
- MediaType.APPLICATION_JSON_VALUE}, produces = {MediaType.APPLICATION_JSON_VALUE})
- @ResponseStatus(HttpStatus.OK)
- public List transformRecordsUsingLatestDefaultXslt(
- @RequestHeader("Authorization") String authorization,
- @PathVariable("datasetId") String datasetId,
- @RequestBody List records) throws GenericMetisException {
- MetisUserView metisUserView = authenticationClient.getUserByAccessTokenInHeader(authorization);
- return datasetService.transformRecordsUsingLatestDefaultXslt(metisUserView, datasetId, records);
- }
-
- /**
- * Get a dataset based on its datasetName
- *
- * @param authorization the String provided by an HTTP Authorization header The expected input should follow the rule Bearer
- * accessTokenHere
- * @param datasetName the name of the dataset used to find a dataset
- * @return {@link Dataset}
- * @throws GenericMetisException which can be one of:
- *
- * - {@link NoDatasetFoundException} if the dataset was not found.
- * - {@link UserUnauthorizedException} if the user is unauthorized.
- *
- */
- @GetMapping(value = RestEndpoints.DATASETS_DATASETNAME, produces = {
- MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
- @ResponseStatus(HttpStatus.OK)
- public Dataset getByDatasetName(@RequestHeader("Authorization") String authorization,
- @PathVariable("datasetName") String datasetName)
- throws GenericMetisException {
-
- MetisUserView metisUserView = authenticationClient.getUserByAccessTokenInHeader(authorization);
-
- Dataset dataset = datasetService.getDatasetByDatasetName(metisUserView, datasetName);
- LOGGER.info("Dataset with datasetName '{}' found", dataset.getDatasetName());
- return dataset;
- }
-
- /**
- * Get a list of all the datasets using the provider field for lookup.
- * The results are paged and wrapped around {@link ResponseListWrapper}
- *
- * @param authorization the String provided by an HTTP Authorization header The expected input should follow the rule Bearer
- * accessTokenHere
- * @param provider the provider used to search
- * @param nextPage the nextPage number or -1
- * @return {@link ResponseListWrapper}
- * @throws GenericMetisException which can be one of:
- *
- * - {@link UserUnauthorizedException} if the user is unauthorized.
- *
- */
- @GetMapping(value = RestEndpoints.DATASETS_PROVIDER, produces = {
- MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
- @ResponseStatus(HttpStatus.OK)
- public ResponseListWrapper getAllDatasetsByProvider(
- @RequestHeader("Authorization") String authorization,
- @PathVariable("provider") String provider,
- @RequestParam(value = "nextPage", required = false, defaultValue = "0") int nextPage)
- throws GenericMetisException {
- if (nextPage < 0) {
- throw new BadContentException(CommonStringValues.NEXT_PAGE_CANNOT_BE_NEGATIVE);
- }
-
- MetisUserView metisUserView = authenticationClient.getUserByAccessTokenInHeader(authorization);
-
- ResponseListWrapper responseListWrapper = new ResponseListWrapper<>();
- responseListWrapper
- .setResultsAndLastPage(
- datasetService.getAllDatasetsByProvider(metisUserView, provider, nextPage),
- datasetService.getDatasetsPerRequestLimit(), nextPage);
- LOGGER.info(CommonStringValues.BATCH_OF_DATASETS_RETURNED,
- responseListWrapper.getListSize(), nextPage);
- return responseListWrapper;
- }
-
- /**
- * Get a list of all the datasets using the intermediateProvider field for lookup.
- * The results are paged and wrapped around {@link ResponseListWrapper}
- *
- * @param authorization the String provided by an HTTP Authorization header The expected input should follow the rule Bearer
- * accessTokenHere
- * @param intermediateProvider the intermediateProvider used to search
- * @param nextPage the nextPage number or -1
- * @return {@link ResponseListWrapper}
- * @throws GenericMetisException which can be one of:
- *
- * - {@link UserUnauthorizedException} if the user is unauthorized.
- *
- */
- @GetMapping(value = RestEndpoints.DATASETS_INTERMEDIATE_PROVIDER, produces = {
- MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
- @ResponseStatus(HttpStatus.OK)
- public ResponseListWrapper getAllDatasetsByIntermediateProvider(
- @RequestHeader("Authorization") String authorization,
- @PathVariable("intermediateProvider") String intermediateProvider,
- @RequestParam(value = "nextPage", required = false, defaultValue = "0") int nextPage)
- throws GenericMetisException {
- if (nextPage < 0) {
- throw new BadContentException(CommonStringValues.NEXT_PAGE_CANNOT_BE_NEGATIVE);
- }
-
- MetisUserView metisUserView = authenticationClient.getUserByAccessTokenInHeader(authorization);
-
- ResponseListWrapper responseListWrapper = new ResponseListWrapper<>();
- responseListWrapper
- .setResultsAndLastPage(
- datasetService
- .getAllDatasetsByIntermediateProvider(metisUserView, intermediateProvider, nextPage),
- datasetService.getDatasetsPerRequestLimit(), nextPage);
- LOGGER.info(CommonStringValues.BATCH_OF_DATASETS_RETURNED,
- responseListWrapper.getListSize(), nextPage);
- return responseListWrapper;
- }
-
- /**
- * Get a list of all the datasets using the dataProvider field for lookup.
- * The results are paged and wrapped around {@link ResponseListWrapper}
- *
- * @param authorization the String provided by an HTTP Authorization header The expected input should follow the rule Bearer
- * accessTokenHere
- * @param dataProvider the dataProvider used to search
- * @param nextPage the nextPage number or -1
- * @return {@link ResponseListWrapper}
- * @throws GenericMetisException which can be one of:
- *
- * - {@link UserUnauthorizedException} if the user is unauthorized.
- *
- */
- @GetMapping(value = RestEndpoints.DATASETS_DATAPROVIDER, produces = {
- MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
- @ResponseStatus(HttpStatus.OK)
- public ResponseListWrapper getAllDatasetsByDataProvider(
- @RequestHeader("Authorization") String authorization,
- @PathVariable("dataProvider") String dataProvider,
- @RequestParam(value = "nextPage", required = false, defaultValue = "0") int nextPage)
- throws GenericMetisException {
- if (nextPage < 0) {
- throw new BadContentException(CommonStringValues.NEXT_PAGE_CANNOT_BE_NEGATIVE);
- }
-
- MetisUserView metisUserView = authenticationClient.getUserByAccessTokenInHeader(authorization);
-
- ResponseListWrapper responseListWrapper = new ResponseListWrapper<>();
- responseListWrapper
- .setResultsAndLastPage(
- datasetService.getAllDatasetsByDataProvider(metisUserView, dataProvider, nextPage),
- datasetService.getDatasetsPerRequestLimit(), nextPage);
- LOGGER.info(CommonStringValues.BATCH_OF_DATASETS_RETURNED,
- responseListWrapper.getListSize(), nextPage);
- return responseListWrapper;
- }
-
- /**
- * Get a list of all the datasets using the organizationId field for lookup.
- * The results are paged and wrapped around {@link ResponseListWrapper}
- *
- * @param authorization the String provided by an HTTP Authorization header The expected input should follow the rule Bearer
- * accessTokenHere
- * @param organizationId the organizationId used to search
- * @param nextPage the nextPage number or -1
- * @return {@link ResponseListWrapper}
- * @throws GenericMetisException which can be one of:
- *
- * - {@link UserUnauthorizedException} if the user is unauthorized.
- *
- */
- @GetMapping(value = RestEndpoints.DATASETS_ORGANIZATION_ID, produces = {
- MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
- @ResponseStatus(HttpStatus.OK)
- public ResponseListWrapper getAllDatasetsByOrganizationId(
- @RequestHeader("Authorization") String authorization,
- @PathVariable("organizationId") String organizationId,
- @RequestParam(value = "nextPage", required = false, defaultValue = "0") int nextPage)
- throws GenericMetisException {
- if (nextPage < 0) {
- throw new BadContentException(CommonStringValues.NEXT_PAGE_CANNOT_BE_NEGATIVE);
- }
-
- MetisUserView metisUserView = authenticationClient.getUserByAccessTokenInHeader(authorization);
-
- ResponseListWrapper responseListWrapper = new ResponseListWrapper<>();
- responseListWrapper
- .setResultsAndLastPage(
- datasetService.getAllDatasetsByOrganizationId(metisUserView, organizationId, nextPage),
- datasetService.getDatasetsPerRequestLimit(), nextPage);
- LOGGER.info(CommonStringValues.BATCH_OF_DATASETS_RETURNED,
- responseListWrapper.getListSize(), nextPage);
- return responseListWrapper;
- }
-
- /**
- * Get a list of all the datasets using the organizationName field for lookup.
- * The results are paged and wrapped around {@link ResponseListWrapper}
- *
- * @param authorization the String provided by an HTTP Authorization header The expected input should follow the rule Bearer
- * accessTokenHere
- * @param organizationName the organizationName used to search
- * @param nextPage the nextPage number or -1
- * @return {@link ResponseListWrapper}
- * @throws GenericMetisException which can be one of:
- *
- * - {@link UserUnauthorizedException} if the user is unauthorized.
- *
- */
- @GetMapping(value = RestEndpoints.DATASETS_ORGANIZATION_NAME, produces = {
- MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
- @ResponseStatus(HttpStatus.OK)
- public ResponseListWrapper getAllDatasetsByOrganizationName(
- @RequestHeader("Authorization") String authorization,
- @PathVariable("organizationName") String organizationName,
- @RequestParam(value = "nextPage", required = false, defaultValue = "0") int nextPage)
- throws GenericMetisException {
- if (nextPage < 0) {
- throw new BadContentException(CommonStringValues.NEXT_PAGE_CANNOT_BE_NEGATIVE);
- }
-
- MetisUserView metisUserView = authenticationClient.getUserByAccessTokenInHeader(authorization);
-
- ResponseListWrapper responseListWrapper = new ResponseListWrapper<>();
- responseListWrapper
- .setResultsAndLastPage(
- datasetService.getAllDatasetsByOrganizationName(metisUserView, organizationName, nextPage),
- datasetService.getDatasetsPerRequestLimit(), nextPage);
- LOGGER.info(CommonStringValues.BATCH_OF_DATASETS_RETURNED,
- responseListWrapper.getListSize(), nextPage);
- return responseListWrapper;
- }
-
- /**
- * Get all available countries that can be used.
- * The list is retrieved based on an internal enum
- *
- * @param authorization the String provided by an HTTP Authorization header The expected input should follow the rule Bearer
- * accessTokenHere
- * @return The list of countries that are serialized based on {@link eu.europeana.metis.core.common.CountrySerializer}
- * @throws GenericMetisException which can be one of:
- *
- * - {@link UserUnauthorizedException} if the user is unauthorized.
- *
- */
- @GetMapping(value = RestEndpoints.DATASETS_COUNTRIES, produces = {
- MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
- @ResponseStatus(HttpStatus.OK)
- public List getDatasetsCountries(
- @RequestHeader("Authorization") String authorization) throws GenericMetisException {
- authenticationClient.getUserByAccessTokenInHeader(authorization);
- return Country.getCountryListSortedByName().stream().map(CountryView::new)
- .toList();
- }
-
- /**
- * Get all available languages that can be used.
- * The list is retrieved based on an internal enum
- *
- * @param authorization the String provided by an HTTP Authorization header
- * The expected input should follow the rule Bearer accessTokenHere
- * @return The list of countries that are serialized based on {@link eu.europeana.metis.core.common.LanguageSerializer}
- * @throws GenericMetisException which can be one of:
- *
- * - {@link UserUnauthorizedException} if the user is unauthorized.
- *
- */
- @GetMapping(value = RestEndpoints.DATASETS_LANGUAGES, produces = {
- MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
- @ResponseStatus(HttpStatus.OK)
- public List getDatasetsLanguages(
- @RequestHeader("Authorization") String authorization) throws GenericMetisException {
- authenticationClient.getUserByAccessTokenInHeader(authorization);
- return Language.getLanguageListSortedByName().stream().map(LanguageView::new)
- .toList();
- }
-
- /**
- * Get the list of of matching DatasetSearch using dataset
- *
- * @param authorization the String provided by an HTTP Authorization header
- * The expected input should follow the rule Bearer accessTokenHere
- * @param searchString a string that may contain multiple words separated by spaces.
- * The search will be performed on the fields datasetId, datasetName, provider, dataProvider.
- * The words that start with a numeric character will be considered as part of the datasetId search and that field is searched
- * as a "starts with" operation. All words that from a certain length threshold and above e.g. 3 will be used, as AND
- * operations, for searching the fields datasetName, provider, dataProvider
- * @param nextPage the nextPage number, must be positive
- * @return a list with the dataset search view results
- * @throws GenericMetisException which can be one of:
- *
- * - {@link BadContentException} if the parameters provided are invalid.
- * - {@link UserUnauthorizedException} if the user is unauthorized.
- *
- */
- @GetMapping(value = RestEndpoints.DATASETS_SEARCH, produces = {
- MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
- @ResponseStatus(HttpStatus.OK)
- public ResponseListWrapper getDatasetSearch(
- @RequestHeader("Authorization") String authorization,
- @RequestParam(value = "searchString") String searchString,
- @RequestParam(value = "nextPage", required = false, defaultValue = "0") int nextPage)
- throws GenericMetisException {
- if (nextPage < 0) {
- throw new BadContentException(CommonStringValues.NEXT_PAGE_CANNOT_BE_NEGATIVE);
- }
-
- final MetisUserView metisUserView = authenticationClient
- .getUserByAccessTokenInHeader(authorization);
- ResponseListWrapper responseListWrapper = new ResponseListWrapper<>();
- responseListWrapper.setResultsAndLastPage(
- datasetService.searchDatasetsBasedOnSearchString(metisUserView, searchString, nextPage),
- datasetService.getDatasetsPerRequestLimit(), nextPage);
- LOGGER.info(CommonStringValues.BATCH_OF_DATASETS_RETURNED, responseListWrapper.getListSize(),
- nextPage);
- return responseListWrapper;
- }
-
- private static class CountryView {
-
- @JsonProperty("enum")
- private final String enumName;
- @JsonProperty
- private final String name;
- @JsonProperty
- private final String isoCode;
-
- CountryView(Country country) {
- this.enumName = country.name();
- this.name = country.getName();
- this.isoCode = country.getIsoCode();
- }
- }
-
- private static class LanguageView {
-
- @JsonProperty("enum")
- private final String enumName;
- @JsonProperty
- private final String name;
-
- LanguageView(Language language) {
- this.enumName = language.name();
- this.name = language.getName();
- }
- }
-}
diff --git a/metis-core/metis-core-rest/src/main/java/eu/europeana/metis/core/rest/controller/DepublishRecordIdController.java b/metis-core/metis-core-rest/src/main/java/eu/europeana/metis/core/rest/controller/DepublishRecordIdController.java
deleted file mode 100644
index 9c652ab1ba..0000000000
--- a/metis-core/metis-core-rest/src/main/java/eu/europeana/metis/core/rest/controller/DepublishRecordIdController.java
+++ /dev/null
@@ -1,226 +0,0 @@
-package eu.europeana.metis.core.rest.controller;
-
-import eu.europeana.metis.authentication.rest.client.AuthenticationClient;
-import eu.europeana.metis.authentication.user.MetisUserView;
-import eu.europeana.metis.core.exceptions.NoDatasetFoundException;
-import eu.europeana.metis.core.rest.DepublicationInfoView;
-import eu.europeana.metis.core.service.DepublishRecordIdService;
-import eu.europeana.metis.core.util.DepublishRecordIdSortField;
-import eu.europeana.metis.core.util.SortDirection;
-import eu.europeana.metis.core.workflow.WorkflowExecution;
-import eu.europeana.metis.exception.BadContentException;
-import eu.europeana.metis.exception.GenericMetisException;
-import eu.europeana.metis.exception.UserUnauthorizedException;
-import eu.europeana.metis.utils.CommonStringValues;
-import eu.europeana.metis.utils.RestEndpoints;
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-import java.util.regex.Pattern;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.MediaType;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestHeader;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RequestPart;
-import org.springframework.web.bind.annotation.ResponseBody;
-import org.springframework.web.bind.annotation.ResponseStatus;
-import org.springframework.web.bind.annotation.RestController;
-import org.springframework.web.multipart.MultipartFile;
-
-/**
- * Controller for calls related to depublish record ids.
- */
-@RestController
-public class DepublishRecordIdController {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(DepublishRecordIdController.class);
- private static final Pattern CRLF_PATTERN = Pattern
- .compile(CommonStringValues.REPLACEABLE_CRLF_CHARACTERS_REGEX);
-
- private final DepublishRecordIdService depublishRecordIdService;
- private final AuthenticationClient authenticationClient;
-
- /**
- * Autowired constructor with all required parameters.
- *
- * @param depublishRecordIdService the service for depublished records.
- * @param authenticationClient the java client to communicate with the external authentication service
- */
- @Autowired
- public DepublishRecordIdController(DepublishRecordIdService depublishRecordIdService,
- AuthenticationClient authenticationClient) {
- this.depublishRecordIdService = depublishRecordIdService;
- this.authenticationClient = authenticationClient;
- }
-
- /**
- * Adds a list of record ids to be depublished for the dataset - the version for a simple text body.
- *
- * @param authorization the HTTP Authorization header, in the form of a Bearer Access Token.
- * @param datasetId The dataset ID to which the depublish record ids belong.
- * @param recordIdsInSeparateLines The string containing the record IDs in separate lines.
- * @throws GenericMetisException which can be one of:
- *
- * - {@link NoDatasetFoundException} if the dataset for datasetId was not found.
- * - {@link UserUnauthorizedException} if the user is unauthorized
- * - {@link BadContentException} if some content or the operation were invalid
- *
- */
- @PostMapping(value = RestEndpoints.DEPUBLISH_RECORDIDS_DATASETID, consumes = {
- MediaType.TEXT_PLAIN_VALUE})
- @ResponseStatus(HttpStatus.CREATED)
- public void createRecordIdsToBeDepublished(@RequestHeader("Authorization") String authorization,
- @PathVariable("datasetId") String datasetId, @RequestBody String recordIdsInSeparateLines
- ) throws GenericMetisException {
- final MetisUserView metisUserView = authenticationClient.getUserByAccessTokenInHeader(authorization);
- final int added = depublishRecordIdService
- .addRecordIdsToBeDepublished(metisUserView, datasetId, recordIdsInSeparateLines);
- if (LOGGER.isInfoEnabled()) {
- LOGGER.info("{} Depublish record ids added to dataset with datasetId: {}", added,
- CRLF_PATTERN.matcher(datasetId).replaceAll(""));
- }
- }
-
- /**
- * Adds a list of record ids to be depublished for the dataset - the version for a multipart file.
- *
- * @param authorization the HTTP Authorization header, in the form of a Bearer Access Token.
- * @param datasetId The dataset ID to which the depublish record ids belong.
- * @param recordIdsFile The file containing the record IDs in separate lines.
- * @throws GenericMetisException which can be one of:
- *
- * - {@link NoDatasetFoundException} if the dataset for datasetId was not found.
- * - {@link UserUnauthorizedException} if the user is unauthorized
- * - {@link BadContentException} if some content or the operation were invalid
- *
- * @throws IOException In case something unexpected went wrong reading the request body.
- */
- @PostMapping(value = RestEndpoints.DEPUBLISH_RECORDIDS_DATASETID, consumes = {
- MediaType.MULTIPART_FORM_DATA_VALUE})
- @ResponseStatus(HttpStatus.CREATED)
- public void createRecordIdsToBeDepublished(@RequestHeader("Authorization") String authorization,
- @PathVariable("datasetId") String datasetId,
- @RequestPart("depublicationFile") MultipartFile recordIdsFile
- ) throws GenericMetisException, IOException {
- createRecordIdsToBeDepublished(authorization, datasetId,
- new String(recordIdsFile.getBytes(), StandardCharsets.UTF_8));
- }
-
- /**
- * Deletes a list of record ids from the database. Only record ids that are in a
- * {@link eu.europeana.metis.core.dataset.DepublishRecordId.DepublicationStatus#PENDING_DEPUBLICATION} state will be removed.
- *
- * @param authorization the HTTP Authorization header, in the form of a Bearer Access Token.
- * @param datasetId The dataset ID to which the depublish record ids belong.
- * @param recordIdsInSeparateLines The string containing the record IDs in separate lines.
- * @throws GenericMetisException which can be one of:
- *
- * - {@link NoDatasetFoundException} if the dataset for datasetId was not found.
- * - {@link UserUnauthorizedException} if the user is unauthorized
- * - {@link BadContentException} if some content or the operation were invalid
- *
- */
- @DeleteMapping(value = RestEndpoints.DEPUBLISH_RECORDIDS_DATASETID, consumes = {
- MediaType.TEXT_PLAIN_VALUE})
- @ResponseStatus(HttpStatus.NO_CONTENT)
- public void deletePendingRecordIds(@RequestHeader("Authorization") String authorization,
- @PathVariable("datasetId") String datasetId, @RequestBody String recordIdsInSeparateLines
- ) throws GenericMetisException {
- final MetisUserView metisUserView = authenticationClient.getUserByAccessTokenInHeader(authorization);
- final Long removedRecordIds = depublishRecordIdService
- .deletePendingRecordIds(metisUserView, datasetId, recordIdsInSeparateLines);
- if (LOGGER.isInfoEnabled()) {
- LOGGER.info("{} Depublish record ids removed from database with datasetId: {}",
- removedRecordIds, CRLF_PATTERN.matcher(datasetId).replaceAll(""));
- }
- }
-
- /**
- * Retrieve the list of depublish record ids for a specific dataset.
- *
- * @param authorization the HTTP Authorization header, in the form of a Bearer Access Token.
- * @param datasetId The ID of the dataset for which to retrieve the records.
- * @param page The page to retrieve.
- * @param sortField The field on which to sort.
- * @param sortAscending The direction in which to sort.
- * @param searchQuery Search query for the record ID.
- * @return The list of records along with some other information regarding the depublication.
- * @throws GenericMetisException which can be one of:
- *
- * - {@link NoDatasetFoundException} if the dataset for datasetId was not found.
- * - {@link UserUnauthorizedException} if the user is unauthorized
- *
- */
- @GetMapping(value = RestEndpoints.DEPUBLISH_RECORDIDS_DATASETID, produces = {
- MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
- @ResponseStatus(HttpStatus.OK)
- @ResponseBody
- public DepublicationInfoView getDepublishRecordIds(
- @RequestHeader("Authorization") String authorization,
- @PathVariable("datasetId") String datasetId,
- @RequestParam(value = "page", defaultValue = "0") int page,
- @RequestParam(value = "sortField", required = false) DepublishRecordIdSortField sortField,
- @RequestParam(value = "sortAscending", defaultValue = "" + true) boolean sortAscending,
- @RequestParam(value = "searchQuery", required = false) String searchQuery
- ) throws GenericMetisException {
- final MetisUserView metisUserView = authenticationClient.getUserByAccessTokenInHeader(authorization);
- final var recordIds = depublishRecordIdService.getDepublishRecordIds(metisUserView, datasetId, page,
- sortField == null ? DepublishRecordIdSortField.RECORD_ID : sortField,
- sortAscending ? SortDirection.ASCENDING : SortDirection.DESCENDING, searchQuery);
- final var canDepublish = depublishRecordIdService.canTriggerDepublication(metisUserView, datasetId);
- return new DepublicationInfoView(recordIds, canDepublish);
- }
-
- /**
- * Does checking, prepares and adds a WorkflowExecution with a single Depublish step in the queue. That means it updates the
- * status of the WorkflowExecution to {@link eu.europeana.metis.core.workflow.WorkflowStatus#INQUEUE}, adds it to the database
- * and also it's identifier goes into the distributed queue of WorkflowExecutions.
- *
- * @param authorization the authorization header with the access token
- * @param datasetId the dataset identifier for which the execution will take place
- * @param datasetDepublish true for dataset depublication, false for record depublication
- * @param priority the priority of the execution in case the system gets overloaded, 0 lowest, 10 highest
- * @param recordIdsInSeparateLines the specific pending record ids to depublish. Only record ids that are marked as
- * {@link eu.europeana.metis.core.dataset.DepublishRecordId.DepublicationStatus#PENDING_DEPUBLICATION} in the database will be
- * attempted for depublication.
- * @return the WorkflowExecution object that was generated
- * @throws GenericMetisException which can be one of:
- *
- * - {@link BadContentException} if the workflow is empty or no plugin enabled
- * - {@link eu.europeana.metis.core.exceptions.NoDatasetFoundException} if the dataset
- * identifier provided does not exist
- * - {@link eu.europeana.metis.exception.UserUnauthorizedException} if the user is not
- * authenticated or authorized to perform this operation
- * - {@link eu.europeana.metis.exception.ExternalTaskException} if there was an exception when
- * contacting the external resource(ECloud)
- * - {@link eu.europeana.metis.core.exceptions.PluginExecutionNotAllowed} if the execution of
- * the first plugin was not allowed, because a valid source plugin could not be found
- * - {@link eu.europeana.metis.core.exceptions.WorkflowExecutionAlreadyExistsException} if a
- * workflow execution for the generated execution identifier already exists, almost impossible to
- * happen since ids are UUIDs
- *
- */
- @PostMapping(value = RestEndpoints.DEPUBLISH_EXECUTE_DATASETID, produces = {
- MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
- @ResponseStatus(HttpStatus.CREATED)
- @ResponseBody
- public WorkflowExecution addDepublishWorkflowInQueueOfWorkflowExecutions(
- @RequestHeader("Authorization") String authorization,
- @PathVariable("datasetId") String datasetId,
- @RequestParam(value = "datasetDepublish", defaultValue = "" + true) boolean datasetDepublish,
- @RequestParam(value = "priority", defaultValue = "0") int priority,
- @RequestBody(required = false) String recordIdsInSeparateLines)
- throws GenericMetisException {
- MetisUserView metisUserView = authenticationClient.getUserByAccessTokenInHeader(authorization);
- return depublishRecordIdService
- .createAndAddInQueueDepublishWorkflowExecution(metisUserView, datasetId,
- datasetDepublish, priority, recordIdsInSeparateLines);
- }
-}
diff --git a/metis-core/metis-core-rest/src/main/java/eu/europeana/metis/core/rest/controller/OrchestratorController.java b/metis-core/metis-core-rest/src/main/java/eu/europeana/metis/core/rest/controller/OrchestratorController.java
deleted file mode 100644
index 53a5a302a9..0000000000
--- a/metis-core/metis-core-rest/src/main/java/eu/europeana/metis/core/rest/controller/OrchestratorController.java
+++ /dev/null
@@ -1,616 +0,0 @@
-package eu.europeana.metis.core.rest.controller;
-
-import eu.europeana.metis.authentication.rest.client.AuthenticationClient;
-import eu.europeana.metis.authentication.user.MetisUserView;
-import eu.europeana.metis.core.common.DaoFieldNames;
-import eu.europeana.metis.core.dataset.DatasetExecutionInformation;
-import eu.europeana.metis.core.rest.ExecutionHistory;
-import eu.europeana.metis.core.rest.IncrementalHarvestingAllowedView;
-import eu.europeana.metis.core.rest.PluginsWithDataAvailability;
-import eu.europeana.metis.core.rest.ResponseListWrapper;
-import eu.europeana.metis.core.rest.VersionEvolution;
-import eu.europeana.metis.core.rest.execution.details.WorkflowExecutionView;
-import eu.europeana.metis.core.rest.execution.overview.ExecutionAndDatasetView;
-import eu.europeana.metis.core.service.OrchestratorService;
-import eu.europeana.metis.core.workflow.Workflow;
-import eu.europeana.metis.core.workflow.WorkflowExecution;
-import eu.europeana.metis.core.workflow.WorkflowStatus;
-import eu.europeana.metis.core.workflow.plugins.ExecutablePluginType;
-import eu.europeana.metis.core.workflow.plugins.MetisPlugin;
-import eu.europeana.metis.core.workflow.plugins.PluginStatus;
-import eu.europeana.metis.core.workflow.plugins.PluginType;
-import eu.europeana.metis.exception.BadContentException;
-import eu.europeana.metis.exception.GenericMetisException;
-import eu.europeana.metis.utils.CommonStringValues;
-import eu.europeana.metis.utils.RestEndpoints;
-import java.util.Date;
-import java.util.Set;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.format.annotation.DateTimeFormat;
-import org.springframework.format.annotation.DateTimeFormat.ISO;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.MediaType;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestHeader;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.ResponseStatus;
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * Contains all the calls that are related to Orchestration.
- * The {@link OrchestratorService} has control on how to orchestrate different components of the
- * system
- */
-@RestController
-public class OrchestratorController {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(OrchestratorController.class);
- private final OrchestratorService orchestratorService;
- private final AuthenticationClient authenticationClient;
-
- /**
- * Autowired constructor with all required parameters.
- *
- * @param orchestratorService the orchestratorService object
- * @param authenticationClient the client for the authentication service
- */
- @Autowired
- public OrchestratorController(OrchestratorService orchestratorService,
- AuthenticationClient authenticationClient) {
- this.orchestratorService = orchestratorService;
- this.authenticationClient = authenticationClient;
- }
-
- /**
- * Create a workflow using a datasetId and the {@link Workflow} that contains the requested plugins. If plugins are disabled,
- * they (their settings) are still saved.
- *
- * @param authorization the authorization header with the access token
- * @param datasetId the dataset identifier to relate the workflow to
- * @param enforcedPredecessorType optional, the plugin type to be used as source data
- * @param workflow the Workflow will all it's requested plugins
- * @throws GenericMetisException which can be one of:
- *
- * - {@link eu.europeana.metis.core.exceptions.WorkflowAlreadyExistsException} if a workflow
- * for the dataset identifier provided already exists
- * - {@link eu.europeana.metis.core.exceptions.NoDatasetFoundException} if the dataset
- * identifier provided does not exist
- * - {@link eu.europeana.metis.exception.UserUnauthorizedException} if the user is not
- * authenticated or authorized to perform this operation
- *
- */
- //WORKFLOWS
- @PostMapping(value = RestEndpoints.ORCHESTRATOR_WORKFLOWS_DATASETID, consumes = {
- MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE}, produces = {
- MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
- @ResponseStatus(HttpStatus.CREATED)
- public void createWorkflow(
- @RequestHeader("Authorization") String authorization,
- @PathVariable("datasetId") String datasetId,
- @RequestParam(value = "enforcedPluginType", required = false, defaultValue = "") ExecutablePluginType enforcedPredecessorType,
- @RequestBody Workflow workflow)
- throws GenericMetisException {
- MetisUserView metisUserView = authenticationClient.getUserByAccessTokenInHeader(authorization);
- orchestratorService.createWorkflow(metisUserView, datasetId, workflow, enforcedPredecessorType);
- }
-
- /**
- * Update an already existent workflow using a datasetId and the {@link Workflow} that contains the requested plugins. If
- * plugins are disabled, they (their settings) are still saved. Any settings in plugins that are not sent in the request are
- * removed.
- *
- * @param authorization the authorization header with the access token
- * @param datasetId the identifier of the dataset for which the workflow should be updated
- * @param enforcedPredecessorType optional, the plugin type to be used as source data
- * @param workflow the workflow with the plugins requested
- * @throws GenericMetisException which can be one of:
- *
- * - {@link eu.europeana.metis.core.exceptions.NoWorkflowFoundException} if a workflow for the
- * dataset identifier provided does not exist
- * - {@link eu.europeana.metis.core.exceptions.NoDatasetFoundException} if the dataset
- * identifier provided does not exist
- * - {@link eu.europeana.metis.exception.UserUnauthorizedException} if the user is not
- * authenticated or authorized to perform this operation
- *
- */
- @PutMapping(value = RestEndpoints.ORCHESTRATOR_WORKFLOWS_DATASETID, produces = {
- MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
- @ResponseStatus(HttpStatus.NO_CONTENT)
- public void updateWorkflow(
- @RequestHeader("Authorization") String authorization,
- @PathVariable("datasetId") String datasetId,
- @RequestParam(value = "enforcedPluginType", required = false, defaultValue = "") ExecutablePluginType enforcedPredecessorType,
- @RequestBody Workflow workflow) throws GenericMetisException {
- MetisUserView metisUserView = authenticationClient.getUserByAccessTokenInHeader(authorization);
- orchestratorService.updateWorkflow(metisUserView, datasetId, workflow, enforcedPredecessorType);
- }
-
- /**
- * Deletes a workflow.
- *
- * @param authorization the authorization header with the access token
- * @param datasetId the dataset identifier that corresponds to the workflow to be deleted
- * @throws GenericMetisException which can be one of:
- *
- * - {@link eu.europeana.metis.core.exceptions.NoDatasetFoundException} if the dataset
- * identifier provided does not exist
- * - {@link eu.europeana.metis.exception.UserUnauthorizedException} if the user is not
- * authenticated or authorized to perform this operation
- *
- */
- @DeleteMapping(value = RestEndpoints.ORCHESTRATOR_WORKFLOWS_DATASETID,
- produces = {MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
- @ResponseStatus(HttpStatus.NO_CONTENT)
- public void deleteWorkflow(
- @RequestHeader("Authorization") String authorization,
- @PathVariable("datasetId") String datasetId) throws GenericMetisException {
- MetisUserView metisUserView = authenticationClient.getUserByAccessTokenInHeader(authorization);
- orchestratorService.deleteWorkflow(metisUserView, datasetId);
- if (LOGGER.isInfoEnabled()) {
- LOGGER.info("Workflow with datasetId '{}' deleted",
- datasetId.replaceAll(CommonStringValues.REPLACEABLE_CRLF_CHARACTERS_REGEX, ""));
- }
- }
-
- /**
- * Get a workflow for a dataset identifier.
- *
- * @param authorization the authorization header with the access token
- * @param datasetId the dataset identifier
- * @return the Workflow object
- * @throws GenericMetisException which can be one of:
- *
- * - {@link eu.europeana.metis.core.exceptions.NoDatasetFoundException} if the dataset
- * identifier provided does not exist
- * - {@link eu.europeana.metis.exception.UserUnauthorizedException} if the user is not
- * authenticated or authorized to perform this operation
- *
- */
- @GetMapping(value = RestEndpoints.ORCHESTRATOR_WORKFLOWS_DATASETID, produces = {
- MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
- @ResponseStatus(HttpStatus.OK)
- public Workflow getWorkflow(
- @RequestHeader("Authorization") String authorization,
- @PathVariable("datasetId") String datasetId) throws GenericMetisException {
- MetisUserView metisUserView = authenticationClient.getUserByAccessTokenInHeader(authorization);
- Workflow workflow = orchestratorService.getWorkflow(metisUserView, datasetId);
- if (LOGGER.isInfoEnabled()) {
- LOGGER.info("Workflow with datasetId '{}' found",
- datasetId.replaceAll(CommonStringValues.REPLACEABLE_CRLF_CHARACTERS_REGEX, ""));
- }
- return workflow;
- }
-
- //WORKFLOW EXECUTIONS
-
- /**
- * Does checking, prepares and adds a WorkflowExecution in the queue. That means it updates the status of the WorkflowExecution
- * to {@link WorkflowStatus#INQUEUE}, adds it to the database and also it's identifier goes into the distributed queue of
- * WorkflowExecutions. The source data for the first plugin in the workflow can be controlled, if required, from the
- * {@code enforcedPredecessorType}, which means that the last valid plugin that is provided with that parameter, will be used as
- * the source data.
- *
- * @param authorization the authorization header with the access token
- * @param datasetId the dataset identifier for which the execution will take place
- * @param enforcedPredecessorType optional, the plugin type to be used as source data
- * @param priority the priority of the execution in case the system gets overloaded, 0 lowest, 10 highest
- * @return the WorkflowExecution object that was generated
- * @throws GenericMetisException which can be one of:
- *
- * - {@link eu.europeana.metis.core.exceptions.NoWorkflowFoundException} if a workflow for the
- * dataset identifier provided does not exist
- * - {@link BadContentException} if the workflow is empty or no plugin enabled
- * - {@link eu.europeana.metis.core.exceptions.NoDatasetFoundException} if the dataset
- * identifier provided does not exist
- * - {@link eu.europeana.metis.exception.UserUnauthorizedException} if the user is not
- * authenticated or authorized to perform this operation
- * - {@link eu.europeana.metis.exception.ExternalTaskException} if there was an exception when
- * contacting the external resource(ECloud)
- * - {@link eu.europeana.metis.core.exceptions.PluginExecutionNotAllowed} if the execution of
- * the first plugin was not allowed, because a valid source plugin could not be found
- * - {@link eu.europeana.metis.core.exceptions.WorkflowExecutionAlreadyExistsException} if a
- * workflow execution for the generated execution identifier already exists, almost impossible to
- * happen since ids are UUIDs
- *
- */
- @PostMapping(value = RestEndpoints.ORCHESTRATOR_WORKFLOWS_DATASETID_EXECUTE, produces = {
- MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
- @ResponseStatus(HttpStatus.CREATED)
- public WorkflowExecution addWorkflowInQueueOfWorkflowExecutions(
- @RequestHeader("Authorization") String authorization,
- @PathVariable("datasetId") String datasetId,
- @RequestParam(value = "enforcedPluginType", required = false, defaultValue = "") ExecutablePluginType enforcedPredecessorType,
- @RequestParam(value = "priority", defaultValue = "0") int priority)
- throws GenericMetisException {
- MetisUserView metisUserView = authenticationClient.getUserByAccessTokenInHeader(authorization);
- WorkflowExecution workflowExecution = orchestratorService
- .addWorkflowInQueueOfWorkflowExecutions(metisUserView, datasetId, null, enforcedPredecessorType,
- priority);
- if (LOGGER.isInfoEnabled()) {
- LOGGER.info("WorkflowExecution for datasetId '{}' added to queue",
- datasetId.replaceAll(CommonStringValues.REPLACEABLE_CRLF_CHARACTERS_REGEX, ""));
- }
- return workflowExecution;
- }
-
- /**
- * Request to cancel a workflow execution. The execution will go into a cancelling state until it's properly
- * {@link WorkflowStatus#CANCELLED} from the system
- *
- * @param authorization the authorization header with the access token
- * @param executionId the execution identifier of the execution to cancel
- * @throws GenericMetisException which can be one of:
- *
- * - {@link eu.europeana.metis.core.exceptions.NoWorkflowExecutionFoundException} if no
- * worklfowExecution could be found
- * - {@link eu.europeana.metis.exception.UserUnauthorizedException} if the user is not
- * authenticated or authorized to perform this operation
- * - {@link eu.europeana.metis.core.exceptions.NoDatasetFoundException} if the dataset
- * identifier of the workflow does not exist
- *
- */
- @DeleteMapping(value = RestEndpoints.ORCHESTRATOR_WORKFLOWS_EXECUTIONS_EXECUTIONID, produces = {
- MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
- @ResponseStatus(HttpStatus.NO_CONTENT)
- public void cancelWorkflowExecution(
- @RequestHeader("Authorization") String authorization,
- @PathVariable("executionId") String executionId)
- throws GenericMetisException {
- MetisUserView metisUserView = authenticationClient.getUserByAccessTokenInHeader(authorization);
- orchestratorService.cancelWorkflowExecution(metisUserView, executionId);
- if (LOGGER.isInfoEnabled()) {
- LOGGER.info("WorkflowExecution for executionId '{}' is cancelling",
- executionId.replaceAll(CommonStringValues.REPLACEABLE_CRLF_CHARACTERS_REGEX, ""));
- }
- }
-
- /**
- * Get a WorkflowExecution using an execution identifier.
- *
- * @param authorization the authorization header with the access token
- * @param executionId the execution identifier
- * @return the WorkflowExecution object
- * @throws GenericMetisException which can be one of:
- *
- * - {@link eu.europeana.metis.core.exceptions.NoDatasetFoundException} if the dataset
- * identifier provided does not exist
- * - {@link eu.europeana.metis.exception.UserUnauthorizedException} if the user is not
- * authenticated or authorized to perform this operation
- *
- */
- @GetMapping(value = RestEndpoints.ORCHESTRATOR_WORKFLOWS_EXECUTIONS_EXECUTIONID, produces = {
- MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
- @ResponseStatus(HttpStatus.OK)
- public WorkflowExecution getWorkflowExecutionByExecutionId(
- @RequestHeader("Authorization") String authorization,
- @PathVariable("executionId") String executionId) throws GenericMetisException {
- MetisUserView metisUserView = authenticationClient.getUserByAccessTokenInHeader(authorization);
- WorkflowExecution workflowExecution = orchestratorService
- .getWorkflowExecutionByExecutionId(metisUserView, executionId);
- if (LOGGER.isInfoEnabled()) {
- LOGGER.info("WorkflowExecution with executionId '{}' {}found.",
- executionId.replaceAll(CommonStringValues.REPLACEABLE_CRLF_CHARACTERS_REGEX, ""),
- workflowExecution == null ? "not " : "");
- }
- return workflowExecution;
- }
-
- /**
- * This method returns whether currently it is permitted/possible to perform incremental harvesting for the given dataset.
- *
- * @param authorization the authorization header with the access token
- * @param datasetId The ID of the dataset for which to check.
- * @return Whether we can perform incremental harvesting for the dataset.
- * @throws GenericMetisException which can be one of:
- *
- * - {@link eu.europeana.metis.core.exceptions.NoDatasetFoundException} if the dataset
- * identifier provided does not exist
- * - {@link eu.europeana.metis.exception.UserUnauthorizedException} if the user is not
- * authenticated or authorized to perform this task
- *
- */
- @GetMapping(value = RestEndpoints.ORCHESTRATOR_WORKFLOWS_EXECUTIONS_DATASET_DATASETID_ALLOWED_INCREMENTAL, produces = {
- MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
- @ResponseStatus(HttpStatus.OK)
- public IncrementalHarvestingAllowedView isIncrementalHarvestingAllowed(
- @RequestHeader("Authorization") String authorization,
- @PathVariable("datasetId") String datasetId) throws GenericMetisException {
- final MetisUserView metisUserView = authenticationClient.getUserByAccessTokenInHeader(authorization);
- return new IncrementalHarvestingAllowedView(
- orchestratorService.isIncrementalHarvestingAllowed(metisUserView, datasetId));
- }
-
- /**
- * Check if a specified {@code pluginType} is allowed for execution. This is checked based on, if there was a previous
- * successful finished plugin that follows a specific order (unless the {@code enforcedPredecessorType} is used) and that has
- * the latest successful harvest plugin as an ancestor.
- *
- * @param authorization the authorization header with the access token
- * @param datasetId the dataset identifier of which the executions are based on
- * @param pluginType the pluginType to be checked for allowance of execution
- * @param enforcedPredecessorType optional, the plugin type to be used as source data
- * @return the abstractMetisPlugin that the execution on {@code pluginType} will be based on. Can be null if the
- * {@code pluginType} is the first one in the total order of executions e.g. One of the harvesting plugins.
- * @throws GenericMetisException which can be one of:
- *
- * - {@link eu.europeana.metis.core.exceptions.PluginExecutionNotAllowed} if the no plugin was
- * found so the {@code pluginType} will be based upon.
- * - {@link eu.europeana.metis.core.exceptions.NoDatasetFoundException} if the dataset
- * identifier provided does not exist
- * - {@link eu.europeana.metis.exception.UserUnauthorizedException} if the user is not
- * authenticated or authorized to perform this operation
- *
- */
- @GetMapping(value = RestEndpoints.ORCHESTRATOR_WORKFLOWS_EXECUTIONS_DATASET_DATASETID_ALLOWED_PLUGIN, produces = {
- MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
- @ResponseStatus(HttpStatus.OK)
- public MetisPlugin getLatestFinishedPluginWorkflowExecutionByDatasetIdIfPluginTypeAllowedForExecution(
- @RequestHeader("Authorization") String authorization,
- @PathVariable("datasetId") String datasetId,
- @RequestParam("pluginType") ExecutablePluginType pluginType,
- @RequestParam(value = "enforcedPluginType", required = false, defaultValue = "") ExecutablePluginType enforcedPredecessorType)
- throws GenericMetisException {
- MetisUserView metisUserView = authenticationClient.getUserByAccessTokenInHeader(authorization);
- MetisPlugin latestFinishedPluginWorkflowExecutionByDatasetId = orchestratorService
- .getLatestFinishedPluginByDatasetIdIfPluginTypeAllowedForExecution(metisUserView, datasetId,
- pluginType, enforcedPredecessorType);
- if (latestFinishedPluginWorkflowExecutionByDatasetId == null) {
- LOGGER.info("PluginType allowed by default");
- } else {
- LOGGER.info("Latest Plugin WorkflowExecution with id '{}' found",
- latestFinishedPluginWorkflowExecutionByDatasetId.getId());
- }
- return latestFinishedPluginWorkflowExecutionByDatasetId;
- }
-
- /**
- * Retrieve dataset level information of past executions {@link DatasetExecutionInformation}
- *
- * @param authorization the authorization header with the access token
- * @param datasetId the dataset identifier to generate the information for
- * @return the structured class containing all the execution information
- * @throws GenericMetisException which can be one of:
- *
- * - {@link eu.europeana.metis.core.exceptions.NoDatasetFoundException} if the dataset
- * identifier provided does not exist
- * - {@link eu.europeana.metis.exception.UserUnauthorizedException} if the user is not
- * authenticated or authorized to perform this operation
- *
- */
- @GetMapping(value = RestEndpoints.ORCHESTRATOR_WORKFLOWS_EXECUTIONS_DATASET_DATASETID_INFORMATION, produces = {
- MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
- @ResponseStatus(HttpStatus.OK)
- public DatasetExecutionInformation getDatasetExecutionInformation(
- @RequestHeader("Authorization") String authorization,
- @PathVariable("datasetId") String datasetId) throws GenericMetisException {
- if (LOGGER.isInfoEnabled()) {
- LOGGER.debug("Requesting dataset execution information for datasetId: {}",
- datasetId.replaceAll(CommonStringValues.REPLACEABLE_CRLF_CHARACTERS_REGEX, ""));
- }
- MetisUserView metisUserView = authenticationClient.getUserByAccessTokenInHeader(authorization);
- return orchestratorService.getDatasetExecutionInformation(metisUserView, datasetId);
- }
-
- /**
- * Get all WorkflowExecutions paged.
- *
- * @param authorization the authorization header with the access token
- * @param datasetId the dataset identifier filter
- * @param workflowStatuses a set of workflow statuses to filter, can be empty or null
- * @param orderField the field to be used to sort the results
- * @param ascending a boolean value to request the ordering to ascending or descending
- * @param nextPage the nextPage token, the end of the list is marked with -1 on the response
- * @return a list of all the WorkflowExecutions found
- * @throws GenericMetisException which can be one of:
- *
- * - {@link BadContentException} if paging is not correctly provided
- * - {@link eu.europeana.metis.core.exceptions.NoDatasetFoundException} if the dataset
- * identifier provided does not exist
- * - {@link eu.europeana.metis.exception.UserUnauthorizedException} if the user is not
- * authenticated or authorized to perform this operation
- *
- */
- @GetMapping(value = RestEndpoints.ORCHESTRATOR_WORKFLOWS_EXECUTIONS_DATASET_DATASETID, produces = {
- MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
- @ResponseStatus(HttpStatus.OK)
- public ResponseListWrapper getAllWorkflowExecutionsByDatasetId(
- @RequestHeader("Authorization") String authorization,
- @PathVariable("datasetId") String datasetId,
- @RequestParam(value = "workflowStatus", required = false) Set workflowStatuses,
- @RequestParam(value = "orderField", required = false, defaultValue = "ID") DaoFieldNames orderField,
- @RequestParam(value = "ascending", required = false, defaultValue = "true") boolean ascending,
- @RequestParam(value = "nextPage", required = false, defaultValue = "0") int nextPage)
- throws GenericMetisException {
- if (nextPage < 0) {
- throw new BadContentException(CommonStringValues.NEXT_PAGE_CANNOT_BE_NEGATIVE);
- }
- final MetisUserView metisUserView = authenticationClient.getUserByAccessTokenInHeader(authorization);
- final ResponseListWrapper result =
- orchestratorService.getAllWorkflowExecutions(metisUserView, datasetId, workflowStatuses,
- orderField, ascending, nextPage);
- logPaging(result, nextPage);
- return result;
- }
-
- /**
- * Get all WorkflowExecutions paged. Not filtered by datasetId.
- *
- * TODO JV This endpoint is no longer in use. Consider removing it.
- *
- * @param authorization the authorization header with the access token
- * @param workflowStatuses a set of workflow statuses to filter, can be empty or null
- * @param orderField the field to be used to sort the results
- * @param ascending a boolean value to request the ordering to ascending or descending
- * @param nextPage the nextPage token, the end of the list is marked with -1 on the response
- * @return a list of all the WorkflowExecutions found
- * @throws GenericMetisException which can be one of:
- *
- * - {@link BadContentException} if paging is not correctly provided
- * - {@link eu.europeana.metis.exception.UserUnauthorizedException} if the user is not
- * authenticated or authorized to perform this operation
- *
- */
- @GetMapping(value = RestEndpoints.ORCHESTRATOR_WORKFLOWS_EXECUTIONS, produces = {
- MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
- @ResponseStatus(HttpStatus.OK)
- public ResponseListWrapper getAllWorkflowExecutions(
- @RequestHeader("Authorization") String authorization,
- @RequestParam(value = "workflowStatus", required = false) Set workflowStatuses,
- @RequestParam(value = "orderField", required = false, defaultValue = "ID") DaoFieldNames orderField,
- @RequestParam(value = "ascending", required = false, defaultValue = "true") boolean ascending,
- @RequestParam(value = "nextPage", required = false, defaultValue = "0") int nextPage)
- throws GenericMetisException {
- if (nextPage < 0) {
- throw new BadContentException(CommonStringValues.NEXT_PAGE_CANNOT_BE_NEGATIVE);
- }
- final MetisUserView metisUserView = authenticationClient.getUserByAccessTokenInHeader(authorization);
- final ResponseListWrapper result =
- orchestratorService.getAllWorkflowExecutions(metisUserView, null, workflowStatuses, orderField,
- ascending, nextPage);
- logPaging(result, nextPage);
- return result;
- }
-
- /**
- * Get the overview of WorkflowExecutions. This returns a list of executions ordered to display an overview. First the ones in
- * queue, then those in progress and then those that are finalized. They will be sorted by creation date. This method does
- * support pagination.
- *
- * @param authorization the authorization header with the access token
- * @param pluginStatuses the plugin statuses to filter. Can be null.
- * @param pluginTypes the plugin types to filter. Can be null.
- * @param fromDate the date from where the results should start. Can be null.
- * @param toDate the date to where the results should end. Can be null.
- * @param nextPage the nextPage token, the end of the list is marked with -1 on the response
- * @param pageCount the number of pages that is requested
- * @return a list of all the WorkflowExecutions together with the datasets that they belong to.
- * @throws GenericMetisException which can be one of:
- *
- * - {@link BadContentException} if paging is not correctly provided
- * - {@link eu.europeana.metis.exception.UserUnauthorizedException} if the user is not
- * authenticated or authorized to perform this operation
- *
- */
- @GetMapping(value = RestEndpoints.ORCHESTRATOR_WORKFLOWS_EXECUTIONS_OVERVIEW, produces = {
- MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
- @ResponseStatus(HttpStatus.OK)
- public ResponseListWrapper getWorkflowExecutionsOverview(
- @RequestHeader("Authorization") String authorization,
- @RequestParam(value = "pluginStatus", required = false) Set pluginStatuses,
- @RequestParam(value = "pluginType", required = false) Set pluginTypes,
- @RequestParam(value = "fromDate", required = false) @DateTimeFormat(iso = ISO.DATE_TIME) Date fromDate,
- @RequestParam(value = "toDate", required = false) @DateTimeFormat(iso = ISO.DATE_TIME) Date toDate,
- @RequestParam(value = "nextPage", required = false, defaultValue = "0") int nextPage,
- @RequestParam(value = "pageCount", required = false, defaultValue = "1") int pageCount)
- throws GenericMetisException {
- if (nextPage < 0) {
- throw new BadContentException(CommonStringValues.NEXT_PAGE_CANNOT_BE_NEGATIVE);
- }
- if (pageCount < 1) {
- throw new BadContentException(CommonStringValues.PAGE_COUNT_CANNOT_BE_ZERO_OR_NEGATIVE);
- }
- final MetisUserView metisUserView = authenticationClient.getUserByAccessTokenInHeader(authorization);
- final ResponseListWrapper result =
- orchestratorService.getWorkflowExecutionsOverview(metisUserView, pluginStatuses, pluginTypes,
- fromDate, toDate, nextPage, pageCount);
- logPaging(result, nextPage);
- return result;
- }
-
- private static void logPaging(ResponseListWrapper> responseListWrapper, int nextPage) {
- LOGGER.debug("Batch of: {} workflowExecutions returned, using batch nextPage: {}",
- responseListWrapper.getListSize(), nextPage);
- }
-
- /**
- * Retrieve dataset level history of past executions {@link ExecutionHistory}
- *
- * @param authorization the authorization header with the access token
- * @param datasetId the dataset identifier to generate the history for
- * @return the structured class containing all the execution history, ordered by date descending.
- * @throws GenericMetisException which can be one of:
- *
- * - {@link eu.europeana.metis.core.exceptions.NoDatasetFoundException} if the dataset
- * identifier provided does not exist
- * - {@link eu.europeana.metis.exception.UserUnauthorizedException} if the user is not
- * authenticated or authorized to perform this operation
- *
- */
- @GetMapping(value = RestEndpoints.ORCHESTRATOR_WORKFLOWS_EXECUTIONS_DATASET_DATASETID_HISTORY, produces = {
- MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
- @ResponseStatus(HttpStatus.OK)
- public ExecutionHistory getDatasetExecutionHistory(
- @RequestHeader("Authorization") String authorization,
- @PathVariable("datasetId") String datasetId) throws GenericMetisException {
- if (LOGGER.isInfoEnabled()) {
- LOGGER.debug("Requesting dataset execution history for datasetId: {}",
- datasetId.replaceAll(CommonStringValues.REPLACEABLE_CRLF_CHARACTERS_REGEX, ""));
- }
- final MetisUserView metisUserView = authenticationClient.getUserByAccessTokenInHeader(authorization);
- return orchestratorService.getDatasetExecutionHistory(metisUserView, datasetId);
- }
-
- /**
- * Retrieve a list of executable plugins with data availability {@link PluginsWithDataAvailability} for a given workflow
- * execution.
- *
- * @param authorization the authorization header with the access token
- * @param executionId the identifier of the execution for which to get the plugins
- * @return the structured class containing all the execution history, ordered by date descending.
- * @throws GenericMetisException which can be one of:
- *
- * - {@link eu.europeana.metis.core.exceptions.NoWorkflowExecutionFoundException} if an
- * non-existing execution ID or version is provided.
- * - {@link eu.europeana.metis.exception.UserUnauthorizedException} if the user is not
- * authenticated or authorized to perform this operation
- *
- */
- @GetMapping(value = RestEndpoints.ORCHESTRATOR_WORKFLOWS_EXECUTIONS_EXECUTIONID_PLUGINS_DATA_AVAILABILITY, produces = {
- MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
- @ResponseStatus(HttpStatus.OK)
- public PluginsWithDataAvailability getExecutablePluginsWithDataAvailability(
- @RequestHeader("Authorization") String authorization,
- @PathVariable("executionId") String executionId) throws GenericMetisException {
- if (LOGGER.isInfoEnabled()) {
- final String logSanitizedExecutionId = executionId.replaceAll("[\r\n]", "");
- LOGGER.debug("Requesting plugins with data availability for executionId: {}", logSanitizedExecutionId);
- }
- final MetisUserView metisUserView = authenticationClient.getUserByAccessTokenInHeader(authorization);
- return orchestratorService.getExecutablePluginsWithDataAvailability(metisUserView, executionId);
- }
-
- /**
- * Get the evolution of the records from when they were first imported until (and excluding) the specified version.
- *
- * @param authorization The authorization header with the access token
- * @param workflowExecutionId The ID of the workflow exection in which the version is created.
- * @param pluginType The step within the workflow execution that created the version.
- * @return The record evolution.
- * @throws GenericMetisException which can be one of:
- *
- * - {@link eu.europeana.metis.core.exceptions.NoWorkflowExecutionFoundException} if an
- * non-existing execution ID or version is provided.
- * - {@link eu.europeana.metis.exception.UserUnauthorizedException} if the user is not
- * authenticated or authorized to perform this operation
- *
- */
- @GetMapping(value = RestEndpoints.ORCHESTRATOR_WORKFLOWS_EVOLUTION, produces = {
- MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
- @ResponseStatus(HttpStatus.OK)
- public VersionEvolution getRecordEvolutionForVersion(
- @RequestHeader("Authorization") String authorization,
- @PathVariable("workflowExecutionId") String workflowExecutionId,
- @PathVariable("pluginType") PluginType pluginType
- ) throws GenericMetisException {
- final MetisUserView metisUserView = authenticationClient.getUserByAccessTokenInHeader(authorization);
- return orchestratorService
- .getRecordEvolutionForVersion(metisUserView, workflowExecutionId, pluginType);
- }
-}
diff --git a/metis-core/metis-core-rest/src/main/java/eu/europeana/metis/core/rest/controller/ProxiesController.java b/metis-core/metis-core-rest/src/main/java/eu/europeana/metis/core/rest/controller/ProxiesController.java
deleted file mode 100644
index 355138edaf..0000000000
--- a/metis-core/metis-core-rest/src/main/java/eu/europeana/metis/core/rest/controller/ProxiesController.java
+++ /dev/null
@@ -1,376 +0,0 @@
-package eu.europeana.metis.core.rest.controller;
-
-import eu.europeana.cloud.common.model.dps.SubTaskInfo;
-import eu.europeana.cloud.common.model.dps.TaskErrorsInfo;
-import eu.europeana.metis.authentication.rest.client.AuthenticationClient;
-import eu.europeana.metis.authentication.user.MetisUserView;
-import eu.europeana.metis.core.rest.ListOfIds;
-import eu.europeana.metis.core.rest.Record;
-import eu.europeana.metis.core.rest.RecordsResponse;
-import eu.europeana.metis.core.rest.stats.NodePathStatistics;
-import eu.europeana.metis.core.rest.stats.RecordStatistics;
-import eu.europeana.metis.core.service.ProxiesService;
-import eu.europeana.metis.core.workflow.plugins.ExecutablePluginType;
-import eu.europeana.metis.core.workflow.plugins.PluginType;
-import eu.europeana.metis.exception.GenericMetisException;
-import eu.europeana.metis.utils.CommonStringValues;
-import eu.europeana.metis.utils.RestEndpoints;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import org.apache.commons.lang3.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.MediaType;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestHeader;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.ResponseStatus;
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * Proxies Controller which encapsulates functionality that has to be proxied to an external resource.
- */
-@RestController
-public class ProxiesController {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(ProxiesController.class);
- private static final int NUMBER_OF_RECORDS = 5;
- private final ProxiesService proxiesService;
- private final AuthenticationClient authenticationClient;
-
- /**
- * Constructor with required parameters
- *
- * @param proxiesService {@link ProxiesService}
- * @param authenticationClient the client for the authentication service
- */
- @Autowired
- public ProxiesController(ProxiesService proxiesService,
- AuthenticationClient authenticationClient) {
- this.proxiesService = proxiesService;
- this.authenticationClient = authenticationClient;
- }
-
- /**
- * Get logs from a specific topology task paged.
- *
- * @param authorization the authorization header with the access token
- * @param topologyName the topology name of the task
- * @param externalTaskId the task identifier
- * @param from integer to start getting logs from
- * @param to integer until where logs should be received
- * @return the list of logs
- * @throws GenericMetisException can be one of:
- *
- * - {@link eu.europeana.cloud.service.dps.exception.DpsException} if an error occurred while
- * retrieving the logs from the external resource
- * - {@link eu.europeana.metis.core.exceptions.NoWorkflowExecutionFoundException} if no
- * workflow execution exists for the provided external task identifier
- * - {@link eu.europeana.metis.exception.UserUnauthorizedException} if the user is not
- * authenticated or authorized to perform this operation
- *
- */
- @GetMapping(value = RestEndpoints.ORCHESTRATOR_PROXIES_TOPOLOGY_TASK_LOGS, produces = {
- MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
- @ResponseStatus(HttpStatus.OK)
- public List getExternalTaskLogs(
- @RequestHeader("Authorization") String authorization,
- @PathVariable("topologyName") String topologyName,
- @PathVariable("externalTaskId") long externalTaskId,
- @RequestParam(value = "from") int from,
- @RequestParam(value = "to") int to) throws GenericMetisException {
- if (LOGGER.isInfoEnabled()) {
- LOGGER.info(
- "Requesting proxy call task logs for topologyName: {}, externalTaskId: {}, from: {}, to: {}",
- topologyName.replaceAll(CommonStringValues.REPLACEABLE_CRLF_CHARACTERS_REGEX, ""),
- externalTaskId, from, to);
- }
- final MetisUserView metisUserView = authenticationClient.getUserByAccessTokenInHeader(authorization);
- return proxiesService.getExternalTaskLogs(metisUserView, topologyName, externalTaskId, from, to);
- }
-
- /**
- * Check if final report is available.
- *
- * @param authorization the authorization header with the access token
- * @param topologyName the topology name of the task
- * @param externalTaskId the task identifier
- * @return true if final report available, false if not or ecloud response {@link jakarta.ws.rs.core.Response.Status)} is not
- * OK, based on {@link eu.europeana.cloud.client.dps.rest.DpsClient#checkIfErrorReportExists}
- * @throws GenericMetisException can be one of:
- *
- * - {@link eu.europeana.metis.core.exceptions.NoWorkflowExecutionFoundException} if no
- * workflow execution exists for the provided external task identifier
- * - {@link eu.europeana.metis.exception.UserUnauthorizedException} if the user is not
- * authenticated or authorized to perform this operation
- *
- */
- @GetMapping(value = RestEndpoints.ORCHESTRATOR_PROXIES_TOPOLOGY_TASK_REPORT_EXISTS, produces = {
- MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
- @ResponseStatus(HttpStatus.OK)
- public Map existsExternalTaskReport(
- @RequestHeader("Authorization") String authorization,
- @PathVariable("topologyName") String topologyName,
- @PathVariable("externalTaskId") long externalTaskId) throws GenericMetisException {
- if (LOGGER.isInfoEnabled()) {
- LOGGER.info(
- "Requesting proxy call to check if task report exists for topologyName: {}, externalTaskId: {}",
- topologyName.replaceAll(CommonStringValues.REPLACEABLE_CRLF_CHARACTERS_REGEX, ""),
- externalTaskId);
- }
- final MetisUserView metisUserView = authenticationClient.getUserByAccessTokenInHeader(authorization);
- return Collections.singletonMap("existsExternalTaskReport",
- proxiesService.existsExternalTaskReport(metisUserView, topologyName, externalTaskId));
- }
-
- /**
- * Get the final report that includes all the errors grouped. The number of ids per error can be specified through the
- * parameters.
- *
- * @param authorization the authorization header with the access token
- * @param topologyName the topology name of the task
- * @param externalTaskId the task identifier
- * @param idsPerError the number of ids that should be displayed per error group
- * @return the list of errors grouped
- * @throws GenericMetisException can be one of:
- *
- * - {@link eu.europeana.cloud.service.dps.exception.DpsException} if an error occurred while
- * retrieving the report from the external resource
- * - {@link eu.europeana.metis.core.exceptions.NoWorkflowExecutionFoundException} if no
- * workflow execution exists for the provided external task identifier
- * - {@link eu.europeana.metis.exception.UserUnauthorizedException} if the user is not
- * authenticated or authorized to perform this operation
- *
- */
- @GetMapping(value = RestEndpoints.ORCHESTRATOR_PROXIES_TOPOLOGY_TASK_REPORT, produces = {
- MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
- @ResponseStatus(HttpStatus.OK)
- public TaskErrorsInfo getExternalTaskReport(
- @RequestHeader("Authorization") String authorization,
- @PathVariable("topologyName") String topologyName,
- @PathVariable("externalTaskId") long externalTaskId,
- @RequestParam("idsPerError") int idsPerError) throws GenericMetisException {
- if (LOGGER.isInfoEnabled()) {
- LOGGER.info("Requesting proxy call task reports for topologyName: {}, externalTaskId: {}",
- topologyName.replaceAll(CommonStringValues.REPLACEABLE_CRLF_CHARACTERS_REGEX, ""),
- externalTaskId);
- }
- final MetisUserView metisUserView = authenticationClient.getUserByAccessTokenInHeader(authorization);
- return proxiesService
- .getExternalTaskReport(metisUserView, topologyName, externalTaskId, idsPerError);
- }
-
- /**
- * Get the statistics on the given task.
- *
- * @param authorization the authorization header with the access token
- * @param topologyName the topology name of the task
- * @param externalTaskId the task identifier
- * @return the task statistics
- * @throws GenericMetisException can be one of:
- *
- * - {@link eu.europeana.cloud.service.dps.exception.DpsException} if an error occurred while
- * retrieving the statistics from the external resource
- * - {@link eu.europeana.metis.core.exceptions.NoWorkflowExecutionFoundException} if no
- * workflow execution exists for the provided external task identifier
- * - {@link eu.europeana.metis.exception.UserUnauthorizedException} if the user is not
- * authenticated or authorized to perform this operation
- *
- */
- @GetMapping(value = RestEndpoints.ORCHESTRATOR_PROXIES_TOPOLOGY_TASK_STATISTICS,
- produces = {MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
- @ResponseStatus(HttpStatus.OK)
- public RecordStatistics getExternalTaskStatistics(
- @RequestHeader("Authorization") String authorization,
- @PathVariable("topologyName") String topologyName,
- @PathVariable("externalTaskId") long externalTaskId) throws GenericMetisException {
- if (LOGGER.isInfoEnabled()) {
- LOGGER.info("Requesting proxy call task statistics for topologyName: {}, externalTaskId: {}",
- topologyName.replaceAll(CommonStringValues.REPLACEABLE_CRLF_CHARACTERS_REGEX, ""),
- externalTaskId);
- }
- final MetisUserView metisUserView = authenticationClient.getUserByAccessTokenInHeader(authorization);
- return proxiesService.getExternalTaskStatistics(metisUserView, topologyName, externalTaskId);
- }
-
- /**
- * Get additional statistics on a node. This method can be used to elaborate on one of the items returned by
- * {@link #getExternalTaskStatistics(String, String, long)}.
- *
- * @param authorization the authorization header with the access token
- * @param topologyName the topology name of the task
- * @param externalTaskId the task identifier
- * @param nodePath the path of the node for which this request is made
- * @return the list of errors grouped
- * @throws GenericMetisException can be one of:
- *
- * - {@link eu.europeana.cloud.service.dps.exception.DpsException} if an error occurred while
- * retrieving the statistics from the external resource
- * - {@link eu.europeana.metis.core.exceptions.NoWorkflowExecutionFoundException} if no
- * workflow execution exists for the provided external task identifier
- * - {@link eu.europeana.metis.exception.UserUnauthorizedException} if the user is not
- * authenticated or authorized to perform this operation
- *
- */
- @GetMapping(value = RestEndpoints.ORCHESTRATOR_PROXIES_TOPOLOGY_TASK_NODE_STATISTICS,
- produces = {MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
- @ResponseStatus(HttpStatus.OK)
- public NodePathStatistics getAdditionalNodeStatistics(
- @RequestHeader("Authorization") String authorization,
- @PathVariable("topologyName") String topologyName,
- @PathVariable("externalTaskId") long externalTaskId,
- @RequestParam("nodePath") String nodePath) throws GenericMetisException {
- if (LOGGER.isInfoEnabled()) {
- LOGGER.info(
- "Requesting proxy call additional node statistics for topologyName: {}, externalTaskId: {}",
- topologyName.replaceAll(CommonStringValues.REPLACEABLE_CRLF_CHARACTERS_REGEX, ""),
- externalTaskId);
- }
- final MetisUserView metisUserView = authenticationClient.getUserByAccessTokenInHeader(authorization);
- return proxiesService
- .getAdditionalNodeStatistics(metisUserView, topologyName, externalTaskId, nodePath);
- }
-
- /**
- * Get a list with record contents from the external resource based on an workflow execution and {@link PluginType}.
- *
- * @param authorization the authorization header with the access token
- * @param workflowExecutionId the execution identifier of the workflow
- * @param pluginType the {@link PluginType} that is to be located inside the workflow
- * @param nextPage the string representation of the next page which is provided from the response and can be used to get the
- * next page of results.
- * TODO: The nextPage parameter is currently ignored and we should decide if we would support it again in the future.
- * @return the list of records from the external resource
- * @throws GenericMetisException can be one of:
- *
- * - {@link eu.europeana.metis.exception.ExternalTaskException} if an error occurred while
- * retrieving the records from the external resource
- * - {@link eu.europeana.metis.core.exceptions.NoWorkflowExecutionFoundException} if no
- * workflow execution exists for the provided identifier
- * - {@link eu.europeana.metis.exception.UserUnauthorizedException} if the user is not
- * authenticated or authorized to perform this operation
- *
- */
- @GetMapping(value = RestEndpoints.ORCHESTRATOR_PROXIES_RECORDS,
- produces = {MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
- @ResponseStatus(HttpStatus.OK)
- public RecordsResponse getListOfFileContentsFromPluginExecution(
- @RequestHeader("Authorization") String authorization,
- @RequestParam("workflowExecutionId") String workflowExecutionId,
- @RequestParam("pluginType") ExecutablePluginType pluginType,
- @RequestParam(value = "nextPage", required = false) String nextPage
- ) throws GenericMetisException {
- final MetisUserView metisUserView = authenticationClient.getUserByAccessTokenInHeader(authorization);
- return proxiesService
- .getListOfFileContentsFromPluginExecution(metisUserView, workflowExecutionId, pluginType,
- StringUtils.isEmpty(nextPage) ? null : nextPage, NUMBER_OF_RECORDS);
- }
-
- /**
- * Get a list with record contents from the external resource for a specific list of IDS based on a workflow execution and
- * {@link PluginType}.
- *
- * @param authorization the authorization header with the access token
- * @param workflowExecutionId the execution identifier of the workflow
- * @param pluginType the {@link ExecutablePluginType} that is to be located inside the workflow
- * @param ecloudIds the list of ecloud IDs of the records we wish to obtain
- * @return the list of records from the external resource matching the input ID list. If no record with the matching ID was
- * found in the given workflow step, no entry for this record will appear in the result list.
- * @throws GenericMetisException can be one of:
- *
- * - {@link eu.europeana.metis.exception.ExternalTaskException} if an error occurred while
- * retrieving the records from the external resource
- * - {@link eu.europeana.metis.exception.UserUnauthorizedException} if the user is not
- * authorized to perform this task
- * - {@link eu.europeana.metis.core.exceptions.NoWorkflowExecutionFoundException} if no workflow
- * execution exists for the provided identifier
- *
- */
- @PostMapping(value = RestEndpoints.ORCHESTRATOR_PROXIES_RECORDS_BY_IDS,
- consumes = {MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE},
- produces = {MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
- @ResponseStatus(HttpStatus.OK)
- public RecordsResponse getListOfFileContentsFromPluginExecution(
- @RequestHeader("Authorization") String authorization,
- @RequestParam("workflowExecutionId") String workflowExecutionId,
- @RequestParam("pluginType") ExecutablePluginType pluginType,
- @RequestBody ListOfIds ecloudIds
- ) throws GenericMetisException {
- final MetisUserView metisUserView = authenticationClient.getUserByAccessTokenInHeader(authorization);
- return proxiesService.getListOfFileContentsFromPluginExecution(metisUserView, workflowExecutionId,
- pluginType, ecloudIds);
- }
-
- /**
- * Get an eCloudId from the external resource for a specific searchId.
- *
- * @param authorization the authorization header with the access token
- * @param workflowExecutionId the execution identifier of the workflow
- * @param idToSearch the ID we are searching for and for which we want to find a record
- * @return the CloudId from the external resource matching the input ID. If no record with the matching ID was found, it will
- * return an empty string.
- * @throws GenericMetisException can be one of:
- *
- * - {@link eu.europeana.metis.exception.ExternalTaskException} if an error occurred while
- * retrieving the records from the external resource
- * - {@link eu.europeana.metis.exception.UserUnauthorizedException} if the user is not
- * authorized to perform this task
- * - {@link eu.europeana.metis.core.exceptions.NoWorkflowExecutionFoundException} if no workflow
- * execution exists for the provided identifier
- *
- */
- @PostMapping(value = RestEndpoints.ORCHESTRATOR_PROXIES_RECORD_SEARCH_BY_ID,
- produces = {MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
- @ResponseStatus(HttpStatus.OK)
- public Record searchRecordByIdFromPluginExecution(
- @RequestHeader("Authorization") String authorization,
- @RequestParam("workflowExecutionId") String workflowExecutionId,
- @RequestParam("pluginType") ExecutablePluginType pluginType,
- @RequestParam("idToSearch") String idToSearch
- ) throws GenericMetisException {
- final MetisUserView metisUserView = authenticationClient.getUserByAccessTokenInHeader(authorization);
- return proxiesService.searchRecordByIdFromPluginExecution(metisUserView, workflowExecutionId, pluginType, idToSearch);
- }
-
- /**
- * Get a list with record contents from the external resource for a specific list of IDS based on a workflow execution and the
- * predecessor of the given {@link PluginType}.
- *
- * @param authorization the authorization header with the access token
- * @param workflowExecutionId the execution identifier of the workflow
- * @param pluginType the {@link ExecutablePluginType} that is to be located inside the workflow
- * @param ecloudIds the list of ecloud IDs of the records we wish to obtain
- * @return the list of records from the external resource matching the input ID list. If no record with the matching ID was
- * found in the given workflow step, no entry for this record will appear in the result list.
- * @throws GenericMetisException can be one of:
- *
- * - {@link eu.europeana.metis.exception.ExternalTaskException} if an error occurred while
- * retrieving the records from the external resource
- * - {@link eu.europeana.metis.exception.UserUnauthorizedException} if the user is not
- * authorized to perform this task
- * - {@link eu.europeana.metis.core.exceptions.NoWorkflowExecutionFoundException} if no workflow
- * execution exists for the provided identifier
- *
- */
- @PostMapping(value = RestEndpoints.ORCHESTRATOR_PROXIES_RECORDS_FROM_PREDECESSOR_PLUGIN,
- consumes = {MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE},
- produces = {MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
- @ResponseStatus(HttpStatus.OK)
- public RecordsResponse getListOfFileContentsFromPredecessorOfPluginExecution(
- @RequestHeader("Authorization") String authorization,
- @RequestParam("workflowExecutionId") String workflowExecutionId,
- @RequestParam("pluginType") ExecutablePluginType pluginType,
- @RequestBody ListOfIds ecloudIds
- ) throws GenericMetisException {
- final MetisUserView metisUserView = authenticationClient.getUserByAccessTokenInHeader(authorization);
- return proxiesService.getListOfFileContentsFromPredecessorPluginExecution(metisUserView, workflowExecutionId, pluginType,
- ecloudIds);
- }
-
-}
diff --git a/metis-core/metis-core-rest/src/main/java/eu/europeana/metis/core/rest/controller/ScheduleWorkflowController.java b/metis-core/metis-core-rest/src/main/java/eu/europeana/metis/core/rest/controller/ScheduleWorkflowController.java
deleted file mode 100644
index 07026db579..0000000000
--- a/metis-core/metis-core-rest/src/main/java/eu/europeana/metis/core/rest/controller/ScheduleWorkflowController.java
+++ /dev/null
@@ -1,159 +0,0 @@
-package eu.europeana.metis.core.rest.controller;
-
-import static eu.europeana.metis.utils.CommonStringValues.CRLF_PATTERN;
-
-import eu.europeana.metis.authentication.rest.client.AuthenticationClient;
-import eu.europeana.metis.authentication.user.MetisUserView;
-import eu.europeana.metis.core.exceptions.NoDatasetFoundException;
-import eu.europeana.metis.core.exceptions.NoWorkflowFoundException;
-import eu.europeana.metis.core.exceptions.ScheduledWorkflowAlreadyExistsException;
-import eu.europeana.metis.core.rest.ResponseListWrapper;
-import eu.europeana.metis.core.service.ScheduleWorkflowService;
-import eu.europeana.metis.core.workflow.ScheduleFrequence;
-import eu.europeana.metis.core.workflow.ScheduledWorkflow;
-import eu.europeana.metis.exception.BadContentException;
-import eu.europeana.metis.exception.GenericMetisException;
-import eu.europeana.metis.exception.UserUnauthorizedException;
-import eu.europeana.metis.utils.CommonStringValues;
-import eu.europeana.metis.utils.RestEndpoints;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.MediaType;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestHeader;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.ResponseStatus;
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * Contains all the calls that are related to scheduling workflows.
- * The {@link ScheduleWorkflowService} has control on how to schedule workflows
- *
- * @author Simon Tzanakis (Simon.Tzanakis@europeana.eu)
- * @since 2018-04-05
- */
-@RestController
-public class ScheduleWorkflowController {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(ScheduleWorkflowController.class);
- private final ScheduleWorkflowService scheduleWorkflowService;
- private final AuthenticationClient authenticationClient;
-
- public ScheduleWorkflowController(ScheduleWorkflowService scheduleWorkflowService,
- AuthenticationClient authenticationClient) {
- this.scheduleWorkflowService = scheduleWorkflowService;
- this.authenticationClient = authenticationClient;
- }
-
- /**
- * Schedules a provided workflow.
- *
- * @param authorization the authorization header with the access token
- * @param scheduledWorkflow the scheduled workflow information
- * @throws GenericMetisException which can be one of:
- *
- * - {@link NoDatasetFoundException} if the dataset does not exist
- * - {@link UserUnauthorizedException} if the user is unauthorized
- * - {@link BadContentException} if some content send was not acceptable
- * - {@link NoWorkflowFoundException} if the workflow for a dataset was not found
- * - {@link ScheduledWorkflowAlreadyExistsException} if a scheduled workflow already exists
- *
- */
- @PostMapping(value = RestEndpoints.ORCHESTRATOR_WORKFLOWS_SCHEDULE, consumes = {
- MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE}, produces = {
- MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
- @ResponseStatus(HttpStatus.CREATED)
- public void scheduleWorkflowExecution(@RequestHeader("Authorization") String authorization,
- @RequestBody ScheduledWorkflow scheduledWorkflow) throws GenericMetisException {
- MetisUserView metisUserView = authenticationClient.getUserByAccessTokenInHeader(authorization);
- scheduleWorkflowService.scheduleWorkflow(metisUserView, scheduledWorkflow);
- if (LOGGER.isInfoEnabled()) {
- LOGGER.info(
- "ScheduledWorkflowExecution for datasetId '{}', pointerDate at '{}', scheduled '{}'",
- CRLF_PATTERN.matcher(scheduledWorkflow.getDatasetId()), scheduledWorkflow.getPointerDate(),
- CRLF_PATTERN.matcher(scheduledWorkflow.getScheduleFrequence().name()).replaceAll(""));
- }
- }
-
- /**
- * Get a scheduled workflow based on datasets identifier.
- *
- * @param authorization the authorization header with the access token
- * @param datasetId the dataset identifier of which a scheduled workflow is to be retrieved
- * @return the scheduled workflow
- * @throws GenericMetisException which can be one of:
- *
- * - {@link UserUnauthorizedException} if user is unauthorized to access the scheduled
- * workflow
- * - {@link NoDatasetFoundException} if dataset identifier does not exist
- *
- */
- @GetMapping(value = RestEndpoints.ORCHESTRATOR_WORKFLOWS_SCHEDULE_DATASETID, produces = {
- MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
- @ResponseStatus(HttpStatus.OK)
- public ScheduledWorkflow getScheduledWorkflow(
- @RequestHeader("Authorization") String authorization,
- @PathVariable("datasetId") String datasetId) throws GenericMetisException {
- MetisUserView metisUserView = authenticationClient.getUserByAccessTokenInHeader(authorization);
- ScheduledWorkflow scheduledWorkflow = scheduleWorkflowService
- .getScheduledWorkflowByDatasetId(metisUserView, datasetId);
- if (LOGGER.isInfoEnabled()) {
- LOGGER.info("ScheduledWorkflow with with datasetId '{}' found",
- datasetId.replaceAll(CommonStringValues.REPLACEABLE_CRLF_CHARACTERS_REGEX, ""));
- }
- return scheduledWorkflow;
- }
-
- @GetMapping(value = RestEndpoints.ORCHESTRATOR_WORKFLOWS_SCHEDULE, produces = {
- MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
- @ResponseStatus(HttpStatus.OK)
- public ResponseListWrapper getAllScheduledWorkflows(
- @RequestHeader("Authorization") String authorization,
- @RequestParam(value = "nextPage", required = false, defaultValue = "0") int nextPage)
- throws GenericMetisException {
-
- if (nextPage < 0) {
- throw new BadContentException(CommonStringValues.NEXT_PAGE_CANNOT_BE_NEGATIVE);
- }
- ResponseListWrapper responseListWrapper = new ResponseListWrapper<>();
- MetisUserView metisUserView = authenticationClient.getUserByAccessTokenInHeader(authorization);
- responseListWrapper.setResultsAndLastPage(scheduleWorkflowService
- .getAllScheduledWorkflows(metisUserView, ScheduleFrequence.NULL, nextPage),
- scheduleWorkflowService.getScheduledWorkflowsPerRequest(), nextPage);
- LOGGER.info("Batch of: {} scheduledWorkflows returned, using batch nextPage: {}",
- responseListWrapper.getListSize(), nextPage);
- return responseListWrapper;
- }
-
- @PutMapping(value = RestEndpoints.ORCHESTRATOR_WORKFLOWS_SCHEDULE, produces = {
- MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
- @ResponseStatus(HttpStatus.NO_CONTENT)
- public void updateScheduledWorkflow(@RequestHeader("Authorization") String authorization,
- @RequestBody ScheduledWorkflow scheduledWorkflow) throws GenericMetisException {
- MetisUserView metisUserView = authenticationClient.getUserByAccessTokenInHeader(authorization);
- scheduleWorkflowService.updateScheduledWorkflow(metisUserView, scheduledWorkflow);
- if (LOGGER.isInfoEnabled()) {
- LOGGER.info("ScheduledWorkflow with with datasetId '{}' updated",
- CRLF_PATTERN.matcher(scheduledWorkflow.getDatasetId()).replaceAll(""));
- }
- }
-
- @DeleteMapping(value = RestEndpoints.ORCHESTRATOR_WORKFLOWS_SCHEDULE_DATASETID, produces = {
- MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
- @ResponseStatus(HttpStatus.NO_CONTENT)
- public void deleteScheduledWorkflowExecution(@RequestHeader("Authorization") String authorization,
- @PathVariable("datasetId") String datasetId) throws GenericMetisException {
- MetisUserView metisUserView = authenticationClient.getUserByAccessTokenInHeader(authorization);
- scheduleWorkflowService.deleteScheduledWorkflow(metisUserView, datasetId);
- if (LOGGER.isInfoEnabled()) {
- LOGGER.info("ScheduledWorkflowExecution for datasetId '{}' deleted",
- datasetId.replaceAll(CommonStringValues.REPLACEABLE_CRLF_CHARACTERS_REGEX, ""));
- }
- }
-}
diff --git a/metis-core/metis-core-rest/src/main/java/eu/europeana/metis/core/rest/exception/RestResponseExceptionHandler.java b/metis-core/metis-core-rest/src/main/java/eu/europeana/metis/core/rest/exception/RestResponseExceptionHandler.java
deleted file mode 100644
index 0a9046ecad..0000000000
--- a/metis-core/metis-core-rest/src/main/java/eu/europeana/metis/core/rest/exception/RestResponseExceptionHandler.java
+++ /dev/null
@@ -1,149 +0,0 @@
-package eu.europeana.metis.core.rest.exception;
-
-import eu.europeana.metis.exception.GenericMetisException;
-import eu.europeana.metis.core.exceptions.NoDatasetFoundException;
-import eu.europeana.metis.core.exceptions.NoWorkflowFoundException;
-import eu.europeana.metis.exception.StructuredExceptionWrapper;
-import jakarta.servlet.http.HttpServletResponse;
-import org.springframework.core.annotation.AnnotationUtils;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.converter.HttpMessageNotReadableException;
-import org.springframework.web.HttpRequestMethodNotSupportedException;
-import org.springframework.web.bind.MissingRequestHeaderException;
-import org.springframework.web.bind.MissingServletRequestParameterException;
-import org.springframework.web.bind.annotation.ControllerAdvice;
-import org.springframework.web.bind.annotation.ExceptionHandler;
-import org.springframework.web.bind.annotation.ResponseBody;
-import org.springframework.web.bind.annotation.ResponseStatus;
-import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
-
-/**
- * {@link ControllerAdvice} class that handles exceptions through spring.
- *
- * @author Simon Tzanakis (Simon.Tzanakis@europeana.eu)
- * @since 2017-05-10
- */
-@ControllerAdvice
-public class RestResponseExceptionHandler {
-
- private static final String AUTHORIZATION_HEADER = "Authorization";
-
- /**
- * Handle metis {@link GenericMetisException} which is one of the many metis exceptions.
- * Some examples e.g. {@link NoDatasetFoundException}, {@link NoWorkflowFoundException}...
- *
- * @param exception the exception thrown
- * @param response the response that should be updated
- * @return {@link StructuredExceptionWrapper} a json friendly class that contains the error
- * message for the client
- */
- @ExceptionHandler(value = {GenericMetisException.class})
- @ResponseBody
- public StructuredExceptionWrapper handleException(Exception exception,
- HttpServletResponse response) {
- final ResponseStatus annotationResponseStatus = AnnotationUtils
- .findAnnotation(exception.getClass(), ResponseStatus.class);
- HttpStatus status = annotationResponseStatus == null ? HttpStatus.INTERNAL_SERVER_ERROR
- : annotationResponseStatus.value();
- response.setStatus(status.value());
- return new StructuredExceptionWrapper(exception.getMessage());
- }
-
- /**
- * Handler for specific classes to overwrite behaviour
- *
- * @param exception the exception thrown
- * @param response the response that should be updated
- * @return {@link StructuredExceptionWrapper} a json friendly class that contains the error
- * message for the client
- */
- @ExceptionHandler(HttpMessageNotReadableException.class)
- @ResponseBody
- public StructuredExceptionWrapper handleMessageNotReadable(
- HttpMessageNotReadableException exception,
- HttpServletResponse response) {
- response.setStatus(HttpStatus.NOT_ACCEPTABLE.value());
- return new StructuredExceptionWrapper(
- "Message body not readable. It is missing or malformed\n" + exception.getMessage());
- }
-
- /**
- * Handler for specific classes to overwrite behaviour
- *
- * @param exception the exception thrown
- * @param response the response that should be updated
- * @return {@link StructuredExceptionWrapper} a json friendly class that contains the error
- * message for the client
- */
- @ExceptionHandler(MissingServletRequestParameterException.class)
- @ResponseBody
- public StructuredExceptionWrapper handleMissingParams(
- MissingServletRequestParameterException exception,
- HttpServletResponse response) {
- response.setStatus(HttpStatus.NOT_ACCEPTABLE.value());
- return new StructuredExceptionWrapper(exception.getParameterName() + " parameter is missing");
- }
-
- /**
- * Handler for specific classes to overwrite behaviour
- *
- * @param exception the exception thrown
- * @param response the response that should be updated
- * @return {@link StructuredExceptionWrapper} a json friendly class that contains the error
- * message for the client
- */
- @ExceptionHandler(HttpRequestMethodNotSupportedException.class)
- @ResponseBody
- public StructuredExceptionWrapper handleMissingParams(
- HttpRequestMethodNotSupportedException exception,
- HttpServletResponse response) {
- response.setStatus(HttpStatus.METHOD_NOT_ALLOWED.value());
- return new StructuredExceptionWrapper("Method not allowed: " + exception.getMessage());
- }
-
- /**
- * Handler for specific classes to overwrite behaviour
- *
- * @param exception the exception thrown
- * @param response the response that should be updated
- * @return {@link StructuredExceptionWrapper} a json friendly class that contains the error
- * message for the client
- */
- @ExceptionHandler(value = {IllegalStateException.class,
- MethodArgumentTypeMismatchException.class})
- @ResponseBody
- public StructuredExceptionWrapper handleMessageNotReadable(Exception exception,
- HttpServletResponse response) {
- response.setStatus(HttpStatus.NOT_ACCEPTABLE.value());
- return new StructuredExceptionWrapper(
- "Request not readable.\n" + exception.getMessage());
- }
-
- /**
- * Handler for specific classes to overwrite behaviour
- *
- * @param exception the exception thrown
- * @param response the response that should be updated
- * @return {@link StructuredExceptionWrapper} a json friendly class that contains the error
- * message for the client
- */
- @ExceptionHandler(value = MissingRequestHeaderException.class)
- @ResponseBody
- public StructuredExceptionWrapper handleMissingRequestHeaderException(
- MissingRequestHeaderException exception,
- HttpServletResponse response) {
-
- final StructuredExceptionWrapper output;
-
- if (AUTHORIZATION_HEADER.equalsIgnoreCase(exception.getHeaderName())) {
- response.setStatus(HttpStatus.UNAUTHORIZED.value());
- output = new StructuredExceptionWrapper(
- "Authorization header is missing in the request.");
- } else {
- output = new StructuredExceptionWrapper(exception.getMessage());
- response.setStatus(HttpStatus.BAD_REQUEST.value());
- }
-
- return output;
- }
-}
diff --git a/metis-core/metis-core-rest/src/main/resources/application.properties.example b/metis-core/metis-core-rest/src/main/resources/application.properties.example
deleted file mode 100644
index fa40cd4634..0000000000
--- a/metis-core/metis-core-rest/src/main/resources/application.properties.example
+++ /dev/null
@@ -1,113 +0,0 @@
-#Spring
-logging.config=/data/logging/log4j2.xml
-#logging.config=log4j2.xml
-server.error.whitelabel.enabled=false
-spring.servlet.multipart.max-file-size=5MB
-spring.servlet.multipart.max-request-size=5MB
-spring.autoconfigure.exclude=\
- org.springframework.boot.autoconfigure.mongo.embedded.EmbeddedMongoAutoConfiguration, \
- org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration, \
- org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration
-
-#Truststore
-truststore.path=
-truststore.password=
-
-#Orchestration
-metis-core.maxConcurrentThreads=1
-metis-core.dpsMonitorCheckIntervalInSeconds=5
-metis-core.dpsConnectTimeoutInMilliseconds=10000
-metis-core.dpsReadTimeoutInMilliseconds=30000
-metis-core.failsafeMarginOfInactivityInSeconds=5
-metis-core.periodicFailsafeCheckInMilliseconds=60000
-metis-core.periodicSchedulerCheckInMilliseconds=90000
-metis-core.pollingTimeoutForCleaningCompletionServiceInMilliseconds=10000
-#If a task passed this cap the task will be cancelled
-metis-core.periodOfNoProcessedRecordsChangeInMinutes=30
-metis-core.threadLimitThrottlingLevelWeak=16
-metis-core.threadLimitThrottlingLevelMedium=8
-metis-core.threadLimitThrottlingLevelStrong=4
-#Use this to specify the FQDN where the application will be hosted under
-metis-core.baseUrl=https://metis-core-rest.test.eanadev.org
-#Use this to specify the maximum execution list length that is served by
-#Metis Core (regardless on whether the list is paginated).
-metis-core.maxServedExecutionListLength=200
-metis-core.maxDepublishRecordIdsPerDataset=1000
-#Use this to specify the default sampling size for Link Checking
-metis-core.linkCheckingDefaultSamplingSize=1000
-#Solr
-metis-core.solrCommitPeriodInMinutes=15
-# Authentication
-metis-core.authenticationBaseUrl=
-# CORS
-metis-core.allowedCorsHosts=
-
-#RabbitMq
-rabbitmq.host=
-rabbitmq.port=
-rabbitmq.username=
-rabbitmq.password=
-rabbitmq.virtualHost=/
-rabbitmq.queueName=UserWorkflowExecution
-rabbitmq.highestPriority=10
-rabbitmq.enableSsl=
-rabbitmq.enableCustomTruststore=
-
-#Mongo
-mongo.hosts=
-mongo.ports=
-mongo.authenticationDatabase=
-mongo.username=
-mongo.password=
-mongo.enableSsl=
-mongo.database=metis-core
-mongo.applicationName=metis-core-local
-
-#Redis
-redis.host=
-redis.port=
-redis.username=
-redis.password=
-redis.enableSsl=
-redis.enableCustomTruststore=
-redis.redisson.connectionPoolSize=16
-redis.redisson.connectTimeoutInSeconds=60
-redis.redisson.lockWatchdogTimeoutInSeconds=120
-#Setting to -1 disables DNS monitoring
-redis.redisson.dnsMonitorIntervalInSeconds=60
-redis.redisson.idleConnectionTimeoutInSeconds=60
-redis.redisson.retryAttempts=10
-
-# ECloud
-ecloud.baseUrl=
-ecloud.dpsBaseUrl=
-ecloud.provider=
-ecloud.username=
-ecloud.password=
-
-#Validation parameters
-validation.validationExternalSchemaZip=
-validation.validationExternalSchemaRoot=
-validation.validationExternalSchematronRoot=
-validation.validationInternalSchemaZip=
-validation.validationInternalSchemaRoot=
-validation.validationInternalSchematronRoot=
-
-#Actuator
-management.endpoint.health.probes.enabled=true
-management.health.livenessState.enabled=true
-management.health.readinessState.enabled=true
-
-#Elastic APM
-elastic.apm.enabled=true
-elastic.apm.recording=true
-elastic.apm.instrument=true
-elastic.apm.service_name=metis-core-local
-elastic.apm.server_url=
-elastic.apm.environment=local
-elastic.apm.application_packages=eu.europeana
-elastic.apm.log_level=ERROR
-elastic.apm.capture_body=all
-elastic.apm.capture_headers=true
-elastic.apm.metrics_interval=5s
-
diff --git a/metis-core/metis-core-rest/src/main/resources/default_transformation.xslt b/metis-core/metis-core-rest/src/main/resources/default_transformation.xslt
deleted file mode 100644
index 89f805227b..0000000000
--- a/metis-core/metis-core-rest/src/main/resources/default_transformation.xslt
+++ /dev/null
@@ -1,462 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- false
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/metis-core/metis-core-rest/src/test/java/eu/europeana/metis/core/rest/controller/TestDatasetController.java b/metis-core/metis-core-rest/src/test/java/eu/europeana/metis/core/rest/controller/TestDatasetController.java
deleted file mode 100644
index bdc23e5c18..0000000000
--- a/metis-core/metis-core-rest/src/test/java/eu/europeana/metis/core/rest/controller/TestDatasetController.java
+++ /dev/null
@@ -1,1146 +0,0 @@
-package eu.europeana.metis.core.rest.controller;
-
-import static org.hamcrest.Matchers.hasSize;
-import static org.hamcrest.core.Is.is;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyInt;
-import static org.mockito.ArgumentMatchers.anyList;
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.reset;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
-
-import com.jayway.jsonpath.Configuration;
-import com.jayway.jsonpath.JsonPath;
-import eu.europeana.metis.authentication.rest.client.AuthenticationClient;
-import eu.europeana.metis.authentication.user.AccountRole;
-import eu.europeana.metis.authentication.user.MetisUserView;
-import eu.europeana.metis.core.common.Country;
-import eu.europeana.metis.core.common.Language;
-import eu.europeana.metis.core.dataset.Dataset;
-import eu.europeana.metis.core.dataset.DatasetSearchView;
-import eu.europeana.metis.core.dataset.DatasetXslt;
-import eu.europeana.metis.core.dataset.DatasetXsltStringWrapper;
-import eu.europeana.metis.core.exceptions.DatasetAlreadyExistsException;
-import eu.europeana.metis.core.exceptions.NoDatasetFoundException;
-import eu.europeana.metis.core.exceptions.NoXsltFoundException;
-import eu.europeana.metis.core.rest.Record;
-import eu.europeana.metis.core.rest.exception.RestResponseExceptionHandler;
-import eu.europeana.metis.core.rest.utils.TestObjectFactory;
-import eu.europeana.metis.core.rest.utils.TestUtils;
-import eu.europeana.metis.core.service.DatasetService;
-import eu.europeana.metis.exception.BadContentException;
-import eu.europeana.metis.exception.UserUnauthorizedException;
-import eu.europeana.metis.utils.CommonStringValues;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import org.bson.types.ObjectId;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Test;
-import org.mockito.ArgumentCaptor;
-import org.springframework.http.MediaType;
-import org.springframework.http.converter.StringHttpMessageConverter;
-import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
-import org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter;
-import org.springframework.test.web.servlet.MockMvc;
-import org.springframework.test.web.servlet.MvcResult;
-import org.springframework.test.web.servlet.setup.MockMvcBuilders;
-
-class TestDatasetController {
-
- private static DatasetService datasetServiceMock;
- private static AuthenticationClient authenticationClient;
- private static MockMvc datasetControllerMock;
-
- @BeforeAll
- static void setUp() {
- datasetServiceMock = mock(DatasetService.class);
- authenticationClient = mock(AuthenticationClient.class);
- DatasetController datasetController = new DatasetController(datasetServiceMock,
- authenticationClient);
- datasetControllerMock = MockMvcBuilders
- .standaloneSetup(datasetController)
- .setControllerAdvice(new RestResponseExceptionHandler())
- .setMessageConverters(new MappingJackson2HttpMessageConverter(),
- new MappingJackson2XmlHttpMessageConverter(),
- new StringHttpMessageConverter(StandardCharsets.UTF_8))
- .build();
- }
-
- @AfterEach
- void cleanUp() {
- reset(datasetServiceMock);
- reset(authenticationClient);
- }
-
- private static MetisUserView getUserWithAccountRole(AccountRole accountRole) {
- MetisUserView metisUserView = TestObjectFactory.createMetisUser(TestObjectFactory.EMAIL);
- doReturn(accountRole).when(metisUserView).getAccountRole();
- return metisUserView;
- }
-
- @Test
- void createDataset() throws Exception {
- MetisUserView metisUserView = getUserWithAccountRole(AccountRole.EUROPEANA_DATA_OFFICER);
- Dataset dataset = TestObjectFactory.createDataset(TestObjectFactory.DATASETNAME);
- when(authenticationClient.getUserByAccessTokenInHeader(TestObjectFactory.AUTHORIZATION_HEADER))
- .thenReturn(metisUserView);
- when(datasetServiceMock.createDataset(any(MetisUserView.class), any(Dataset.class)))
- .thenReturn(dataset);
-
- datasetControllerMock.perform(post("/datasets")
- .header("Authorization", TestObjectFactory.AUTHORIZATION_HEADER)
- .contentType(MediaType.APPLICATION_JSON)
- .accept(MediaType.APPLICATION_JSON)
- .content(TestUtils.convertObjectToJsonBytes(dataset)))
- .andExpect(status().is(201))
- .andExpect(content().contentType(MediaType.APPLICATION_JSON))
- .andExpect(jsonPath("$.datasetName", is(TestObjectFactory.DATASETNAME)));
- verify(datasetServiceMock, times(1)).createDataset(any(MetisUserView.class), any(Dataset.class));
- }
-
- @Test
- void createDatasetInvalidUser() throws Exception {
- Dataset dataset = TestObjectFactory.createDataset(TestObjectFactory.DATASETNAME);
- when(authenticationClient.getUserByAccessTokenInHeader(TestObjectFactory.AUTHORIZATION_HEADER))
- .thenThrow(new UserUnauthorizedException(CommonStringValues.UNAUTHORIZED));
-
- datasetControllerMock.perform(post("/datasets")
- .header("Authorization", TestObjectFactory.AUTHORIZATION_HEADER)
- .contentType(MediaType.APPLICATION_JSON)
- .accept(MediaType.APPLICATION_JSON)
- .content(TestUtils.convertObjectToJsonBytes(dataset)))
- .andExpect(status().is(401))
- .andExpect(content().contentType(MediaType.APPLICATION_JSON))
- .andExpect(jsonPath("$.errorMessage", is(CommonStringValues.UNAUTHORIZED)));
- verify(datasetServiceMock, times(0)).createDataset(any(MetisUserView.class), any(Dataset.class));
- }
-
- @Test
- void createDataset_DatasetAlreadyExistsException_Returns409() throws Exception {
- MetisUserView metisUserView = getUserWithAccountRole(AccountRole.EUROPEANA_DATA_OFFICER);
- Dataset dataset = TestObjectFactory.createDataset(TestObjectFactory.DATASETNAME);
-
- when(authenticationClient.getUserByAccessTokenInHeader(TestObjectFactory.AUTHORIZATION_HEADER))
- .thenReturn(metisUserView);
- doThrow(new DatasetAlreadyExistsException("Conflict"))
- .when(datasetServiceMock).createDataset(any(MetisUserView.class), any(Dataset.class));
-
- datasetControllerMock.perform(post("/datasets")
- .header("Authorization", TestObjectFactory.AUTHORIZATION_HEADER)
- .accept(MediaType.APPLICATION_JSON)
- .contentType(MediaType.APPLICATION_JSON)
- .content(TestUtils.convertObjectToJsonBytes(dataset)))
- .andExpect(status().is(409))
- .andExpect(jsonPath("$.errorMessage", is("Conflict")));
- }
-
- @Test
- void updateDataset_withValidData_Returns204() throws Exception {
- MetisUserView metisUserView = getUserWithAccountRole(AccountRole.EUROPEANA_DATA_OFFICER);
- Dataset dataset = TestObjectFactory.createDataset(TestObjectFactory.DATASETNAME);
- DatasetXsltStringWrapper datasetXsltStringWrapper = new DatasetXsltStringWrapper(dataset,
- "");
- when(authenticationClient.getUserByAccessTokenInHeader(TestObjectFactory.AUTHORIZATION_HEADER))
- .thenReturn(metisUserView);
- datasetControllerMock.perform(put("/datasets")
- .header("Authorization", TestObjectFactory.AUTHORIZATION_HEADER)
- .accept(MediaType.APPLICATION_JSON)
- .contentType(MediaType.APPLICATION_JSON)
- .content(TestUtils.convertObjectToJsonBytes(datasetXsltStringWrapper)))
- .andExpect(status().is(204))
- .andExpect(content().string(""));
-
- verify(datasetServiceMock, times(1))
- .updateDataset(any(MetisUserView.class), any(Dataset.class), anyString());
- }
-
- @Test
- void updateDataset_InvalidUser() throws Exception {
- Dataset dataset = TestObjectFactory.createDataset(TestObjectFactory.DATASETNAME);
- when(authenticationClient.getUserByAccessTokenInHeader(TestObjectFactory.AUTHORIZATION_HEADER))
- .thenThrow(new UserUnauthorizedException(CommonStringValues.UNAUTHORIZED));
- datasetControllerMock.perform(put("/datasets")
- .header("Authorization", TestObjectFactory.AUTHORIZATION_HEADER)
- .accept(MediaType.APPLICATION_JSON)
- .contentType(MediaType.APPLICATION_JSON)
- .content(TestUtils.convertObjectToJsonBytes(dataset)))
- .andExpect(status().is(401))
- .andExpect(jsonPath("$.errorMessage", is(CommonStringValues.UNAUTHORIZED)));
-
- verify(datasetServiceMock, times(0))
- .updateDataset(any(MetisUserView.class), any(Dataset.class), anyString());
- }
-
- @Test
- void updateDataset_noDatasetFound_Returns404() throws Exception {
- MetisUserView metisUserView = getUserWithAccountRole(AccountRole.EUROPEANA_DATA_OFFICER);
- Dataset dataset = TestObjectFactory.createDataset(TestObjectFactory.DATASETNAME);
- DatasetXsltStringWrapper datasetXsltStringWrapper = new DatasetXsltStringWrapper(dataset,
- "");
- when(authenticationClient.getUserByAccessTokenInHeader(TestObjectFactory.AUTHORIZATION_HEADER))
- .thenReturn(metisUserView);
- doThrow(new NoDatasetFoundException("Does not exist")).when(datasetServiceMock)
- .updateDataset(any(MetisUserView.class), any(Dataset.class), anyString());
- datasetControllerMock.perform(put("/datasets")
- .header("Authorization", TestObjectFactory.AUTHORIZATION_HEADER)
- .accept(MediaType.APPLICATION_JSON)
- .contentType(MediaType.APPLICATION_JSON)
- .content(TestUtils.convertObjectToJsonBytes(datasetXsltStringWrapper)))
- .andExpect(status().is(404))
- .andExpect(jsonPath("$.errorMessage", is("Does not exist")));
-
- verify(datasetServiceMock, times(1))
- .updateDataset(any(MetisUserView.class), any(Dataset.class), anyString());
- }
-
- @Test
- void updateDataset_BadContentException_Returns406() throws Exception {
- MetisUserView metisUserView = getUserWithAccountRole(AccountRole.EUROPEANA_DATA_OFFICER);
- Dataset dataset = TestObjectFactory.createDataset(TestObjectFactory.DATASETNAME);
- DatasetXsltStringWrapper datasetXsltStringWrapper = new DatasetXsltStringWrapper(dataset,
- "");
- when(authenticationClient.getUserByAccessTokenInHeader(TestObjectFactory.AUTHORIZATION_HEADER))
- .thenReturn(metisUserView);
- doThrow(new BadContentException("Bad Content")).when(datasetServiceMock)
- .updateDataset(any(MetisUserView.class), any(Dataset.class), anyString());
- datasetControllerMock.perform(put("/datasets")
- .header("Authorization", TestObjectFactory.AUTHORIZATION_HEADER)
- .accept(MediaType.APPLICATION_JSON)
- .contentType(MediaType.APPLICATION_JSON)
- .content(TestUtils.convertObjectToJsonBytes(datasetXsltStringWrapper)))
- .andExpect(status().is(406))
- .andExpect(jsonPath("$.errorMessage", is("Bad Content")));
-
- verify(datasetServiceMock, times(1))
- .updateDataset(any(MetisUserView.class), any(Dataset.class), anyString());
- }
-
- @Test
- void deleteDataset() throws Exception {
- MetisUserView metisUserView = getUserWithAccountRole(AccountRole.EUROPEANA_DATA_OFFICER);
- when(authenticationClient.getUserByAccessTokenInHeader(TestObjectFactory.AUTHORIZATION_HEADER))
- .thenReturn(metisUserView);
- datasetControllerMock.perform(
- delete(String.format("/datasets/%s", TestObjectFactory.DATASETID))
- .header("Authorization", TestObjectFactory.AUTHORIZATION_HEADER)
- .accept(MediaType.APPLICATION_JSON)
- .contentType(MediaType.APPLICATION_JSON)
- .content(TestUtils.convertObjectToJsonBytes(null)))
- .andExpect(status().is(204))
- .andExpect(content().string(""));
-
- ArgumentCaptor datasetIdArgumentCaptor = ArgumentCaptor.forClass(String.class);
-
- verify(datasetServiceMock, times(1))
- .deleteDatasetByDatasetId(any(MetisUserView.class), datasetIdArgumentCaptor.capture());
-
- assertEquals(Integer.toString(TestObjectFactory.DATASETID), datasetIdArgumentCaptor.getValue());
- }
-
- @Test
- void deleteDatasetInvalidUser() throws Exception {
- when(authenticationClient.getUserByAccessTokenInHeader(TestObjectFactory.AUTHORIZATION_HEADER))
- .thenThrow(new UserUnauthorizedException(CommonStringValues.UNAUTHORIZED));
- datasetControllerMock.perform(
- delete(String.format("/datasets/%s", TestObjectFactory.DATASETID))
- .header("Authorization", TestObjectFactory.AUTHORIZATION_HEADER)
- .accept(MediaType.APPLICATION_JSON)
- .contentType(MediaType.APPLICATION_JSON)
- .content(TestUtils.convertObjectToJsonBytes(null)))
- .andExpect(status().is(401))
- .andExpect(jsonPath("$.errorMessage", is(CommonStringValues.UNAUTHORIZED)));
- verify(datasetServiceMock, times(0))
- .deleteDatasetByDatasetId(any(MetisUserView.class), anyString());
- }
-
- @Test
- void deleteDataset_BadContentException_Returns406() throws Exception {
- MetisUserView metisUserView = getUserWithAccountRole(AccountRole.EUROPEANA_DATA_OFFICER);
- when(authenticationClient.getUserByAccessTokenInHeader(TestObjectFactory.AUTHORIZATION_HEADER))
- .thenReturn(metisUserView);
- doThrow(new BadContentException("Bad Content")).when(datasetServiceMock)
- .deleteDatasetByDatasetId(metisUserView, Integer.toString(TestObjectFactory.DATASETID));
- datasetControllerMock.perform(
- delete(String.format("/datasets/%s", TestObjectFactory.DATASETID))
- .header("Authorization", TestObjectFactory.AUTHORIZATION_HEADER)
- .accept(MediaType.APPLICATION_JSON)
- .contentType(MediaType.APPLICATION_JSON)
- .content(TestUtils.convertObjectToJsonBytes(null)))
- .andExpect(status().is(406))
- .andExpect(jsonPath("$.errorMessage", is("Bad Content")));
- }
-
-
- @Test
- void getByDatasetId() throws Exception {
- MetisUserView metisUserView = getUserWithAccountRole(AccountRole.EUROPEANA_DATA_OFFICER);
- Dataset dataset = TestObjectFactory.createDataset(TestObjectFactory.DATASETNAME);
-
- when(authenticationClient.getUserByAccessTokenInHeader(TestObjectFactory.AUTHORIZATION_HEADER))
- .thenReturn(metisUserView);
- when(datasetServiceMock
- .getDatasetByDatasetId(metisUserView, Integer.toString(TestObjectFactory.DATASETID)))
- .thenReturn(dataset);
- datasetControllerMock
- .perform(get(String.format("/datasets/%s", TestObjectFactory.DATASETID))
- .header("Authorization", TestObjectFactory.AUTHORIZATION_HEADER)
- .contentType(MediaType.APPLICATION_JSON)
- .content(TestUtils.convertObjectToJsonBytes(null)))
- .andExpect(status().is(200))
- .andExpect(content().contentType(MediaType.APPLICATION_JSON))
- .andExpect(jsonPath("$.datasetName", is(TestObjectFactory.DATASETNAME)))
- .andExpect(jsonPath("$.datasetId", is(Integer.toString(TestObjectFactory.DATASETID))));
-
- ArgumentCaptor datasetIdArgumentCaptor = ArgumentCaptor.forClass(String.class);
- verify(datasetServiceMock, times(1))
- .getDatasetByDatasetId(any(MetisUserView.class), datasetIdArgumentCaptor.capture());
- assertEquals(Integer.toString(TestObjectFactory.DATASETID), datasetIdArgumentCaptor.getValue());
- }
-
- @Test
- void getByDatasetIdInvalidUser() throws Exception {
- when(authenticationClient.getUserByAccessTokenInHeader(TestObjectFactory.AUTHORIZATION_HEADER))
- .thenThrow(new UserUnauthorizedException(CommonStringValues.UNAUTHORIZED));
- datasetControllerMock
- .perform(get(String.format("/datasets/%s", TestObjectFactory.DATASETID))
- .header("Authorization", TestObjectFactory.AUTHORIZATION_HEADER)
- .contentType(MediaType.APPLICATION_JSON)
- .content(TestUtils.convertObjectToJsonBytes(null)))
- .andExpect(status().is(401))
- .andExpect(content().contentType(MediaType.APPLICATION_JSON))
- .andExpect(jsonPath("$.errorMessage", is(CommonStringValues.UNAUTHORIZED)));
-
- verify(datasetServiceMock, times(0))
- .getDatasetByDatasetId(any(MetisUserView.class), anyString());
- }
-
- @Test
- void getByDatasetId_noDatasetFound_Returns404() throws Exception {
- MetisUserView metisUserView = getUserWithAccountRole(AccountRole.EUROPEANA_DATA_OFFICER);
- when(authenticationClient.getUserByAccessTokenInHeader(TestObjectFactory.AUTHORIZATION_HEADER))
- .thenReturn(metisUserView);
- when(datasetServiceMock
- .getDatasetByDatasetId(metisUserView, Integer.toString(TestObjectFactory.DATASETID)))
- .thenThrow(new NoDatasetFoundException("Does not exist"));
- datasetControllerMock
- .perform(get(String.format("/datasets/%s", TestObjectFactory.DATASETID))
- .header("Authorization", TestObjectFactory.AUTHORIZATION_HEADER)
- .contentType(MediaType.APPLICATION_JSON)
- .content(TestUtils.convertObjectToJsonBytes(null)))
- .andExpect(content().contentType(MediaType.APPLICATION_JSON))
- .andExpect(status().is(404))
- .andExpect(jsonPath("$.errorMessage", is("Does not exist")));
- }
-
- @Test
- void getDatasetXsltByDatasetId() throws Exception {
- MetisUserView metisUserView = getUserWithAccountRole(AccountRole.EUROPEANA_DATA_OFFICER);
- Dataset dataset = TestObjectFactory.createDataset(TestObjectFactory.DATASETNAME);
- DatasetXslt xsltObject = new DatasetXslt(dataset.getDatasetId(),
- "");
-
- when(authenticationClient.getUserByAccessTokenInHeader(TestObjectFactory.AUTHORIZATION_HEADER))
- .thenReturn(metisUserView);
- when(datasetServiceMock
- .getDatasetXsltByDatasetId(metisUserView, Integer.toString(TestObjectFactory.DATASETID)))
- .thenReturn(xsltObject);
- datasetControllerMock
- .perform(
- get(String.format("/datasets/%s/xslt", TestObjectFactory.DATASETID))
- .header("Authorization", TestObjectFactory.AUTHORIZATION_HEADER)
- .contentType(MediaType.APPLICATION_JSON)
- .content(TestUtils.convertObjectToJsonBytes(null)))
- .andExpect(status().is(200))
- .andExpect(content().contentType(MediaType.APPLICATION_JSON))
- .andExpect(jsonPath("$.xslt", is(xsltObject.getXslt())))
- .andExpect(jsonPath("$.datasetId", is(Integer.toString(TestObjectFactory.DATASETID))));
-
- ArgumentCaptor datasetIdArgumentCaptor = ArgumentCaptor.forClass(String.class);
- verify(datasetServiceMock, times(1))
- .getDatasetXsltByDatasetId(any(MetisUserView.class), datasetIdArgumentCaptor.capture());
- assertEquals(Integer.toString(TestObjectFactory.DATASETID), datasetIdArgumentCaptor.getValue());
- }
-
- @Test
- void getDatasetXsltByDatasetId_noDatasetFound_Returns404() throws Exception {
- MetisUserView metisUserView = getUserWithAccountRole(AccountRole.EUROPEANA_DATA_OFFICER);
-
- when(authenticationClient.getUserByAccessTokenInHeader(TestObjectFactory.AUTHORIZATION_HEADER))
- .thenReturn(metisUserView);
- when(datasetServiceMock
- .getDatasetXsltByDatasetId(metisUserView, Integer.toString(TestObjectFactory.DATASETID)))
- .thenThrow(new NoDatasetFoundException("Does not exist"));
- datasetControllerMock
- .perform(
- get(String.format("/datasets/%s/xslt", TestObjectFactory.DATASETID))
- .header("Authorization", TestObjectFactory.AUTHORIZATION_HEADER)
- .contentType(MediaType.APPLICATION_JSON)
- .content(TestUtils.convertObjectToJsonBytes(null)))
- .andExpect(status().is(404))
- .andExpect(content().contentType(MediaType.APPLICATION_JSON))
- .andExpect(jsonPath("$.errorMessage", is("Does not exist")));
- }
-
- @Test
- void getDatasetXsltByDatasetId_noXsltFound_Returns404() throws Exception {
- MetisUserView metisUserView = getUserWithAccountRole(AccountRole.EUROPEANA_DATA_OFFICER);
-
- when(authenticationClient.getUserByAccessTokenInHeader(TestObjectFactory.AUTHORIZATION_HEADER))
- .thenReturn(metisUserView);
- when(datasetServiceMock
- .getDatasetXsltByDatasetId(metisUserView, Integer.toString(TestObjectFactory.DATASETID)))
- .thenThrow(new NoXsltFoundException("Does not exist"));
- datasetControllerMock
- .perform(
- get(String.format("/datasets/%s/xslt", TestObjectFactory.DATASETID))
- .header("Authorization", TestObjectFactory.AUTHORIZATION_HEADER)
- .contentType(MediaType.APPLICATION_JSON)
- .content(TestUtils.convertObjectToJsonBytes(null)))
- .andExpect(status().is(404))
- .andExpect(content().contentType(MediaType.APPLICATION_JSON))
- .andExpect(jsonPath("$.errorMessage", is("Does not exist")));
- }
-
- @Test
- void getDatasetXsltByDatasetIdInvalidUser() throws Exception {
- MetisUserView metisUserView = getUserWithAccountRole(AccountRole.EUROPEANA_DATA_OFFICER);
- Dataset dataset = TestObjectFactory.createDataset(TestObjectFactory.DATASETNAME);
- DatasetXslt xsltObject = new DatasetXslt(dataset.getDatasetId(),
- "");
-
- when(authenticationClient.getUserByAccessTokenInHeader(TestObjectFactory.AUTHORIZATION_HEADER))
- .thenThrow(new UserUnauthorizedException(CommonStringValues.UNAUTHORIZED));
- when(datasetServiceMock
- .getDatasetXsltByDatasetId(metisUserView, Integer.toString(TestObjectFactory.DATASETID)))
- .thenReturn(xsltObject);
- datasetControllerMock
- .perform(
- get(String.format("/datasets/%s/xslt", TestObjectFactory.DATASETID))
- .header("Authorization", TestObjectFactory.AUTHORIZATION_HEADER)
- .contentType(MediaType.APPLICATION_JSON)
- .content(TestUtils.convertObjectToJsonBytes(null)))
- .andExpect(status().is(401))
- .andExpect(content().contentType(MediaType.APPLICATION_JSON))
- .andExpect(jsonPath("$.errorMessage", is(CommonStringValues.UNAUTHORIZED)));
-
- verify(datasetServiceMock, times(0))
- .getDatasetXsltByDatasetId(any(MetisUserView.class), anyString());
- }
-
- @Test
- void getXsltByXsltId() throws Exception {
- Dataset dataset = TestObjectFactory.createDataset(TestObjectFactory.DATASETNAME);
- DatasetXslt xsltObject = new DatasetXslt(dataset.getDatasetId(),
- "");
-
- when(datasetServiceMock.getDatasetXsltByXsltId(TestObjectFactory.XSLTID))
- .thenReturn(xsltObject);
- datasetControllerMock
- .perform(get(String.format("/datasets/xslt/%s", TestObjectFactory.XSLTID))
- .content(TestUtils.convertObjectToJsonBytes(null)))
- .andExpect(status().is(200))
- .andExpect(content().contentType(
- new MediaType(MediaType.TEXT_PLAIN.getType(), MediaType.TEXT_PLAIN.getSubtype(),
- StandardCharsets.UTF_8)))
- .andExpect(content().string(xsltObject.getXslt()));
-
- ArgumentCaptor xsltIdArgumentCaptor = ArgumentCaptor.forClass(String.class);
- verify(datasetServiceMock, times(1))
- .getDatasetXsltByXsltId(xsltIdArgumentCaptor.capture());
- assertEquals(TestObjectFactory.XSLTID, xsltIdArgumentCaptor.getValue());
- }
-
- @Test
- void getXsltByXsltId_NoXsltFound_404() throws Exception {
- when(datasetServiceMock.getDatasetXsltByXsltId(TestObjectFactory.XSLTID))
- .thenThrow(new NoXsltFoundException("No xslt found"));
- datasetControllerMock
- .perform(get(String.format("/datasets/xslt/%s", TestObjectFactory.XSLTID))
- .contentType(MediaType.APPLICATION_JSON)
- .content(TestUtils.convertObjectToJsonBytes(null)))
- .andExpect(status().is(404));
-
- ArgumentCaptor xsltIdArgumentCaptor = ArgumentCaptor.forClass(String.class);
- verify(datasetServiceMock, times(1))
- .getDatasetXsltByXsltId(xsltIdArgumentCaptor.capture());
- assertEquals(TestObjectFactory.XSLTID, xsltIdArgumentCaptor.getValue());
- }
-
- @Test
- void createDefaultXslt() throws Exception {
- MetisUserView metisUserView = getUserWithAccountRole(AccountRole.METIS_ADMIN);
- Dataset dataset = TestObjectFactory.createDataset(TestObjectFactory.DATASETNAME);
- DatasetXslt xsltObject = new DatasetXslt(dataset.getDatasetId(),
- "");
- xsltObject.setId(new ObjectId(TestObjectFactory.XSLTID));
-
- when(authenticationClient.getUserByAccessTokenInHeader(TestObjectFactory.AUTHORIZATION_HEADER))
- .thenReturn(metisUserView);
-
- when(datasetServiceMock.createDefaultXslt(any(MetisUserView.class), anyString()))
- .thenReturn(xsltObject);
- datasetControllerMock
- .perform(post("/datasets/xslt/default", TestObjectFactory.XSLTID)
- .header("Authorization", TestObjectFactory.AUTHORIZATION_HEADER)
- .contentType(MediaType.TEXT_PLAIN)
- .content(TestUtils.convertObjectToJsonBytes(xsltObject.getXslt())))
- .andExpect(status().is(201))
- .andExpect(content().contentType(MediaType.APPLICATION_JSON))
- .andExpect(jsonPath("$.xslt", is(xsltObject.getXslt())))
- .andExpect(jsonPath("$.datasetId", is(Integer.toString(TestObjectFactory.DATASETID))));
- }
-
- @Test
- void createDefaultXslt_Unauthorized() throws Exception {
- MetisUserView metisUserView = getUserWithAccountRole(AccountRole.EUROPEANA_DATA_OFFICER);
- Dataset dataset = TestObjectFactory.createDataset(TestObjectFactory.DATASETNAME);
- DatasetXslt xsltObject = new DatasetXslt(dataset.getDatasetId(),
- "");
- xsltObject.setId(new ObjectId(TestObjectFactory.XSLTID));
-
- when(authenticationClient.getUserByAccessTokenInHeader(TestObjectFactory.AUTHORIZATION_HEADER))
- .thenReturn(metisUserView);
-
- when(datasetServiceMock.createDefaultXslt(any(MetisUserView.class), anyString()))
- .thenThrow(new UserUnauthorizedException(CommonStringValues.UNAUTHORIZED));
- datasetControllerMock
- .perform(post("/datasets/xslt/default", TestObjectFactory.XSLTID)
- .header("Authorization", TestObjectFactory.AUTHORIZATION_HEADER)
- .contentType(MediaType.TEXT_PLAIN)
- .content(TestUtils.convertObjectToJsonBytes(xsltObject.getXslt())))
- .andExpect(status().is(401))
- .andExpect(content().contentType(MediaType.APPLICATION_JSON))
- .andExpect(jsonPath("$.errorMessage", is(CommonStringValues.UNAUTHORIZED)));
- }
-
- @Test
- void getLatestDefaultXslt() throws Exception {
- Dataset dataset = TestObjectFactory.createDataset(TestObjectFactory.DATASETNAME);
- DatasetXslt xsltObject = new DatasetXslt(dataset.getDatasetId(),
- "");
-
- when(datasetServiceMock.getLatestDefaultXslt()).thenReturn(xsltObject);
- datasetControllerMock.perform(get("/datasets/xslt/default")
- .content(TestUtils.convertObjectToJsonBytes(null)))
- .andExpect(status().is(200))
- .andExpect(content().contentType(
- new MediaType(MediaType.TEXT_PLAIN.getType(), MediaType.TEXT_PLAIN.getSubtype(),
- StandardCharsets.UTF_8)))
- .andExpect(content().string(xsltObject.getXslt()));
-
- verify(datasetServiceMock, times(1)).getLatestDefaultXslt();
- }
-
- @Test
- void getLatestDefaultXslt_NoXsltFound_404() throws Exception {
- when(datasetServiceMock.getLatestDefaultXslt())
- .thenThrow(new NoXsltFoundException("No xslt found"));
- datasetControllerMock.perform(get("/datasets/xslt/default")
- .contentType(MediaType.APPLICATION_JSON)
- .content(TestUtils.convertObjectToJsonBytes(null)))
- .andExpect(status().is(404));
-
- verify(datasetServiceMock, times(1)).getLatestDefaultXslt();
- }
-
- @Test
- void transformRecordsUsingLatestDatasetXslt() throws Exception {
- MetisUserView metisUserView = getUserWithAccountRole(AccountRole.EUROPEANA_DATA_OFFICER);
- when(authenticationClient.getUserByAccessTokenInHeader(TestObjectFactory.AUTHORIZATION_HEADER))
- .thenReturn(metisUserView);
- List listOfRecords = TestObjectFactory.createListOfRecords(5);
- when(datasetServiceMock
- .transformRecordsUsingLatestDatasetXslt(any(MetisUserView.class), anyString(), anyList()))
- .thenReturn(listOfRecords);
- datasetControllerMock
- .perform(post("/datasets/{datasetId}/xslt/transform",
- Integer.toString(TestObjectFactory.DATASETID))
- .header("Authorization", TestObjectFactory.AUTHORIZATION_HEADER)
- .contentType(MediaType.APPLICATION_JSON_VALUE)
- .content(TestUtils.convertObjectToJsonBytes(listOfRecords)))
- .andExpect(status().is(200))
- .andExpect(content().contentType(MediaType.APPLICATION_JSON))
- .andExpect(jsonPath("$", hasSize(5)));
- }
-
- @Test
- void transformRecordsUsingLatestDatasetXslt_UserUnauthorizedException() throws Exception {
- when(authenticationClient.getUserByAccessTokenInHeader(TestObjectFactory.AUTHORIZATION_HEADER))
- .thenThrow(new UserUnauthorizedException(CommonStringValues.WRONG_ACCESS_TOKEN));
- datasetControllerMock
- .perform(post("/datasets/{datasetId}/xslt/transform",
- Integer.toString(TestObjectFactory.DATASETID))
- .header("Authorization", TestObjectFactory.AUTHORIZATION_HEADER)
- .contentType(MediaType.APPLICATION_JSON_VALUE)
- .content(TestUtils.convertObjectToJsonBytes(TestObjectFactory.createListOfRecords(5))))
- .andExpect(status().is(401))
- .andExpect(content().contentType(MediaType.APPLICATION_JSON))
- .andExpect(jsonPath("$.errorMessage", is(CommonStringValues.WRONG_ACCESS_TOKEN)));
- }
-
- @Test
- void transformRecordsUsingLatestDefaultXslt() throws Exception {
- MetisUserView metisUserView = getUserWithAccountRole(AccountRole.EUROPEANA_DATA_OFFICER);
- when(authenticationClient.getUserByAccessTokenInHeader(TestObjectFactory.AUTHORIZATION_HEADER))
- .thenReturn(metisUserView);
- List listOfRecords = TestObjectFactory.createListOfRecords(5);
- when(datasetServiceMock
- .transformRecordsUsingLatestDefaultXslt(any(MetisUserView.class), anyString(), anyList()))
- .thenReturn(listOfRecords);
- datasetControllerMock
- .perform(post("/datasets/{datasetId}/xslt/transform/default",
- Integer.toString(TestObjectFactory.DATASETID))
- .header("Authorization", TestObjectFactory.AUTHORIZATION_HEADER)
- .contentType(MediaType.APPLICATION_JSON_VALUE)
- .content(TestUtils.convertObjectToJsonBytes(listOfRecords)))
- .andExpect(status().is(200))
- .andExpect(content().contentType(MediaType.APPLICATION_JSON))
- .andExpect(jsonPath("$", hasSize(5)));
- }
-
- @Test
- void transformRecordsUsingLatestDefaultXslt_UserUnauthorizedException() throws Exception {
- when(authenticationClient.getUserByAccessTokenInHeader(TestObjectFactory.AUTHORIZATION_HEADER))
- .thenThrow(new UserUnauthorizedException(CommonStringValues.WRONG_ACCESS_TOKEN));
- datasetControllerMock
- .perform(post("/datasets/{datasetId}/xslt/transform/default",
- Integer.toString(TestObjectFactory.DATASETID))
- .header("Authorization", TestObjectFactory.AUTHORIZATION_HEADER)
- .contentType(MediaType.APPLICATION_JSON_VALUE)
- .content(TestUtils.convertObjectToJsonBytes(TestObjectFactory.createListOfRecords(5))))
- .andExpect(status().is(401))
- .andExpect(content().contentType(MediaType.APPLICATION_JSON))
- .andExpect(jsonPath("$.errorMessage", is(CommonStringValues.WRONG_ACCESS_TOKEN)));
- }
-
- @Test
- void getByDatasetName() throws Exception {
- MetisUserView metisUserView = getUserWithAccountRole(AccountRole.EUROPEANA_DATA_OFFICER);
- Dataset dataset = TestObjectFactory.createDataset(TestObjectFactory.DATASETNAME);
-
- when(authenticationClient.getUserByAccessTokenInHeader(TestObjectFactory.AUTHORIZATION_HEADER))
- .thenReturn(metisUserView);
- when(datasetServiceMock.getDatasetByDatasetName(metisUserView, TestObjectFactory.DATASETNAME))
- .thenReturn(dataset);
- datasetControllerMock
- .perform(get(String.format("/datasets/dataset_name/%s", TestObjectFactory.DATASETNAME))
- .header("Authorization", TestObjectFactory.AUTHORIZATION_HEADER)
- .contentType(MediaType.APPLICATION_JSON)
- .content(TestUtils.convertObjectToJsonBytes(null)))
- .andExpect(status().is(200))
- .andExpect(content().contentType(MediaType.APPLICATION_JSON))
- .andExpect(jsonPath("$.datasetName", is(TestObjectFactory.DATASETNAME)))
- .andExpect(jsonPath("$.datasetId", is(Integer.toString(TestObjectFactory.DATASETID))));
-
- ArgumentCaptor datasetNameArgumentCaptor = ArgumentCaptor.forClass(String.class);
- verify(datasetServiceMock, times(1))
- .getDatasetByDatasetName(any(MetisUserView.class), datasetNameArgumentCaptor.capture());
- assertEquals(TestObjectFactory.DATASETNAME, datasetNameArgumentCaptor.getValue());
- }
-
- @Test
- void getByDatasetNameInvalidUser() throws Exception {
- when(authenticationClient.getUserByAccessTokenInHeader(TestObjectFactory.AUTHORIZATION_HEADER))
- .thenThrow(new UserUnauthorizedException(CommonStringValues.UNAUTHORIZED));
- datasetControllerMock
- .perform(get(String.format("/datasets/dataset_name/%s", TestObjectFactory.DATASETNAME))
- .header("Authorization", TestObjectFactory.AUTHORIZATION_HEADER)
- .contentType(MediaType.APPLICATION_JSON)
- .content(TestUtils.convertObjectToJsonBytes(null)))
- .andExpect(status().is(401))
- .andExpect(content().contentType(MediaType.APPLICATION_JSON))
- .andExpect(jsonPath("$.errorMessage", is(CommonStringValues.UNAUTHORIZED)));
-
- verify(datasetServiceMock, times(0))
- .getDatasetByDatasetName(any(MetisUserView.class), anyString());
- }
-
-
- @Test
- void getByDatasetName_noDatasetFound_Returns404() throws Exception {
- MetisUserView metisUserView = getUserWithAccountRole(AccountRole.EUROPEANA_DATA_OFFICER);
- when(authenticationClient.getUserByAccessTokenInHeader(TestObjectFactory.AUTHORIZATION_HEADER))
- .thenReturn(metisUserView);
- when(datasetServiceMock.getDatasetByDatasetName(metisUserView, TestObjectFactory.DATASETNAME))
- .thenThrow(new NoDatasetFoundException("Does not exist"));
- datasetControllerMock
- .perform(get(String.format("/datasets/dataset_name/%s", TestObjectFactory.DATASETNAME))
- .header("Authorization", TestObjectFactory.AUTHORIZATION_HEADER)
- .contentType(MediaType.APPLICATION_JSON)
- .content(TestUtils.convertObjectToJsonBytes(null)))
- .andExpect(content().contentType(MediaType.APPLICATION_JSON))
- .andExpect(status().is(404))
- .andExpect(jsonPath("$.errorMessage", is("Does not exist")));
- }
-
- @Test
- void getAllDatasetsByProvider() throws Exception {
- MetisUserView metisUserView = getUserWithAccountRole(AccountRole.EUROPEANA_DATA_OFFICER);
- List datasetList = getDatasets();
-
- when(authenticationClient.getUserByAccessTokenInHeader(TestObjectFactory.AUTHORIZATION_HEADER))
- .thenReturn(metisUserView);
- when(datasetServiceMock.getAllDatasetsByProvider(metisUserView, "myProvider", 3))
- .thenReturn(datasetList);
- when(datasetServiceMock.getDatasetsPerRequestLimit()).thenReturn(5);
-
- datasetControllerMock.perform(get("/datasets/provider/myProvider")
- .header("Authorization", TestObjectFactory.AUTHORIZATION_HEADER)
- .param("nextPage", "3")
- .contentType(MediaType.APPLICATION_JSON)
- .content(TestUtils.convertObjectToJsonBytes(null)))
- .andExpect(status().is(200))
- .andExpect(content().contentType(MediaType.APPLICATION_JSON))
- .andExpect(jsonPath("$.results", hasSize(2)))
- .andExpect(jsonPath("$.results[0].datasetId",
- is(Integer.toString(TestObjectFactory.DATASETID + 1))))
- .andExpect(jsonPath("$.results[1].datasetId",
- is(Integer.toString(TestObjectFactory.DATASETID + 2))));
-
- ArgumentCaptor provider = ArgumentCaptor.forClass(String.class);
- ArgumentCaptor page = ArgumentCaptor.forClass(Integer.class);
- verify(datasetServiceMock, times(1))
- .getAllDatasetsByProvider(any(MetisUserView.class), provider.capture(), page.capture());
-
- assertEquals("myProvider", provider.getValue());
- assertEquals(3, page.getValue().intValue());
- }
-
- @Test
- void getAllDatasetsByProviderNegativeNextPage() throws Exception {
- datasetControllerMock.perform(get("/datasets/provider/myProvider")
- .header("Authorization", TestObjectFactory.AUTHORIZATION_HEADER)
- .param("nextPage", "-1")
- .contentType(MediaType.APPLICATION_JSON)
- .content(TestUtils.convertObjectToJsonBytes(null)))
- .andExpect(status().is(406));
- }
-
- @Test
- void getAllDatasetsByProviderInvalidUser() throws Exception {
- when(authenticationClient.getUserByAccessTokenInHeader(TestObjectFactory.AUTHORIZATION_HEADER))
- .thenThrow(new UserUnauthorizedException(CommonStringValues.UNAUTHORIZED));
-
- datasetControllerMock.perform(get("/datasets/provider/myProvider")
- .header("Authorization", TestObjectFactory.AUTHORIZATION_HEADER)
- .param("nextPage", "3")
- .contentType(MediaType.APPLICATION_JSON)
- .content(TestUtils.convertObjectToJsonBytes(null)))
- .andExpect(status().is(401))
- .andExpect(content().contentType(MediaType.APPLICATION_JSON))
- .andExpect(jsonPath("$.errorMessage", is(CommonStringValues.UNAUTHORIZED)));
-
- verify(datasetServiceMock, times(0))
- .getAllDatasetsByProvider(any(MetisUserView.class), anyString(), anyInt());
- }
-
- @Test
- void getAllDatasetsByIntermediateProvider() throws Exception {
- MetisUserView metisUserView = getUserWithAccountRole(AccountRole.EUROPEANA_DATA_OFFICER);
- List datasetList = getDatasets();
-
- when(authenticationClient.getUserByAccessTokenInHeader(TestObjectFactory.AUTHORIZATION_HEADER))
- .thenReturn(metisUserView);
- when(datasetServiceMock
- .getAllDatasetsByIntermediateProvider(metisUserView, "myIntermediateProvider", 3))
- .thenReturn(datasetList);
- when(datasetServiceMock.getDatasetsPerRequestLimit()).thenReturn(5);
-
- datasetControllerMock.perform(get("/datasets/intermediate_provider/myIntermediateProvider")
- .header("Authorization", TestObjectFactory.AUTHORIZATION_HEADER)
- .param("nextPage", "3")
- .contentType(MediaType.APPLICATION_JSON)
- .content(TestUtils.convertObjectToJsonBytes(null)))
- .andExpect(status().is(200))
- .andExpect(content().contentType(MediaType.APPLICATION_JSON))
- .andExpect(jsonPath("$.results", hasSize(2)))
- .andExpect(jsonPath("$.results[0].datasetId",
- is(Integer.toString(TestObjectFactory.DATASETID + 1))))
- .andExpect(jsonPath("$.results[1].datasetId",
- is(Integer.toString(TestObjectFactory.DATASETID + 2))));
-
- ArgumentCaptor provider = ArgumentCaptor.forClass(String.class);
- ArgumentCaptor page = ArgumentCaptor.forClass(Integer.class);
- verify(datasetServiceMock, times(1))
- .getAllDatasetsByIntermediateProvider(any(MetisUserView.class), provider.capture(),
- page.capture());
-
- assertEquals("myIntermediateProvider", provider.getValue());
- assertEquals(3, page.getValue().intValue());
- }
-
- @Test
- void getAllDatasetsByIntermediateProviderNegativeNextPage() throws Exception {
- datasetControllerMock.perform(get("/datasets/intermediate_provider/myIntermediateProvider")
- .header("Authorization", TestObjectFactory.AUTHORIZATION_HEADER)
- .param("nextPage", "-1")
- .contentType(MediaType.APPLICATION_JSON)
- .content(TestUtils.convertObjectToJsonBytes(null)))
- .andExpect(status().is(406));
- }
-
- @Test
- void getAllDatasetsByIntermediateProviderInvalidUser() throws Exception {
- when(authenticationClient.getUserByAccessTokenInHeader(TestObjectFactory.AUTHORIZATION_HEADER))
- .thenThrow(new UserUnauthorizedException(CommonStringValues.UNAUTHORIZED));
-
- datasetControllerMock.perform(get("/datasets/intermediate_provider/myIntermediateProvider")
- .header("Authorization", TestObjectFactory.AUTHORIZATION_HEADER)
- .param("nextPage", "3")
- .contentType(MediaType.APPLICATION_JSON)
- .content(TestUtils.convertObjectToJsonBytes(null)))
- .andExpect(status().is(401))
- .andExpect(content().contentType(MediaType.APPLICATION_JSON))
- .andExpect(jsonPath("$.errorMessage", is(CommonStringValues.UNAUTHORIZED)));
-
- verify(datasetServiceMock, times(0))
- .getAllDatasetsByIntermediateProvider(any(MetisUserView.class), anyString(), anyInt());
- }
-
- @Test
- void getAllDatasetsByDataProvider() throws Exception {
- MetisUserView metisUserView = getUserWithAccountRole(AccountRole.EUROPEANA_DATA_OFFICER);
- List datasetList = getDatasets();
-
- when(authenticationClient.getUserByAccessTokenInHeader(TestObjectFactory.AUTHORIZATION_HEADER))
- .thenReturn(metisUserView);
- when(datasetServiceMock.getAllDatasetsByDataProvider(metisUserView, "myDataProvider", 3))
- .thenReturn(datasetList);
- when(datasetServiceMock.getDatasetsPerRequestLimit()).thenReturn(5);
-
- datasetControllerMock.perform(get("/datasets/data_provider/myDataProvider")
- .header("Authorization", TestObjectFactory.AUTHORIZATION_HEADER)
- .param("nextPage", "3")
- .contentType(MediaType.APPLICATION_JSON)
- .content(TestUtils.convertObjectToJsonBytes(null)))
- .andExpect(status().is(200))
- .andExpect(content().contentType(MediaType.APPLICATION_JSON))
- .andExpect(jsonPath("$.results", hasSize(2)))
- .andExpect(jsonPath("$.results[0].datasetId",
- is(Integer.toString(TestObjectFactory.DATASETID + 1))))
- .andExpect(jsonPath("$.results[1].datasetId",
- is(Integer.toString(TestObjectFactory.DATASETID + 2))));
-
- ArgumentCaptor provider = ArgumentCaptor.forClass(String.class);
- ArgumentCaptor page = ArgumentCaptor.forClass(Integer.class);
- verify(datasetServiceMock, times(1))
- .getAllDatasetsByDataProvider(any(MetisUserView.class), provider.capture(), page.capture());
-
- assertEquals("myDataProvider", provider.getValue());
- assertEquals(3, page.getValue().intValue());
- }
-
- @Test
- void getAllDatasetsByDataProviderNegativeNextPage() throws Exception {
- datasetControllerMock.perform(get("/datasets/data_provider/myDataProvider")
- .header("Authorization", TestObjectFactory.AUTHORIZATION_HEADER)
- .param("nextPage", "-1")
- .contentType(MediaType.APPLICATION_JSON)
- .content(TestUtils.convertObjectToJsonBytes(null)))
- .andExpect(status().is(406));
- }
-
- @Test
- void getAllDatasetsByDataProviderInvalidUser() throws Exception {
- when(authenticationClient.getUserByAccessTokenInHeader(TestObjectFactory.AUTHORIZATION_HEADER))
- .thenThrow(new UserUnauthorizedException(CommonStringValues.UNAUTHORIZED));
-
- datasetControllerMock.perform(get("/datasets/data_provider/myDataProvider")
- .header("Authorization", TestObjectFactory.AUTHORIZATION_HEADER)
- .param("nextPage", "3")
- .contentType(MediaType.APPLICATION_JSON)
- .content(TestUtils.convertObjectToJsonBytes(null)))
- .andExpect(status().is(401))
- .andExpect(content().contentType(MediaType.APPLICATION_JSON))
- .andExpect(jsonPath("$.errorMessage", is(CommonStringValues.UNAUTHORIZED)));
-
- verify(datasetServiceMock, times(0))
- .getAllDatasetsByDataProvider(any(MetisUserView.class), anyString(), anyInt());
- }
-
- @Test
- void getAllDatasetsByOrganizationId() throws Exception {
- MetisUserView metisUserView = getUserWithAccountRole(AccountRole.EUROPEANA_DATA_OFFICER);
- List datasetList = getDatasets();
-
- when(authenticationClient.getUserByAccessTokenInHeader(TestObjectFactory.AUTHORIZATION_HEADER))
- .thenReturn(metisUserView);
- when(datasetServiceMock.getAllDatasetsByOrganizationId(metisUserView, "myOrganizationId", 3))
- .thenReturn(datasetList);
- when(datasetServiceMock.getDatasetsPerRequestLimit()).thenReturn(5);
-
- datasetControllerMock.perform(get("/datasets/organization_id/myOrganizationId")
- .header("Authorization", TestObjectFactory.AUTHORIZATION_HEADER)
- .param("nextPage", "3")
- .contentType(MediaType.APPLICATION_JSON)
- .content(TestUtils.convertObjectToJsonBytes(null)))
- .andExpect(status().is(200))
- .andExpect(content().contentType(MediaType.APPLICATION_JSON))
- .andExpect(jsonPath("$.results", hasSize(2)))
- .andExpect(jsonPath("$.results[0].datasetId",
- is(Integer.toString(TestObjectFactory.DATASETID + 1))))
- .andExpect(jsonPath("$.results[1].datasetId",
- is(Integer.toString(TestObjectFactory.DATASETID + 2))));
-
- ArgumentCaptor provider = ArgumentCaptor.forClass(String.class);
- ArgumentCaptor page = ArgumentCaptor.forClass(Integer.class);
- verify(datasetServiceMock, times(1))
- .getAllDatasetsByOrganizationId(any(MetisUserView.class), provider.capture(), page.capture());
-
- assertEquals("myOrganizationId", provider.getValue());
- assertEquals(3, page.getValue().intValue());
- }
-
- @Test
- void getAllDatasetsByOrganizationIdNegativeNextPage() throws Exception {
- datasetControllerMock.perform(get("/datasets/organization_id/myOrganizationId")
- .header("Authorization", TestObjectFactory.AUTHORIZATION_HEADER)
- .param("nextPage", "-1")
- .contentType(MediaType.APPLICATION_JSON)
- .content(TestUtils.convertObjectToJsonBytes(null)))
- .andExpect(status().is(406));
- }
-
- @Test
- void getAllDatasetsByOrganizationIdInvalidUser() throws Exception {
- when(authenticationClient.getUserByAccessTokenInHeader(TestObjectFactory.AUTHORIZATION_HEADER))
- .thenThrow(new UserUnauthorizedException(CommonStringValues.UNAUTHORIZED));
-
- datasetControllerMock.perform(get("/datasets/organization_id/myOrganizationId")
- .header("Authorization", TestObjectFactory.AUTHORIZATION_HEADER)
- .param("nextPage", "3")
- .contentType(MediaType.APPLICATION_JSON)
- .content(TestUtils.convertObjectToJsonBytes(null)))
- .andExpect(status().is(401))
- .andExpect(content().contentType(MediaType.APPLICATION_JSON))
- .andExpect(jsonPath("$.errorMessage", is(CommonStringValues.UNAUTHORIZED)));
-
- verify(datasetServiceMock, times(0))
- .getAllDatasetsByOrganizationId(any(MetisUserView.class), anyString(), anyInt());
- }
-
- @Test
- void getAllDatasetsByOrganizationName() throws Exception {
- MetisUserView metisUserView = getUserWithAccountRole(AccountRole.EUROPEANA_DATA_OFFICER);
- List datasetList = getDatasets();
-
- when(authenticationClient.getUserByAccessTokenInHeader(TestObjectFactory.AUTHORIZATION_HEADER))
- .thenReturn(metisUserView);
- when(datasetServiceMock.getAllDatasetsByOrganizationName(metisUserView, "myOrganizationName", 3))
- .thenReturn(datasetList);
- when(datasetServiceMock.getDatasetsPerRequestLimit()).thenReturn(5);
-
- datasetControllerMock.perform(get("/datasets/organization_name/myOrganizationName")
- .header("Authorization", TestObjectFactory.AUTHORIZATION_HEADER)
- .param("nextPage", "3")
- .contentType(MediaType.APPLICATION_JSON)
- .content(TestUtils.convertObjectToJsonBytes(null)))
- .andExpect(status().is(200))
- .andExpect(content().contentType(MediaType.APPLICATION_JSON))
- .andExpect(jsonPath("$.results", hasSize(2)))
- .andExpect(jsonPath("$.results[0].datasetId",
- is(Integer.toString(TestObjectFactory.DATASETID + 1))))
- .andExpect(jsonPath("$.results[1].datasetId",
- is(Integer.toString(TestObjectFactory.DATASETID + 2))));
-
- ArgumentCaptor provider = ArgumentCaptor.forClass(String.class);
- ArgumentCaptor page = ArgumentCaptor.forClass(Integer.class);
- verify(datasetServiceMock, times(1))
- .getAllDatasetsByOrganizationName(any(MetisUserView.class), provider.capture(), page.capture());
-
- assertEquals("myOrganizationName", provider.getValue());
- assertEquals(3, page.getValue().intValue());
- }
-
- @Test
- void getAllDatasetsByOrganizationNameNegativeNextPage() throws Exception {
- datasetControllerMock.perform(get("/datasets/organization_name/myOrganizationName")
- .header("Authorization", TestObjectFactory.AUTHORIZATION_HEADER)
- .param("nextPage", "-1")
- .contentType(MediaType.APPLICATION_JSON)
- .content(TestUtils.convertObjectToJsonBytes(null)))
- .andExpect(status().is(406));
- }
-
- @Test
- void getAllDatasetsByOrganizationNameInvalidUser() throws Exception {
- when(authenticationClient.getUserByAccessTokenInHeader(TestObjectFactory.AUTHORIZATION_HEADER))
- .thenThrow(new UserUnauthorizedException(CommonStringValues.UNAUTHORIZED));
-
- datasetControllerMock.perform(get("/datasets/organization_name/myOrganizationName")
- .header("Authorization", TestObjectFactory.AUTHORIZATION_HEADER)
- .param("nextPage", "3")
- .contentType(MediaType.APPLICATION_JSON)
- .content(TestUtils.convertObjectToJsonBytes(null)))
- .andExpect(status().is(401))
- .andExpect(content().contentType(MediaType.APPLICATION_JSON))
- .andExpect(jsonPath("$.errorMessage", is(CommonStringValues.UNAUTHORIZED)));
-
- verify(datasetServiceMock, times(0))
- .getAllDatasetsByOrganizationName(any(MetisUserView.class), anyString(), anyInt());
- }
-
- @Test
- void getDatasetsCountries() throws Exception {
- MetisUserView metisUserView = TestObjectFactory.createMetisUser(TestObjectFactory.EMAIL);
- when(authenticationClient.getUserByAccessTokenInHeader(TestObjectFactory.AUTHORIZATION_HEADER))
- .thenReturn(metisUserView);
-
- MvcResult mvcResult = datasetControllerMock.perform(get("/datasets/countries")
- .header("Authorization", TestObjectFactory.AUTHORIZATION_HEADER)
- .contentType(MediaType.APPLICATION_JSON)
- .content(""))
- .andExpect(status().is(200))
- .andExpect(content().contentType(MediaType.APPLICATION_JSON)).andReturn();
-
- String resultListOfCountries = mvcResult.getResponse().getContentAsString();
- Object document = Configuration.defaultConfiguration().jsonProvider()
- .parse(resultListOfCountries);
-
- List