DS-3489: Fixes after rebase on master

This commit is contained in:
Tom Desair
2017-12-13 23:39:12 +01:00
parent a45709ae90
commit f6b7805b88
19 changed files with 87 additions and 45 deletions

View File

@@ -7,16 +7,6 @@
*/
package org.dspace.core;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.EmptyStackException;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.Stack;
import java.util.UUID;
import org.apache.log4j.Logger;
import org.dspace.authorize.ResourcePolicy;
import org.dspace.content.DSpaceObject;
@@ -32,6 +22,10 @@ import org.dspace.storage.rdbms.DatabaseUtils;
import org.dspace.utils.DSpace;
import org.springframework.util.CollectionUtils;
import java.sql.SQLException;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
/**
* Class representing the context of a particular DSpace operation. This stores
* information such as the current authenticated user and the database

View File

@@ -513,9 +513,15 @@ public class DatabaseUtils
log.info("Loading Flyway DB migrations from: " + StringUtils.join(scriptLocations, ", "));
flywaydb.setLocations(scriptLocations.toArray(new String[scriptLocations.size()]));
} catch (SQLException e) {
log.error("Unable to setup Flyway against DSpace database", e);
}
// Set flyway callbacks (i.e. classes which are called post-DB migration and similar)
// In this situation, we have a Registry Updater that runs PRE-migration
// NOTE: DatabaseLegacyReindexer only indexes in Legacy Lucene & RDBMS indexes. It can be removed once those are obsolete.
List<FlywayCallback> flywayCallbacks = DSpaceServicesFactory.getInstance().getServiceManager().getServicesByType(FlywayCallback.class);
flywaydb.setCallbacks(flywayCallbacks.toArray(new FlywayCallback[flywayCallbacks.size()]));
}
catch(SQLException e)
{
log.error("Unable to setup Flyway against DSpace database", e);
}
}
@@ -600,11 +606,22 @@ public class DatabaseUtils
// Setup Flyway API against our database
Flyway flyway = setupFlyway(datasource);
// Set whethe Flyway will run migrations "out of order". By default, this is false,
// and Flyway ONLY runs migrations that have a higher version number.
flyway.setOutOfOrder(outOfOrder);
// If a target version was specified, tell Flyway to ONLY migrate to that version
// (i.e. all later migrations are left as "pending"). By default we always migrate to latest version.
if(!StringUtils.isBlank(targetVersion))
{
flyway.setTargetAsString(targetVersion);
}
// Does the necessary Flyway table ("schema_version") exist in this database?
// If not, then this is the first time Flyway has run, and we need to initialize
// NOTE: search is case sensitive, as flyway table name is ALWAYS lowercase,
// See: http://flywaydb.org/documentation/faq.html#case-sensitive
if (!tableExists(connection, flyway.getTable(), true))
if(!tableExists(connection, flyway.getTable(), true))
{
// Try to determine our DSpace database version, so we know what to tell Flyway to do
String dbVersion = determineDBVersion(connection);
@@ -624,6 +641,7 @@ public class DatabaseUtils
}
}
// Determine pending Database migrations
MigrationInfo[] pending = flyway.info().pending();
// As long as there are pending migrations, log them and run migrate()

View File

@@ -37,4 +37,4 @@ public class RESTSpringLoader implements SpringLoader {
return new String[0];
}
}
}
}

View File

@@ -9,9 +9,10 @@ package org.dspace.app.rest.model;
import java.io.Serializable;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.springframework.hateoas.Identifiable;
import com.fasterxml.jackson.annotation.JsonIgnore;
/**
* Base class for any REST resource that need to be addressable
*

View File

@@ -9,9 +9,10 @@ package org.dspace.app.rest.model;
import java.util.List;
import org.dspace.app.rest.RestResourceController;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.dspace.app.rest.RestResourceController;
/**
* The Browse Index REST Resource

View File

@@ -9,9 +9,10 @@ package org.dspace.app.rest.model;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.dspace.app.rest.RestResourceController;
import com.fasterxml.jackson.annotation.JsonIgnore;
/**
* The Group REST Resource
*

View File

@@ -11,6 +11,8 @@ import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty.Access;
/**
* The Item REST Resource

View File

@@ -7,9 +7,10 @@
*/
package org.dspace.app.rest.model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.dspace.app.rest.RestResourceController;
import com.fasterxml.jackson.annotation.JsonIgnore;
/**
* The MetadataField REST Resource
*

View File

@@ -7,8 +7,12 @@
*/
package org.dspace.app.rest.model;
import java.util.List;
import org.dspace.app.rest.RestResourceController;
import com.fasterxml.jackson.annotation.JsonIgnore;
/**
* The MetadataSchema REST Resource
*

View File

@@ -38,7 +38,4 @@ public interface RestModel extends Serializable {
@JsonIgnore
public Class getController();
}

View File

@@ -21,6 +21,7 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Component;
/**
* This is the repository responsible to manage BitstreamFormat Rest object
*

View File

@@ -7,12 +7,16 @@
*/
package org.dspace.app.rest.repository;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import org.dspace.app.rest.converter.BrowseIndexConverter;
import org.dspace.app.rest.converter.CollectionConverter;
import org.dspace.app.rest.model.BrowseIndexRest;
import org.dspace.app.rest.model.CollectionRest;
import org.dspace.app.rest.model.hateoas.BrowseIndexResource;
import org.dspace.app.rest.model.hateoas.CollectionResource;
import org.dspace.browse.BrowseException;
import org.dspace.browse.BrowseIndex;
import org.dspace.core.Context;
@@ -20,6 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.data.rest.webmvc.ResourceNotFoundException;
import org.springframework.stereotype.Component;
/**

View File

@@ -11,7 +11,13 @@ import java.io.Serializable;
import org.dspace.app.rest.model.RestModel;
import org.dspace.app.rest.model.hateoas.DSpaceResource;
import org.dspace.app.rest.utils.ContextUtil;
import org.dspace.app.rest.utils.Utils;
import org.dspace.core.Context;
import org.dspace.services.RequestService;
import org.dspace.services.model.Request;
import org.dspace.utils.DSpace;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;

View File

@@ -22,7 +22,6 @@ import org.springframework.data.web.config.EnableSpringDataWebSupport;
@EnableSpringDataWebSupport
@ComponentScan({ "org.dspace.app.rest.converter", "org.dspace.app.rest.repository", "org.dspace.app.rest.utils" })
public class ApplicationConfig {
@Value("${dspace.dir}")
private String dspaceHome;

View File

@@ -7,11 +7,6 @@
*/
package org.dspace.app.rest.utils;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import org.apache.log4j.Logger;
import org.dspace.core.Context;

