Upgrade Spring (REPO-1295), Quartz (REPO-3049) and remove Hibernate (REPO-2873) (#45)

* Change context file schemas
* Change quartz related usages
This commit is contained in:
Alex Mukha
2018-03-04 16:58:48 +00:00
committed by GitHub
parent dbe4c07bd6
commit b2b0c9e660
21 changed files with 284 additions and 568 deletions

View File

@@ -35,16 +35,16 @@
<dir.root>${project.build.directory}/alf_data</dir.root> <dir.root>${project.build.directory}/alf_data</dir.root>
<img.exe>convert</img.exe> <img.exe>convert</img.exe>
<dependency.alfresco-repository.version>6.27</dependency.alfresco-repository.version> <dependency.alfresco-repository.version>6.28</dependency.alfresco-repository.version>
<dependency.alfresco-core.version>6.18</dependency.alfresco-core.version> <dependency.alfresco-core.version>7.0</dependency.alfresco-core.version>
<dependency.alfresco-data-model.version>7.3</dependency.alfresco-data-model.version> <dependency.alfresco-data-model.version>8.0</dependency.alfresco-data-model.version>
<dependency.alfresco-pdf-renderer.version>1.1</dependency.alfresco-pdf-renderer.version> <dependency.alfresco-pdf-renderer.version>1.1</dependency.alfresco-pdf-renderer.version>
<dependency.jackson.version>2.8.10</dependency.jackson.version> <dependency.jackson.version>2.8.10</dependency.jackson.version>
<dependency.webscripts.version>6.13</dependency.webscripts.version> <dependency.webscripts.version>6.13</dependency.webscripts.version>
<dependency.opencmis.version>1.0.0</dependency.opencmis.version> <dependency.opencmis.version>1.0.0</dependency.opencmis.version>
<dependency.spring.version>3.2.17.RELEASE</dependency.spring.version> <dependency.spring.version>5.0.4.RELEASE</dependency.spring.version>
<dependency.postgresql.version>9.4.1212</dependency.postgresql.version> <dependency.postgresql.version>9.4.1212</dependency.postgresql.version>
<dependency.mysql.version>5.1.40</dependency.mysql.version> <dependency.mysql.version>5.1.40</dependency.mysql.version>
</properties> </properties>

View File

@@ -35,8 +35,8 @@ import org.alfresco.rest.framework.Operation;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.core.BridgeMethodResolver; import org.springframework.core.BridgeMethodResolver;
import org.springframework.core.GenericCollectionTypeResolver;
import org.springframework.core.GenericTypeResolver; import org.springframework.core.GenericTypeResolver;
import org.springframework.core.ResolvableType;
import org.springframework.core.annotation.AnnotationUtils; import org.springframework.core.annotation.AnnotationUtils;
/** /**
@@ -74,7 +74,7 @@ public class ResourceInspectorUtil
Class returnType = GenericTypeResolver.resolveReturnType(resolvedMethod, resource); Class returnType = GenericTypeResolver.resolveReturnType(resolvedMethod, resource);
if (List.class.isAssignableFrom(returnType)) if (List.class.isAssignableFrom(returnType))
{ {
return GenericCollectionTypeResolver.getCollectionReturnType(method); return ResolvableType.forMethodReturnType(method).asCollection().getGeneric(0).resolve();
} }
return returnType; return returnType;
} }

View File

@@ -139,9 +139,9 @@ public class ResourceWebScriptPut extends AbstractResourceWebScript implements P
{ {
MediaType media = MediaType.parseMediaType(req.getContentType()); MediaType media = MediaType.parseMediaType(req.getContentType());
contentType = media.getType()+'/'+media.getSubtype(); contentType = media.getType()+'/'+media.getSubtype();
if (media.getCharSet() != null) if (media.getCharset() != null)
{ {
encoding = media.getCharSet().toString(); encoding = media.getCharset().toString();
} }
} }

View File

@@ -1,7 +1,9 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN 2.0//EN' 'http://www.springframework.org/dtd/spring-beans-2.0.dtd'> <beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<beans>
<bean id="abstractBlogWebScript" parent="webscript" abstract="true"> <bean id="abstractBlogWebScript" parent="webscript" abstract="true">
<property name="repository" ref="repositoryHelper"/> <property name="repository" ref="repositoryHelper"/>
<property name="blogService" ref="BlogService"/> <property name="blogService" ref="BlogService"/>

View File

@@ -2,8 +2,8 @@
<beans xmlns="http://www.springframework.org/schema/beans" <beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<bean id="publicapi.webscripts.store" parent="webscripts.repoclasspathstore"> <bean id="publicapi.webscripts.store" parent="webscripts.repoclasspathstore">
<property name="mustExist"><value>true</value></property> <property name="mustExist"><value>true</value></property>
@@ -42,7 +42,7 @@
<bean name="publicapi.webScriptsRegistryCache" class="org.alfresco.repo.web.scripts.RegistryAsynchronouslyRefreshedCache" parent="abstractAsynchronouslyRefreshedCache"> <bean name="publicapi.webScriptsRegistryCache" class="org.alfresco.repo.web.scripts.RegistryAsynchronouslyRefreshedCache" parent="abstractAsynchronouslyRefreshedCache">
<property name="registryFactory"> <property name="registryFactory">
<bean class="org.springframework.beans.factory.config.ObjectFactoryCreatingFactoryBean"> <bean class="org.springframework.beans.factory.config.ObjectFactoryCreatingFactoryBean">
<property name="targetBeanName"><idref local="publicapi.registry.prototype"/></property> <property name="targetBeanName"><idref bean="publicapi.registry.prototype"/></property>
</bean> </bean>
</property> </property>
<property name="retryingTransactionHelper" ref="retryingTransactionHelper" /> <property name="retryingTransactionHelper" ref="retryingTransactionHelper" />

View File

@@ -1,7 +1,8 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'> <beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<beans> xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="webdav.initParams" class="org.alfresco.repo.webdav.WebDAVServlet$WebDAVInitParameters"> <bean id="webdav.initParams" class="org.alfresco.repo.webdav.WebDAVServlet$WebDAVInitParameters">
<property name="enabled" value="${system.webdav.servlet.enabled}" /> <property name="enabled" value="${system.webdav.servlet.enabled}" />

View File

@@ -1,7 +1,8 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN 2.0//EN' 'http://www.springframework.org/dtd/spring-beans-2.0.dtd'> <beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<beans> xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<!-- --> <!-- -->
<!-- Web Script Configuration --> <!-- Web Script Configuration -->
@@ -185,7 +186,7 @@
<bean name="webScriptsRegistryCache" class="org.alfresco.repo.web.scripts.RegistryAsynchronouslyRefreshedCache" parent="abstractAsynchronouslyRefreshedCache"> <bean name="webScriptsRegistryCache" class="org.alfresco.repo.web.scripts.RegistryAsynchronouslyRefreshedCache" parent="abstractAsynchronouslyRefreshedCache">
<property name="registryFactory"> <property name="registryFactory">
<bean class="org.springframework.beans.factory.config.ObjectFactoryCreatingFactoryBean"> <bean class="org.springframework.beans.factory.config.ObjectFactoryCreatingFactoryBean">
<property name="targetBeanName"><idref local="webscripts.registry.prototype"/></property> <property name="targetBeanName"><idref bean="webscripts.registry.prototype"/></property>
</bean> </bean>
</property> </property>
<property name="retryingTransactionHelper" ref="retryingTransactionHelper" /> <property name="retryingTransactionHelper" ref="retryingTransactionHelper" />

View File

@@ -69,10 +69,6 @@ import org.junit.runners.Suite;
org.alfresco.repo.remoteticket.RemoteAlfrescoTicketServiceTest.class, org.alfresco.repo.remoteticket.RemoteAlfrescoTicketServiceTest.class,
org.alfresco.repo.web.scripts.servlet.RemoteAuthenticatorFactoryTest.class, org.alfresco.repo.web.scripts.servlet.RemoteAuthenticatorFactoryTest.class,
// [classpath:alfresco/application-context.xml, classpath:subsystem-test-context.xml]
org.alfresco.repo.management.subsystems.test.SubsystemsTest.class,
// [classpath:alfresco/application-context.xml] // [classpath:alfresco/application-context.xml]
org.alfresco.repo.webdav.GetMethodRegressionTest.class, org.alfresco.repo.webdav.GetMethodRegressionTest.class,
org.alfresco.repo.webdav.WebDAVHelperIntegrationTest.class, org.alfresco.repo.webdav.WebDAVHelperIntegrationTest.class,

View File

@@ -1,228 +0,0 @@
/*
* #%L
* Alfresco Remote API
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.repo.management.subsystems.test;
import java.io.IOException;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.SocketTimeoutException;
import java.util.HashMap;
import java.util.Map;
import org.alfresco.repo.management.subsystems.ApplicationContextFactory;
import org.alfresco.repo.management.subsystems.ChildApplicationContextFactory;
import org.alfresco.repo.management.subsystems.InvalidPropertyValueException;
import org.alfresco.repo.management.subsystems.SubsystemEarlyPropertyChecker;
import org.alfresco.test_category.OwnJVMTestsCategory;
import org.alfresco.util.ApplicationContextHelper;
import org.alfresco.util.BaseSpringTest;
import org.apache.commons.logging.LogFactory;
import org.junit.experimental.categories.Category;
import org.springframework.context.ConfigurableApplicationContext;
/**
* Ensures the following features of subsystems are working:
* <ul>
* <li>Subsystem default properties
* <li>Global property overrides (via alfresco-global.properties)
* <li>Subsystem instance specific property overrides (via extension classpath)
* <li>Subsystem instance specific Spring overrides (via extension classpath)
* <li>Composite property defaults
* <li>Composite property instance overrides
* </ul>
*
* @see ChildApplicationContextFactory
* @author dward
*/
@Category(OwnJVMTestsCategory.class)
public class SubsystemsTest extends BaseSpringTest
{
volatile boolean shouldBlockPort;
/*
* (non-Javadoc)
* @see org.alfresco.util.BaseSpringTest#getConfigLocations()
*/
@Override
protected String[] getConfigLocations()
{
return new String[]
{
ApplicationContextHelper.CONFIG_LOCATIONS[0], "classpath:subsystem-test-context.xml"
};
}
/**
* Test subsystems.
*
* @throws Exception
* the exception
*/
public void testSubsystems() throws Exception
{
ApplicationContextFactory subsystem = (ApplicationContextFactory) getApplicationContext().getBean(
"testsubsystem");
ConfigurableApplicationContext childContext = (ConfigurableApplicationContext) subsystem
.getApplicationContext();
assertTrue("Subsystem not started", childContext.isActive());
TestService testService = (TestService) childContext.getBean("testService");
// Make sure subsystem defaults work
assertEquals("Subsystem Default1", testService.getSimpleProp1());
// Make sure global property overrides work
assertEquals(true, testService.getSimpleProp2().booleanValue());
// Make sure extension classpath property overrides work
assertEquals("Instance Override3", testService.getSimpleProp3());
// Make sure extension classpath Spring overrides work
assertEquals("An extra bean I changed", childContext.getBean("anotherBean"));
// Make sure composite properties and their defaults work
TestBean[] testBeans = testService.getTestBeans();
assertNotNull("Composite property not set", testBeans);
assertEquals(3, testBeans.length);
assertEquals("inst1", testBeans[0].getId());
assertEquals(false, testBeans[0].isBoolProperty());
assertEquals(123456789123456789L, testBeans[0].getLongProperty());
assertEquals("Global Default", testBeans[0].getAnotherStringProperty());
assertEquals("inst2", testBeans[1].getId());
assertEquals(true, testBeans[1].isBoolProperty());
assertEquals(123456789123456789L, testBeans[1].getLongProperty());
assertEquals("Global Default", testBeans[1].getAnotherStringProperty());
assertEquals("inst3", testBeans[2].getId());
assertEquals(false, testBeans[2].isBoolProperty());
assertEquals(123456789123456789L, testBeans[2].getLongProperty());
assertEquals("Global Instance Default", testBeans[2].getAnotherStringProperty());
}
public void testAbstractPropertyBackedBean_performEarlyPropertyChecks_PortEarlyPropertyChecker()
{
int testPortNumber = (Integer) getApplicationContext().getBean("testPortNumber");
String testHost = (String) getApplicationContext().getBean("testHost");
ChildApplicationContextFactory testBean = (ChildApplicationContextFactory) getApplicationContext().getBean("testsubsystem");
Map<String, String> testProperties = new HashMap<String, String>();
// Check for empty port value error:
testProperties.put("test1.port", "");
// Check for "unable to parse" error:
testProperties.put("test2.port", "123xy");
// Check for "out-of-bounds" (less than) error:
testProperties.put("test3.port", "0");
// Check for "out of bounds" (greater than) error:
testProperties.put("test4.port", "65536");
// Check for "port in use" error:
testProperties.put("test5.port", "" + testPortNumber);
String errorMessage = testBean.performEarlyPropertyChecks(testProperties);
assertTrue(errorMessage.contains("The value for TestSubsystem port property cannot be empty."));
assertTrue(errorMessage.contains("Unable to parse value for TestSubsystem port property: 123xy."));
assertTrue(errorMessage.contains("The port chosen for TestSubsystem is outside the required range (1, 65535): 0."));
assertTrue(errorMessage.contains("The port chosen for TestSubsystem is outside the required range (1, 65535): 65536."));
assertTrue(errorMessage.contains(
"The port chosen for TestSubsystem is already in use or you don't have permission to use it: " + testPortNumber + "."));
testProperties.clear();
testProperties.put("test_with_host.port", "" + testPortNumber);
// Check for unknown host:
testProperties.put("test.subsystem.host", testHost);
errorMessage = testBean.performEarlyPropertyChecks(testProperties);
assertTrue(errorMessage.contains(
"The hostname chosen for TestSubsystem is unknown or misspelled: " + testProperties.get("test.subsystem.host") + "."));
}
public void testAbstractPropertyBackedBean_performEarlyPropertyChecks_CustomEarlyPropertyChecker()
{
ChildApplicationContextFactory testBean = new ChildApplicationContextFactory();
SubsystemEarlyPropertyChecker testEarlyPropertyChecker = new SubsystemEarlyPropertyChecker()
{
@Override
public void checkPropertyValue(String propertyName, String propertyValue, String pairedPropertyValue) throws InvalidPropertyValueException
{
if (propertyValue == null || propertyValue.isEmpty())
{
throw new InvalidPropertyValueException("Property value cannot be empty.");
}
if (pairedPropertyValue == null)
{
if (propertyValue.equals("Bad value"))
{
throw new InvalidPropertyValueException("Property value cannot be a 'Bad value'.");
}
}
else if ((propertyValue + pairedPropertyValue).contains("bad value"))
{
throw new InvalidPropertyValueException("No 'bad value's allowed!");
}
}
@Override
public String getPairedPropertyName()
{
return "testPairedPropertyName";
}
};
Map<String, SubsystemEarlyPropertyChecker> earlyPropertyCheckersMap = new HashMap<String, SubsystemEarlyPropertyChecker>();
earlyPropertyCheckersMap.put("test1.property", testEarlyPropertyChecker);
earlyPropertyCheckersMap.put("test2.property", testEarlyPropertyChecker);
testBean.setEarlyPropertyCheckers(earlyPropertyCheckersMap);
Map<String, String> testProperties = new HashMap<String, String>();
// Test empty value error:
testProperties.put("test1.property", "");
// Test "Bad value" error:
testProperties.put("test2.property", "Bad value");
String errorMessage = testBean.performEarlyPropertyChecks(testProperties);
assertTrue(errorMessage.contains("Property value cannot be empty."));
assertTrue(errorMessage.contains("Property value cannot be a 'Bad value'."));
earlyPropertyCheckersMap.clear();
earlyPropertyCheckersMap.put("test3.property", testEarlyPropertyChecker);
testProperties.clear();
testProperties.put("testPairedPropertyName", "Test paired property bad value");
testProperties.put("test3.property", "Test property value");
errorMessage = testBean.performEarlyPropertyChecks(testProperties);
assertTrue(errorMessage.contains("No 'bad value's allowed!"));
}
}

View File

@@ -1,72 +0,0 @@
/*
* #%L
* Alfresco Remote API
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.repo.management.subsystems.test;
import java.io.IOException;
import org.alfresco.repo.management.subsystems.PortEarlyPropertyChecker;
public class TestPortEarlyPropertyChecker extends PortEarlyPropertyChecker
{
private int blockedPort = -1;
private String wrongHost = "";
public TestPortEarlyPropertyChecker(String subsystemName, boolean hasMultiplePorts,
boolean shouldCheckForBlockedPort)
{
super(subsystemName, hasMultiplePorts, shouldCheckForBlockedPort);
}
public TestPortEarlyPropertyChecker(String subsystemName, String requiredPairedPropertyName,
boolean hasMultiplePorts, boolean shouldCheckForBlockedPort)
{
super(subsystemName, requiredPairedPropertyName, hasMultiplePorts,
shouldCheckForBlockedPort);
}
public void setBlockedPort(int blockedPort)
{
this.blockedPort = blockedPort;
}
public void setWrongHost(String wrongHost)
{
this.wrongHost = wrongHost;
}
@Override
public void checkPort(int portNumber, String host) throws IOException
{
if (portNumber == blockedPort)
{
throw new java.net.BindException();
}
if (wrongHost.equals(host))
{
throw new java.net.UnknownHostException();
}
}
}

View File

@@ -42,11 +42,12 @@ import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.service.cmr.repository.ContentIOException; import org.alfresco.service.cmr.repository.ContentIOException;
import org.alfresco.service.cmr.security.MutableAuthenticationService; import org.alfresco.service.cmr.security.MutableAuthenticationService;
import org.alfresco.service.cmr.security.PersonService; import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.util.CronTriggerBean;
import org.alfresco.util.PropertyMap; import org.alfresco.util.PropertyMap;
import org.mockito.Mockito; import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock; import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer; import org.mockito.stubbing.Answer;
import org.quartz.CronTrigger;
import org.quartz.Scheduler;
import org.springframework.extensions.webscripts.Authenticator; import org.springframework.extensions.webscripts.Authenticator;
import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest;
import org.springframework.extensions.webscripts.TestWebScriptServer.PutRequest; import org.springframework.extensions.webscripts.TestWebScriptServer.PutRequest;
@@ -161,12 +162,11 @@ public class RepositoryContainerTest extends BaseWebScriptTest
assertEquals(SUCCESS, response.getContentAsString()); assertEquals(SUCCESS, response.getContentAsString());
// trigger the webscript temp folder cleaner job // trigger the webscript temp folder cleaner job
CronTriggerBean webscriptsTempFileCleanerJobTrigger = (CronTriggerBean) getServer().getApplicationContext().getBean("webscripts.tempFileCleanerTrigger"); CronTrigger webscriptsTempFileCleanerJobTrigger = (CronTrigger) getServer().getApplicationContext().getBean("webscripts.tempFileCleanerTrigger");
webscriptsTempFileCleanerJobTrigger.getScheduler().triggerJobWithVolatileTrigger( Scheduler scheduler = (Scheduler) getServer().getApplicationContext().getBean("schedulerFactory");
webscriptsTempFileCleanerJobTrigger.getJobDetail().getName(),
webscriptsTempFileCleanerJobTrigger.getJobDetail().getGroup(), scheduler.triggerJob(webscriptsTempFileCleanerJobTrigger.getJobKey());
webscriptsTempFileCleanerJobTrigger.getJobDetail().getJobDataMap());
// check that we still can upload file larger than 4 mb, i.e. ensure that cleaner has not deleted temp folder // check that we still can upload file larger than 4 mb, i.e. ensure that cleaner has not deleted temp folder
response = sendRequest(new PutRequest("/test/largecontenttest", content, "text/plain"), STATUS_OK); response = sendRequest(new PutRequest("/test/largecontenttest", content, "text/plain"), STATUS_OK);

View File

@@ -25,11 +25,15 @@
*/ */
package org.alfresco.repo.webdav; package org.alfresco.repo.webdav;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.repo.action.executer.ContentMetadataExtracter;
import org.alfresco.repo.model.Repository; import org.alfresco.repo.model.Repository;
import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.permissions.AccessDeniedException; import org.alfresco.repo.security.permissions.AccessDeniedException;
import org.alfresco.repo.transaction.RetryingTransactionHelper; import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.rest.api.tests.client.data.Action;
import org.alfresco.service.cmr.action.ActionService;
import org.alfresco.service.cmr.coci.CheckOutCheckInService; import org.alfresco.service.cmr.coci.CheckOutCheckInService;
import org.alfresco.service.cmr.lock.LockService; import org.alfresco.service.cmr.lock.LockService;
import org.alfresco.service.cmr.lock.LockStatus; import org.alfresco.service.cmr.lock.LockStatus;
@@ -78,6 +82,8 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
/** /**
* Unit tests for the {@link PutMethod} class. * Unit tests for the {@link PutMethod} class.
@@ -114,6 +120,7 @@ public class PutMethodTest
private ContentService contentService; private ContentService contentService;
private CheckOutCheckInService checkOutCheckInService; private CheckOutCheckInService checkOutCheckInService;
private PermissionService permissionService; private PermissionService permissionService;
private ActionService actionService;
private Repository repositoryHelper; private Repository repositoryHelper;
private NodeRef companyHomeNodeRef; private NodeRef companyHomeNodeRef;
@@ -148,6 +155,7 @@ public class PutMethodTest
checkOutCheckInService = ctx.getBean("CheckOutCheckInService", CheckOutCheckInService.class); checkOutCheckInService = ctx.getBean("CheckOutCheckInService", CheckOutCheckInService.class);
permissionService = ctx.getBean("PermissionService", PermissionService.class); permissionService = ctx.getBean("PermissionService", PermissionService.class);
namespaceService = ctx.getBean("namespaceService", NamespaceService.class); namespaceService = ctx.getBean("namespaceService", NamespaceService.class);
actionService = ctx.getBean("ActionService", ActionService.class);
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
@@ -805,8 +813,14 @@ public class PutMethodTest
String lockHeaderValue = "(<" + WebDAV.OPAQUE_LOCK_TOKEN + lockToken + ">)"; String lockHeaderValue = "(<" + WebDAV.OPAQUE_LOCK_TOKEN + lockToken + ">)";
HashMap<String, String> headers = new HashMap<String, String>(); HashMap<String, String> headers = new HashMap<String, String>();
headers.put(WebDAV.HEADER_IF, lockHeaderValue); headers.put(WebDAV.HEADER_IF, lockHeaderValue);
// Simulate any failure during the content write
// null content is no longer null in MockHttpServletRequest (Spring 5)
ActionService mockActionService = mock(ActionService.class);
when(mockActionService.createAction(ContentMetadataExtracter.EXECUTOR_NAME))
.thenThrow(new AlfrescoRuntimeException("Negative test"));
try try
{ {
webDAVHelper.setActionService(mockActionService);
// setting a null content // setting a null content
executeMethod(WebDAV.METHOD_PUT, fileName, null, headers); executeMethod(WebDAV.METHOD_PUT, fileName, null, headers);
@@ -824,6 +838,10 @@ public class PutMethodTest
{ {
throw new RuntimeException("Failed to upload a file", e); throw new RuntimeException("Failed to upload a file", e);
} }
finally
{
webDAVHelper.setActionService(actionService);
}
if (fileNoderef != null && nodeService.exists(fileNoderef)) if (fileNoderef != null && nodeService.exists(fileNoderef))
{ {

View File

@@ -145,10 +145,11 @@ import org.apache.commons.logging.LogFactory;
import org.json.JSONException; import org.json.JSONException;
import org.json.simple.JSONObject; import org.json.simple.JSONObject;
import org.json.simple.JSONValue; import org.json.simple.JSONValue;
import org.quartz.CronTrigger;
import org.quartz.JobDetail;
import org.quartz.JobExecutionException; import org.quartz.JobExecutionException;
import org.quartz.Scheduler; import org.quartz.Scheduler;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.scheduling.quartz.JobDetailBean;
import com.google.common.collect.AbstractIterator; import com.google.common.collect.AbstractIterator;
@@ -185,11 +186,11 @@ public class RepoService
protected TenantService tenantService; protected TenantService tenantService;
protected TenantAdminService tenantAdminService; protected TenantAdminService tenantAdminService;
protected ActivityPostDAO postDAO; protected ActivityPostDAO postDAO;
protected JobDetailBean feedGeneratorJobDetail; protected JobDetail feedGeneratorJobDetail;
protected JobDetailBean postLookupJobDetail; protected JobDetail postLookupJobDetail;
protected JobDetailBean feedCleanerJobDetail; protected JobDetail feedCleanerJobDetail;
protected JobDetailBean postCleanerJobDetail; protected JobDetail postCleanerJobDetail;
protected JobDetailBean feedNotifierJobDetail; protected JobDetail feedNotifierJobDetail;
protected ContentStoreCleaner contentStoreCleaner; protected ContentStoreCleaner contentStoreCleaner;
protected FeedCleaner feedCleaner; protected FeedCleaner feedCleaner;
protected PersonService personService; protected PersonService personService;
@@ -265,26 +266,26 @@ public class RepoService
Scheduler scheduler = (Scheduler)applicationContext.getBean("schedulerFactory"); Scheduler scheduler = (Scheduler)applicationContext.getBean("schedulerFactory");
JobDetailBean contentStoreCleanerJobDetail = (JobDetailBean)applicationContext.getBean("contentStoreCleanerJobDetail"); CronTrigger contentStoreCleanerTrigger = (CronTrigger)applicationContext.getBean("contentStoreCleanerTrigger");
scheduler.pauseJob(contentStoreCleanerJobDetail.getName(), contentStoreCleanerJobDetail.getGroup()); scheduler.pauseJob(contentStoreCleanerTrigger.getJobKey());
ChildApplicationContextFactory activitiesFeed = (ChildApplicationContextFactory)applicationContext.getBean("ActivitiesFeed"); ChildApplicationContextFactory activitiesFeed = (ChildApplicationContextFactory)applicationContext.getBean("ActivitiesFeed");
ApplicationContext activitiesFeedCtx = activitiesFeed.getApplicationContext(); ApplicationContext activitiesFeedCtx = activitiesFeed.getApplicationContext();
this.postLookup = (PostLookup)activitiesFeedCtx.getBean("postLookup"); this.postLookup = (PostLookup)activitiesFeedCtx.getBean("postLookup");
this.feedGenerator = (FeedGenerator)activitiesFeedCtx.getBean("feedGenerator"); this.feedGenerator = (FeedGenerator)activitiesFeedCtx.getBean("feedGenerator");
this.feedGeneratorJobDetail = (JobDetailBean)activitiesFeedCtx.getBean("feedGeneratorJobDetail"); this.feedGeneratorJobDetail = (JobDetail)activitiesFeedCtx.getBean("feedGeneratorJobDetail");
this.postLookupJobDetail = (JobDetailBean)activitiesFeedCtx.getBean("postLookupJobDetail"); this.postLookupJobDetail = (JobDetail)activitiesFeedCtx.getBean("postLookupJobDetail");
this.feedCleanerJobDetail = (JobDetailBean)activitiesFeedCtx.getBean("feedCleanerJobDetail"); this.feedCleanerJobDetail = (JobDetail)activitiesFeedCtx.getBean("feedCleanerJobDetail");
this.postCleanerJobDetail = (JobDetailBean)activitiesFeedCtx.getBean("postCleanerJobDetail"); this.postCleanerJobDetail = (JobDetail)activitiesFeedCtx.getBean("postCleanerJobDetail");
this.feedNotifierJobDetail = (JobDetailBean)activitiesFeedCtx.getBean("feedNotifierJobDetail"); this.feedNotifierJobDetail = (JobDetail)activitiesFeedCtx.getBean("feedNotifierJobDetail");
this.feedCleaner = (FeedCleaner)activitiesFeedCtx.getBean("feedCleaner"); this.feedCleaner = (FeedCleaner)activitiesFeedCtx.getBean("feedCleaner");
// Pause activities jobs so that we aren't competing with their scheduled versions // Pause activities jobs so that we aren't competing with their scheduled versions
scheduler.pauseJob(feedGeneratorJobDetail.getName(), feedGeneratorJobDetail.getGroup()); scheduler.pauseJob(feedGeneratorJobDetail.getKey());
scheduler.pauseJob(postLookupJobDetail.getName(), postLookupJobDetail.getGroup()); scheduler.pauseJob(postLookupJobDetail.getKey());
scheduler.pauseJob(feedCleanerJobDetail.getName(), feedCleanerJobDetail.getGroup()); scheduler.pauseJob(feedCleanerJobDetail.getKey());
scheduler.pauseJob(postCleanerJobDetail.getName(), postCleanerJobDetail.getGroup()); scheduler.pauseJob(postCleanerJobDetail.getKey());
scheduler.pauseJob(feedNotifierJobDetail.getName(), feedNotifierJobDetail.getGroup()); scheduler.pauseJob(feedNotifierJobDetail.getKey());
this.systemNetwork = new TestNetwork(TenantService.DEFAULT_DOMAIN, true); this.systemNetwork = new TestNetwork(TenantService.DEFAULT_DOMAIN, true);
} }

View File

@@ -35,7 +35,6 @@ import org.alfresco.opencmis.OpenCMISClientContext;
import org.alfresco.opencmis.tck.tests.query.QueryForObjectCustom; import org.alfresco.opencmis.tck.tests.query.QueryForObjectCustom;
import org.alfresco.opencmis.tck.tests.query.QueryInFolderTestCustom; import org.alfresco.opencmis.tck.tests.query.QueryInFolderTestCustom;
import org.alfresco.opencmis.tck.tests.query.QueryLikeTestCustom; import org.alfresco.opencmis.tck.tests.query.QueryLikeTestCustom;
import org.alfresco.repo.domain.hibernate.dialect.AlfrescoOracle9Dialect;
import org.alfresco.rest.api.tests.RepoService.TestNetwork; import org.alfresco.rest.api.tests.RepoService.TestNetwork;
import org.alfresco.util.testing.category.LuceneTests; import org.alfresco.util.testing.category.LuceneTests;
import org.alfresco.util.testing.category.RedundantTests; import org.alfresco.util.testing.category.RedundantTests;
@@ -52,7 +51,6 @@ import org.apache.chemistry.opencmis.tck.tests.query.QuerySmokeTest;
import org.apache.chemistry.opencmis.tck.tests.versioning.VersioningTestGroup; import org.apache.chemistry.opencmis.tck.tests.versioning.VersioningTestGroup;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.hibernate.dialect.Dialect;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@@ -73,8 +71,9 @@ public class TestPublicApiAtomPub10TCK extends AbstractEnterpriseOpenCMIS10TCKTe
public void before() throws Exception public void before() throws Exception
{ {
// see REPO-1524 // see REPO-1524
Dialect dialect = (Dialect) applicationContext.getBean("dialect"); // the tests are always run on PostgreSQL only
assumeFalse(dialect instanceof AlfrescoOracle9Dialect); // Dialect dialect = (Dialect) applicationContext.getBean("dialect");
// assumeFalse(dialect instanceof Oracle9Dialect);
int port = getTestFixture().getJettyComponent().getPort(); int port = getTestFixture().getJettyComponent().getPort();
TestNetwork network = getTestFixture().getRandomNetwork(); TestNetwork network = getTestFixture().getRandomNetwork();

View File

@@ -32,13 +32,11 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.alfresco.opencmis.OpenCMISClientContext; import org.alfresco.opencmis.OpenCMISClientContext;
import org.alfresco.repo.domain.hibernate.dialect.AlfrescoOracle9Dialect;
import org.alfresco.rest.api.tests.RepoService.TestNetwork; import org.alfresco.rest.api.tests.RepoService.TestNetwork;
import org.apache.chemistry.opencmis.commons.enums.BindingType; import org.apache.chemistry.opencmis.commons.enums.BindingType;
import org.apache.chemistry.opencmis.tck.impl.TestParameters; import org.apache.chemistry.opencmis.tck.impl.TestParameters;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.hibernate.dialect.Dialect;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.Before; import org.junit.Before;
@@ -57,8 +55,9 @@ public class TestPublicApiAtomPub11TCK extends AbstractEnterpriseOpenCMIS11TCKTe
public void before() throws Exception public void before() throws Exception
{ {
// see REPO-1524 // see REPO-1524
Dialect dialect = (Dialect) applicationContext.getBean("dialect"); // the tests are always run on PostgreSQL only
assumeFalse(dialect instanceof AlfrescoOracle9Dialect); // Dialect dialect = (Dialect) applicationContext.getBean("dialect");
// assumeFalse(dialect instanceof Oracle9Dialect);
int port = getTestFixture().getJettyComponent().getPort(); int port = getTestFixture().getJettyComponent().getPort();
TestNetwork network = getTestFixture().getRandomNetwork(); TestNetwork network = getTestFixture().getRandomNetwork();

View File

@@ -32,13 +32,11 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.alfresco.opencmis.OpenCMISClientContext; import org.alfresco.opencmis.OpenCMISClientContext;
import org.alfresco.repo.domain.hibernate.dialect.AlfrescoOracle9Dialect;
import org.alfresco.rest.api.tests.RepoService.TestNetwork; import org.alfresco.rest.api.tests.RepoService.TestNetwork;
import org.apache.chemistry.opencmis.commons.enums.BindingType; import org.apache.chemistry.opencmis.commons.enums.BindingType;
import org.apache.chemistry.opencmis.tck.impl.TestParameters; import org.apache.chemistry.opencmis.tck.impl.TestParameters;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.hibernate.dialect.Dialect;
import org.junit.Before; import org.junit.Before;
/** /**
@@ -56,8 +54,9 @@ public class TestPublicApiBrowser11TCK extends AbstractEnterpriseOpenCMIS11TCKTe
public void before() throws Exception public void before() throws Exception
{ {
// see REPO-1524 // see REPO-1524
Dialect dialect = (Dialect) applicationContext.getBean("dialect"); // the tests are always run on PostgreSQL only
assumeFalse(dialect instanceof AlfrescoOracle9Dialect); // Dialect dialect = (Dialect) applicationContext.getBean("dialect");
// assumeFalse(dialect instanceof Oracle9Dialect);
int port = getTestFixture().getJettyComponent().getPort(); int port = getTestFixture().getJettyComponent().getPort();
TestNetwork network = getTestFixture().getRandomNetwork(); TestNetwork network = getTestFixture().getRandomNetwork();

View File

@@ -34,7 +34,6 @@ import java.util.Map;
import javax.transaction.Status; import javax.transaction.Status;
import javax.transaction.UserTransaction; import javax.transaction.UserTransaction;
import org.alfresco.repo.domain.hibernate.dialect.AlfrescoSQLServerDialect;
import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.workflow.WorkflowModel; import org.alfresco.repo.workflow.WorkflowModel;
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo; import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
@@ -55,7 +54,6 @@ import org.alfresco.service.cmr.workflow.WorkflowService;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
import org.alfresco.util.ApplicationContextHelper; import org.alfresco.util.ApplicationContextHelper;
import org.alfresco.util.testing.category.LuceneTests; import org.alfresco.util.testing.category.LuceneTests;
import org.hibernate.dialect.Dialect;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@@ -212,14 +210,15 @@ public class ProcessesImplTest extends TestCase implements RecognizedParamsExtra
@Test @Test
public void testGetProcessesMatchesIgnoreCaseNoResults() public void testGetProcessesMatchesIgnoreCaseNoResults()
{ {
Dialect dialect = (Dialect) applicationContext.getBean("dialect"); // the tests are always run on PostgreSQL only
if (dialect instanceof AlfrescoSQLServerDialect) // Dialect dialect = (Dialect) applicationContext.getBean("dialect");
{ // if (dialect instanceof AlfrescoSQLServerDialect)
// {
// REPO-1104: we do not run this test on MS SQL server because it will fail // REPO-1104: we do not run this test on MS SQL server because it will fail
// until the Activiti defect related to REPO-1104 will be fixed // until the Activiti defect related to REPO-1104 will be fixed
// this test could fail on other DBs where the LIKE operator behaves as case insensitive // this test could fail on other DBs where the LIKE operator behaves as case insensitive
return; // return;
} // }
CollectionWithPagingInfo<ProcessInfo> result = queryMatchesProcesses("test workflow api calls review and approve"); CollectionWithPagingInfo<ProcessInfo> result = queryMatchesProcesses("test workflow api calls review and approve");
assertNotNull(result); assertNotNull(result);

View File

@@ -1,7 +1,9 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'> <beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<beans>
<import resource="classpath:alfresco/application-context.xml"/> <import resource="classpath:alfresco/application-context.xml"/>
<import resource="classpath:alfresco/web-scripts-application-context.xml"/> <import resource="classpath:alfresco/web-scripts-application-context.xml"/>

View File

@@ -1,6 +1,9 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN 2.0//EN' 'http://www.springframework.org/dtd/spring-beans-2.0.dtd'> <beans xmlns="http://www.springframework.org/schema/beans"
<beans> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="org.alfresco.repository.quickshare.abstract" class="org.alfresco.repo.web.scripts.quickshare.AbstractQuickShareContent" abstract="true"> <bean id="org.alfresco.repository.quickshare.abstract" class="org.alfresco.repo.web.scripts.quickshare.AbstractQuickShareContent" abstract="true">
<property name="quickShareService" ref="QuickShareService" /> <property name="quickShareService" ref="QuickShareService" />
<property name="enabled" value="false" /> <property name="enabled" value="false" />

View File

@@ -1,13 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" <beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mongo="http://www.springframework.org/schema/data/mongo" xsi:schemaLocation="http://www.springframework.org/schema/beans
xsi:schemaLocation="http://www.springframework.org/schema/context http://www.springframework.org/schema/beans/spring-beans.xsd">
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/data/mongo
http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean id="httpClientProvider" class="org.alfresco.rest.api.tests.client.SharedHttpClientProvider"> <bean id="httpClientProvider" class="org.alfresco.rest.api.tests.client.SharedHttpClientProvider">
<constructor-arg name="alfrescoUrl" value="http://localhost:8081/alfresco/" /> <constructor-arg name="alfrescoUrl" value="http://localhost:8081/alfresco/" />
<constructor-arg name="maxNumberOfConnections" value="2" /> <constructor-arg name="maxNumberOfConnections" value="2" />

View File

@@ -2,8 +2,8 @@
<beans xmlns="http://www.springframework.org/schema/beans" <beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<bean id="apiLookup" class="org.alfresco.rest.framework.core.ResourceLookupDictionary"> <bean id="apiLookup" class="org.alfresco.rest.framework.core.ResourceLookupDictionary">
</bean> </bean>