View File

@@ -12,16 +12,7 @@ import org.dspace.authorize.factory.AuthorizeServiceFactory;
import org.dspace.authorize.service.AuthorizeService;
import org.dspace.authorize.service.ResourcePolicyService;
import org.dspace.content.factory.ContentServiceFactory;
import org.dspace.content.service.BitstreamFormatService;
import org.dspace.content.service.BitstreamService;
import org.dspace.content.service.BundleService;
import org.dspace.content.service.CollectionService;
import org.dspace.content.service.CommunityService;
import org.dspace.content.service.DSpaceObjectService;
import org.dspace.content.service.InstallItemService;
import org.dspace.content.service.ItemService;
import org.dspace.content.service.WorkspaceItemService;
import org.dspace.core.Constants;
import org.dspace.content.service.*;
import org.dspace.core.Context;
import org.dspace.discovery.IndexingService;
import org.dspace.eperson.factory.EPersonServiceFactory;
@@ -63,6 +54,15 @@ public abstract class AbstractBuilder<T, S> {
static AuthorizeService authorizeService;
static ResourcePolicyService resourcePolicyService;
static IndexingService indexingService;
static RegistrationDataService registrationDataService;
static VersionHistoryService versionHistoryService;
static ClaimedTaskService claimedTaskService;
static InProgressUserService inProgressUserService;
static PoolTaskService poolTaskService;
static WorkflowItemRoleService workflowItemRoleService;
static MetadataFieldService metadataFieldService;
static MetadataSchemaService metadataSchemaService;
static SiteService siteService;
protected Context context;
@@ -89,6 +89,18 @@ public abstract class AbstractBuilder<T, S> {
authorizeService = AuthorizeServiceFactory.getInstance().getAuthorizeService();
resourcePolicyService = AuthorizeServiceFactory.getInstance().getResourcePolicyService();
indexingService = DSpaceServicesFactory.getInstance().getServiceManager().getServiceByName(IndexingService.class.getName(),IndexingService.class);
registrationDataService = EPersonServiceFactory.getInstance().getRegistrationDataService();
versionHistoryService = VersionServiceFactory.getInstance().getVersionHistoryService();
metadataFieldService = ContentServiceFactory.getInstance().getMetadataFieldService();
metadataSchemaService = ContentServiceFactory.getInstance().getMetadataSchemaService();
siteService = ContentServiceFactory.getInstance().getSiteService();
// Temporarily disabled
// TODO find a way to be able to test the XML and "default" workflow at the same time
//claimedTaskService = XmlWorkflowServiceFactoryImpl.getInstance().getClaimedTaskService();
//inProgressUserService = XmlWorkflowServiceFactoryImpl.getInstance().getInProgressUserService();
//poolTaskService = XmlWorkflowServiceFactoryImpl.getInstance().getPoolTaskService();
//workflowItemRoleService = XmlWorkflowServiceFactoryImpl.getInstance().getWorkflowItemRoleService();
}
@@ -106,6 +118,15 @@ public abstract class AbstractBuilder<T, S> {
resourcePolicyService = null;
indexingService = null;
bitstreamFormatService = null;
registrationDataService = null;
versionHistoryService = null;
claimedTaskService = null;
inProgressUserService = null;
poolTaskService = null;
workflowItemRoleService = null;
metadataFieldService = null;
metadataSchemaService = null;
siteService = null;
}
public static void cleanupObjects() throws Exception {

View File

@@ -45,7 +45,8 @@ public class ItemMatcher {
hasJsonPath("$._links.self.href", startsWith(REST_SERVER_URL)),
hasJsonPath("$._links.bitstreams.href", startsWith(REST_SERVER_URL)),
hasJsonPath("$._links.owningCollection.href", startsWith(REST_SERVER_URL)),
hasJsonPath("$._links.templateItemOf.href", startsWith(REST_SERVER_URL))
hasJsonPath("$._links.templateItemOf.href", startsWith(REST_SERVER_URL)),
hasJsonPath("$._links.self.href", startsWith(REST_SERVER_URL))
);
}

View File

@@ -107,6 +107,5 @@ public class AbstractDSpaceIntegrationTest
return System.getProperty("dspace.dir");
}
}

View File

@@ -9,12 +9,12 @@ package org.dspace.app.rest.test;
import static org.junit.Assert.fail;
import java.io.IOException;
import java.sql.SQLException;
import java.util.Arrays;
import org.apache.log4j.Logger;
import org.dspace.app.launcher.ScriptLauncher;
import org.dspace.app.rest.builder.AbstractBuilder;
import org.dspace.authorize.AuthorizeException;
import org.dspace.content.Community;
import org.dspace.core.Context;
@@ -28,10 +28,6 @@ import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import java.sql.SQLException;
import static org.junit.Assert.fail;
/**
* Abstract Test class that will initialize the in-memory database
*/