diff --git a/source/java/org/alfresco/rest/api/People.java b/source/java/org/alfresco/rest/api/People.java index 058635ee61..b32fb0fcad 100644 --- a/source/java/org/alfresco/rest/api/People.java +++ b/source/java/org/alfresco/rest/api/People.java @@ -35,5 +35,5 @@ public interface People * @throws NoSuchPersonException if personId does not exist */ Person getPerson(final String personId); - Person updatePerson(String personId, Person person); + //Person updatePerson(String personId, Person person); } diff --git a/source/java/org/alfresco/rest/api/impl/PeopleImpl.java b/source/java/org/alfresco/rest/api/impl/PeopleImpl.java index dbaa7b25ff..1127fc4e71 100644 --- a/source/java/org/alfresco/rest/api/impl/PeopleImpl.java +++ b/source/java/org/alfresco/rest/api/impl/PeopleImpl.java @@ -285,7 +285,7 @@ public class PeopleImpl implements People return person; } - +/** private void addToMap(Map properties, QName name, Serializable value) { // if(name != null && value != null) @@ -355,4 +355,5 @@ public class PeopleImpl implements People return getPerson(personId); } + */ } diff --git a/source/java/org/alfresco/rest/workflow/api/impl/ProcessesImpl.java b/source/java/org/alfresco/rest/workflow/api/impl/ProcessesImpl.java index 1b1466cef1..ced247172b 100644 --- a/source/java/org/alfresco/rest/workflow/api/impl/ProcessesImpl.java +++ b/source/java/org/alfresco/rest/workflow/api/impl/ProcessesImpl.java @@ -62,7 +62,6 @@ import org.alfresco.repo.workflow.WorkflowPropertyHandlerRegistry; import org.alfresco.repo.workflow.WorkflowQNameConverter; import org.alfresco.repo.workflow.activiti.ActivitiConstants; import org.alfresco.repo.workflow.activiti.ActivitiNodeConverter; -import org.alfresco.repo.workflow.activiti.ActivitiTypeConverter; import org.alfresco.repo.workflow.activiti.ActivitiUtil; import org.alfresco.repo.workflow.activiti.properties.ActivitiPropertyConverter; import org.alfresco.rest.antlr.WhereClauseParser; @@ -141,7 +140,6 @@ public class ProcessesImpl extends WorkflowRestImpl implements Processes protected WorkflowPropertyHandlerRegistry handlerRegistry; protected WorkflowAuthorityManager authorityManager; protected ActivitiPropertyConverter propertyConverter; - protected ActivitiTypeConverter typeConverter; public void setAuthorityDAO(AuthorityDAO authorityDAO) { @@ -256,15 +254,6 @@ public class ProcessesImpl extends WorkflowRestImpl implements Processes } return propertyConverter; } - - protected ActivitiTypeConverter getTypeConverter() - { - if (typeConverter == null) - { - typeConverter = new ActivitiTypeConverter(activitiProcessEngine, getWorkflowFactory(), getPropertyConverter(), deployWorkflowsInTenant); - } - return typeConverter; - } @Override public CollectionWithPagingInfo getProcesses(Parameters parameters) diff --git a/source/java/org/alfresco/rest/workflow/api/impl/TasksImpl.java b/source/java/org/alfresco/rest/workflow/api/impl/TasksImpl.java index 80e0f4c281..f4dac38424 100644 --- a/source/java/org/alfresco/rest/workflow/api/impl/TasksImpl.java +++ b/source/java/org/alfresco/rest/workflow/api/impl/TasksImpl.java @@ -36,6 +36,8 @@ import org.activiti.engine.history.HistoricVariableInstance; import org.activiti.engine.task.DelegationState; import org.activiti.engine.task.IdentityLink; import org.activiti.engine.task.IdentityLinkType; +import org.activiti.engine.task.TaskInfo; +import org.activiti.engine.task.TaskInfoQuery; import org.activiti.engine.task.TaskQuery; import org.alfresco.model.ContentModel; import org.alfresco.repo.i18n.MessageService; @@ -285,100 +287,8 @@ public class TasksImpl extends WorkflowRestImpl implements Tasks } List variableProperties = propertyWalker.getVariableProperties(); - if (variableProperties != null) - { - for (QueryVariableHolder queryVariableHolder : variableProperties) - { - if (queryVariableHolder.getOperator() == WhereClauseParser.EQUALS) - { - if (queryVariableHolder.isGlobalScope()) - { - query.processVariableValueEquals(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue()); - } - else - { - query.taskVariableValueEquals(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue()); - } - } - else if (queryVariableHolder.getOperator() == WhereClauseParser.GREATERTHAN) - { - if (queryVariableHolder.isGlobalScope()) - { - query.processVariableValueGreaterThan(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue()); - } - else - { - query.taskVariableValueGreaterThan(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue()); - } - } - else if (queryVariableHolder.getOperator() == WhereClauseParser.GREATERTHANOREQUALS) - { - if (queryVariableHolder.isGlobalScope()) - { - query.processVariableValueGreaterThanOrEqual(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue()); - } - else - { - query.taskVariableValueGreaterThanOrEqual(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue()); - } - } - else if (queryVariableHolder.getOperator() == WhereClauseParser.LESSTHAN) - { - if (queryVariableHolder.isGlobalScope()) - { - query.processVariableValueLessThan(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue()); - } - else - { - query.taskVariableValueLessThan(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue()); - } - } - else if (queryVariableHolder.getOperator() == WhereClauseParser.LESSTHANOREQUALS) - { - if (queryVariableHolder.isGlobalScope()) - { - query.processVariableValueLessThanOrEqual(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue()); - } - else - { - query.taskVariableValueLessThanOrEqual(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue()); - } - } - else if (queryVariableHolder.getOperator() == WhereClauseParser.MATCHES) - { - if (queryVariableHolder.getPropertyValue() instanceof String == false) - { - throw new InvalidArgumentException("the matches operator can only be used with a String value for property " + queryVariableHolder.getPropertyName()); - } - - if (queryVariableHolder.isGlobalScope()) - { - query.processVariableValueLike(queryVariableHolder.getPropertyName(), (String) queryVariableHolder.getPropertyValue()); - } - else - { - query.taskVariableValueLike(queryVariableHolder.getPropertyName(), (String) queryVariableHolder.getPropertyValue()); - } - } - else if (queryVariableHolder.getOperator() == WhereClauseParser.NEGATION) - { - if (queryVariableHolder.isGlobalScope()) - { - query.processVariableValueNotEquals(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue()); - } - else - { - query.taskVariableValueNotEquals(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue()); - } - } - else - { - throw new InvalidArgumentException("variable " + queryVariableHolder.getPropertyName() + - " can only be used with an =, not comparison type"); - } - } - } - + setQueryUsingVariables(query, variableProperties); + // Add tenant-filtering if(tenantService.isEnabled()) { query.processVariableValueEquals(ActivitiConstants.VAR_TENANT_DOMAIN, TenantUtil.getCurrentDomain()); @@ -467,100 +377,8 @@ public class TasksImpl extends WorkflowRestImpl implements Tasks } List variableProperties = propertyWalker.getVariableProperties(); - if (variableProperties != null) - { - for (QueryVariableHolder queryVariableHolder : variableProperties) - { - if (queryVariableHolder.getOperator() == WhereClauseParser.EQUALS) - { - if (queryVariableHolder.isGlobalScope()) - { - query.processVariableValueEquals(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue()); - } - else - { - query.taskVariableValueEquals(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue()); - } - } - else if (queryVariableHolder.getOperator() == WhereClauseParser.GREATERTHAN) - { - if (queryVariableHolder.isGlobalScope()) - { - query.processVariableValueGreaterThan(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue()); - } - else - { - query.taskVariableValueGreaterThan(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue()); - } - } - else if (queryVariableHolder.getOperator() == WhereClauseParser.GREATERTHANOREQUALS) - { - if (queryVariableHolder.isGlobalScope()) - { - query.processVariableValueGreaterThanOrEqual(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue()); - } - else - { - query.taskVariableValueGreaterThanOrEqual(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue()); - } - } - else if (queryVariableHolder.getOperator() == WhereClauseParser.LESSTHAN) - { - if (queryVariableHolder.isGlobalScope()) - { - query.processVariableValueLessThan(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue()); - } - else - { - query.taskVariableValueLessThan(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue()); - } - } - else if (queryVariableHolder.getOperator() == WhereClauseParser.LESSTHANOREQUALS) - { - if (queryVariableHolder.isGlobalScope()) - { - query.processVariableValueLessThanOrEqual(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue()); - } - else - { - query.taskVariableValueLessThanOrEqual(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue()); - } - } - else if (queryVariableHolder.getOperator() == WhereClauseParser.MATCHES) - { - if (queryVariableHolder.getPropertyValue() instanceof String == false) - { - throw new InvalidArgumentException("the matches operator can only be used with a String value for property " + queryVariableHolder.getPropertyName()); - } - - if (queryVariableHolder.isGlobalScope()) - { - query.processVariableValueLike(queryVariableHolder.getPropertyName(), (String) queryVariableHolder.getPropertyValue()); - } - else - { - query.taskVariableValueLike(queryVariableHolder.getPropertyName(), (String) queryVariableHolder.getPropertyValue()); - } - } - else if (queryVariableHolder.getOperator() == WhereClauseParser.NEGATION) - { - if (queryVariableHolder.isGlobalScope()) - { - query.processVariableValueNotEquals(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue()); - } - else - { - query.taskVariableValueNotEquals(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue()); - } - } - else - { - throw new InvalidArgumentException("variable " + queryVariableHolder.getPropertyName() + - " can only be used with an =, not comparison type"); - } - } - } - + setQueryUsingVariables(query, variableProperties); + // Add tenant filtering if (tenantService.isEnabled()) { @@ -598,7 +416,104 @@ public class TasksImpl extends WorkflowRestImpl implements Tasks return CollectionWithPagingInfo.asPaged(paging, page, (page.size() + paging.getSkipCount()) < totalCount, totalCount); } - + + private void setQueryUsingVariables(TaskInfoQuery query, List variableProperties) + { + if (variableProperties != null) + { + for (QueryVariableHolder queryVariableHolder : variableProperties) + { + if (queryVariableHolder.getOperator() == WhereClauseParser.EQUALS) + { + if (queryVariableHolder.isGlobalScope()) + { + query.processVariableValueEquals(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue()); + } + else + { + query.taskVariableValueEquals(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue()); + } + } + else if (queryVariableHolder.getOperator() == WhereClauseParser.GREATERTHAN) + { + if (queryVariableHolder.isGlobalScope()) + { + query.processVariableValueGreaterThan(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue()); + } + else + { + query.taskVariableValueGreaterThan(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue()); + } + } + else if (queryVariableHolder.getOperator() == WhereClauseParser.GREATERTHANOREQUALS) + { + if (queryVariableHolder.isGlobalScope()) + { + query.processVariableValueGreaterThanOrEqual(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue()); + } + else + { + query.taskVariableValueGreaterThanOrEqual(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue()); + } + } + else if (queryVariableHolder.getOperator() == WhereClauseParser.LESSTHAN) + { + if (queryVariableHolder.isGlobalScope()) + { + query.processVariableValueLessThan(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue()); + } + else + { + query.taskVariableValueLessThan(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue()); + } + } + else if (queryVariableHolder.getOperator() == WhereClauseParser.LESSTHANOREQUALS) + { + if (queryVariableHolder.isGlobalScope()) + { + query.processVariableValueLessThanOrEqual(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue()); + } + else + { + query.taskVariableValueLessThanOrEqual(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue()); + } + } + else if (queryVariableHolder.getOperator() == WhereClauseParser.MATCHES) + { + if (queryVariableHolder.getPropertyValue() instanceof String == false) + { + throw new InvalidArgumentException("the matches operator can only be used with a String value for property " + queryVariableHolder.getPropertyName()); + } + + if (queryVariableHolder.isGlobalScope()) + { + query.processVariableValueLike(queryVariableHolder.getPropertyName(), (String) queryVariableHolder.getPropertyValue()); + } + else + { + query.taskVariableValueLike(queryVariableHolder.getPropertyName(), (String) queryVariableHolder.getPropertyValue()); + } + } + else if (queryVariableHolder.getOperator() == WhereClauseParser.NEGATION) + { + if (queryVariableHolder.isGlobalScope()) + { + query.processVariableValueNotEquals(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue()); + } + else + { + query.taskVariableValueNotEquals(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue()); + } + } + else + { + throw new InvalidArgumentException("variable " + queryVariableHolder.getPropertyName() + + " can only be used with an =, not comparison type"); + } + } + } + } + protected void addVariables(Task task, Boolean includeProcessVariables, Boolean includeTaskVariables, Map processVariables, Map taskVariables, Map definitionTypeMap) { diff --git a/source/test-java/org/alfresco/repo/web/scripts/invitation/InvitationWebScriptTest.java b/source/test-java/org/alfresco/repo/web/scripts/invitation/InvitationWebScriptTest.java index ab67e9f80f..898bae5197 100644 --- a/source/test-java/org/alfresco/repo/web/scripts/invitation/InvitationWebScriptTest.java +++ b/source/test-java/org/alfresco/repo/web/scripts/invitation/InvitationWebScriptTest.java @@ -133,7 +133,7 @@ public class InvitationWebScriptTest extends BaseWebScriptTest ppOne.put(ContentModel.PROP_EMAIL, email); ppOne.put(ContentModel.PROP_JOBTITLE, "jobTitle"); NodeRef person = personService.createPerson(ppOne); - String avatarUrl = makeAvatar(person); + String avatarUrl = makeAvatar(nodeService,person); // Create expected user properties HashMap properties = new HashMap(4); @@ -511,7 +511,7 @@ public class InvitationWebScriptTest extends BaseWebScriptTest } } - private String makeAvatar(final NodeRef person) + public static String makeAvatar(final NodeService nodeService, final NodeRef person) { nodeService.addAspect(person, ContentModel.ASPECT_PREFERENCES, null); ChildAssociationRef assoc = nodeService.createNode(person, ContentModel.ASSOC_PREFERENCE_IMAGE, avatarQName, diff --git a/source/test-java/org/alfresco/repo/web/scripts/thumbnail/ThumbnailServiceTest.java b/source/test-java/org/alfresco/repo/web/scripts/thumbnail/ThumbnailServiceTest.java index 722f50071e..abed0a2ff5 100644 --- a/source/test-java/org/alfresco/repo/web/scripts/thumbnail/ThumbnailServiceTest.java +++ b/source/test-java/org/alfresco/repo/web/scripts/thumbnail/ThumbnailServiceTest.java @@ -32,6 +32,7 @@ import org.alfresco.service.cmr.model.FileInfo; import org.alfresco.service.cmr.repository.ContentService; import org.alfresco.service.cmr.repository.ContentWriter; import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.TransformationOptions; import org.alfresco.service.cmr.security.MutableAuthenticationService; import org.alfresco.service.cmr.security.PersonService; import org.alfresco.test_category.OwnJVMTestsCategory; @@ -125,7 +126,7 @@ public class ThumbnailServiceTest extends BaseWebScriptTest public void testCreateThumbnail() throws Exception { // Check for pdfToSWF transformation before doing test - if (this.contentService.getTransformer(MimetypeMap.MIMETYPE_PDF, MimetypeMap.MIMETYPE_FLASH) != null) + if (this.contentService.getTransformer(MimetypeMap.MIMETYPE_PDF, MimetypeMap.MIMETYPE_FLASH, new TransformationOptions()) != null) { String url = "/api/node/" + pdfNode.getStoreRef().getProtocol() + "/" + pdfNode.getStoreRef().getIdentifier() + "/" + pdfNode.getId() + "/content/thumbnails"; diff --git a/source/test-java/org/alfresco/rest/api/tests/EnterpriseTestFixture.java b/source/test-java/org/alfresco/rest/api/tests/EnterpriseTestFixture.java index e017fececc..349d8cd97a 100644 --- a/source/test-java/org/alfresco/rest/api/tests/EnterpriseTestFixture.java +++ b/source/test-java/org/alfresco/rest/api/tests/EnterpriseTestFixture.java @@ -6,6 +6,7 @@ import org.alfresco.service.cmr.site.SiteVisibility; public abstract class EnterpriseTestFixture extends AbstractTestFixture { + public static final String WITH_AVATAR = "withAvatar"; //If you set PersonInfo instantmsg to WITH_AVATAR, an avatar gets created. public EnterpriseTestFixture(String[] configLocations, String[] classLocations, int port, String contextPath, String servletName, int numMembersPerSite, boolean cleanup) { @@ -37,10 +38,10 @@ public abstract class EnterpriseTestFixture extends AbstractTestFixture addPerson(new PersonInfo("David", "Smith", "david.smith", "password", null, "skype", "location", "telephone", "mob", "instant", "google")); addPerson(new PersonInfo("Bob", "Jones", "bob.jones", "password", null, "skype", "location", "telephone", "mob", "instant", "google")); - addPerson(new PersonInfo("Bill", "Grainger", "bill.grainger", "password", null, "skype", "location", "telephone", "mob", "instant", "google")); + addPerson(new PersonInfo("Bill", "Grainger", "bill.grainger", "password", null, "skype", "location", "telephone", "mob", WITH_AVATAR, "google")); addPerson(new PersonInfo("Jill", "Fry", "jill.fry", "password", null, "skype", "location", "telephone", "mob", "instant", "google")); - addPerson(new PersonInfo("Elvis", "Presley", "elvis.presley", "password", null, "skype", "location", "telephone", "mob", "instant", "google")); - addPerson(new PersonInfo("John", "Lennon", "john.lennon", "password", null, "skype", "location", "telephone", "mob", "instant", "google")); + addPerson(new PersonInfo("Elvis", "Presley", "elvis.presley", "password", null, "skype", "location", "telephone", "mob", WITH_AVATAR, "google")); + addPerson(new PersonInfo("John", "Lennon", "john.lennon", "password", null, "skype", "location", "telephone", "mob", WITH_AVATAR, "google")); addPerson(new PersonInfo("George", "Harrison", "george.harrison", "password", null, "skype", "location", "telephone", "mob", "instant", "google")); addPerson(new PersonInfo("David", "Bowie", "david.bowie", "password", null, "skype", "location", "telephone", "mob", "instant", "google")); addPerson(new PersonInfo("Ford", "Prefect", "ford.prefect", "password", null, "skype", "location", "telephone", "mob", "instant", "google")); diff --git a/source/test-java/org/alfresco/rest/api/tests/RepoService.java b/source/test-java/org/alfresco/rest/api/tests/RepoService.java index 3ad4033d89..9307ead822 100644 --- a/source/test-java/org/alfresco/rest/api/tests/RepoService.java +++ b/source/test-java/org/alfresco/rest/api/tests/RepoService.java @@ -47,6 +47,7 @@ import org.alfresco.query.PagingResults; import org.alfresco.repo.activities.feed.FeedGenerator; import org.alfresco.repo.activities.feed.cleanup.FeedCleaner; import org.alfresco.repo.activities.post.lookup.PostLookup; +import org.alfresco.repo.content.MimetypeMap; import org.alfresco.repo.content.cleanup.ContentStoreCleaner; import org.alfresco.repo.domain.activities.ActivityFeedEntity; import org.alfresco.repo.domain.activities.ActivityPostDAO; @@ -56,6 +57,7 @@ import org.alfresco.repo.management.subsystems.ChildApplicationContextFactory; import org.alfresco.repo.model.filefolder.HiddenAspect; import org.alfresco.repo.model.filefolder.HiddenAspect.Visibility; import org.alfresco.repo.node.index.NodeIndexer; +import org.alfresco.repo.security.authentication.AuthenticationException; import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; import org.alfresco.repo.site.SiteDoesNotExistException; @@ -68,6 +70,7 @@ import org.alfresco.repo.tenant.TenantUtil.TenantRunAsWork; import org.alfresco.repo.transaction.RetryingTransactionHelper; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; import org.alfresco.repo.version.VersionModel; +import org.alfresco.repo.web.scripts.invitation.InvitationWebScriptTest; import org.alfresco.rest.api.Activities; import org.alfresco.rest.api.impl.node.ratings.RatingScheme; import org.alfresco.rest.api.tests.client.data.Activity; @@ -364,7 +367,30 @@ public class RepoService { lockService.unlock(nodeRef); } - + + public NodeRef addUserDescription(final String personId, final TestNetwork network, final String personDescription) + { + return AuthenticationUtil.runAsSystem(new RunAsWork() + { + //@Override + public NodeRef doWork() throws Exception + { + NodeRef userRef = personService.getPersonOrNull(personId); + if (userRef == null) + { + throw new AuthenticationException("User name does not exist: " + personId); + } + + ContentWriter writer = contentService.getWriter(userRef, ContentModel.PROP_PERSONDESC, true); + writer.setMimetype(MimetypeMap.MIMETYPE_HTML); + writer.putContent(personDescription); + + log("Updated person description " + personId + (network != null ? " in network " + network : "")); + return userRef; + } + }); + } + public TestPerson createUser(final PersonInfo personInfo, final String username, final TestNetwork network) { return AuthenticationUtil.runAsSystem(new RunAsWork() @@ -390,11 +416,17 @@ public class RepoService }); } - personService.createPerson(props); + NodeRef createdPerson = personService.createPerson(props); // create authentication to represent user authenticationService.createAuthentication(username, personInfo.getPassword().toCharArray()); + if (EnterpriseTestFixture.WITH_AVATAR.equals(personInfo.getInstantmsg())) + { + InvitationWebScriptTest.makeAvatar(nodeService,createdPerson); + log("Made avatar for " + testPerson.getId() + (network != null ? " in network " + network : "")); + } + log("Created person " + testPerson.getId() + (network != null ? " in network " + network : "")); publicApiContext.addUser(testPerson.getId()); @@ -1301,6 +1333,19 @@ public class RepoService return person; } + public NodeRef addUserDescription(final String personId, final String personDescription) + { + NodeRef personRef = TenantUtil.runAsTenant(new TenantRunAsWork() + { + public NodeRef doWork() throws Exception + { + return RepoService.this.addUserDescription(personId, TestNetwork.this, personDescription); + } + }, getId()); + + return personRef; + } + public TestPerson createUser(final PersonInfo personInfo) { final String username = publicApiContext.createUserName(personInfo.getUsername(), getId()); @@ -1746,7 +1791,7 @@ public class RepoService public TestPerson(String firstName, String lastName, String username, String password, Company company, TestNetwork defaultAccount, String skype, String location, String tel, String mob, String instantmsg, String google) { - super(username, username, true, firstName, lastName, company, skype, location, tel, mob, instantmsg, google); + super(username, username, true, firstName, lastName, company, skype, location, tel, mob, instantmsg, google, null); this.password = password; this.enabled = true; this.defaultAccount = defaultAccount; diff --git a/source/test-java/org/alfresco/rest/api/tests/TestPeople.java b/source/test-java/org/alfresco/rest/api/tests/TestPeople.java index e63f0425b4..3d13609a6d 100644 --- a/source/test-java/org/alfresco/rest/api/tests/TestPeople.java +++ b/source/test-java/org/alfresco/rest/api/tests/TestPeople.java @@ -1,10 +1,12 @@ package org.alfresco.rest.api.tests; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; import java.util.Iterator; +import org.alfresco.model.ContentModel; import org.alfresco.repo.tenant.TenantUtil; import org.alfresco.repo.tenant.TenantUtil.TenantRunAsWork; import org.alfresco.repo.transaction.RetryingTransactionHelper; @@ -73,5 +75,15 @@ public class TestPeople extends EnterpriseTestApi { assertEquals(HttpStatus.SC_UNAUTHORIZED, e.getHttpResponse().getStatusCode()); } + + RepoService.TestPerson testP = account1.createUser(); + String personId = testP.getId(); + String desc = "Nice person"; + account1.addUserDescription(personId, desc); + publicApiClient.setRequestContext(new RequestContext(account1.getId(), personId)); + Person resp = publicApiClient.people().getPerson(personId); + assertEquals(resp.getId(), personId); + assertEquals(resp.getDescription(), desc); } + } diff --git a/source/test-java/org/alfresco/rest/api/tests/client/data/Person.java b/source/test-java/org/alfresco/rest/api/tests/client/data/Person.java index 13ab0f6d7a..66066f2ead 100644 --- a/source/test-java/org/alfresco/rest/api/tests/client/data/Person.java +++ b/source/test-java/org/alfresco/rest/api/tests/client/data/Person.java @@ -36,12 +36,13 @@ public class Person implements Serializable, Comparable, ExpectedCompari private String mob; private String instantmsg; private String google; + private String description; private static Collator collator = Collator.getInstance(); public Person(String id, String username, Boolean enabled, String firstName, String lastName, Company company, String skype, String location, String tel, - String mob, String instantmsg, String google) + String mob, String instantmsg, String google, String description) { super(); if(id == null) @@ -60,6 +61,7 @@ public class Person implements Serializable, Comparable, ExpectedCompari this.mob = mob; this.instantmsg = instantmsg; this.google = google; + this.description = description; } public String getId() @@ -165,7 +167,12 @@ public class Person implements Serializable, Comparable, ExpectedCompari { this.lastName = lastName; } - + + public String getDescription() + { + return description; + } + @Override public String toString() { @@ -181,6 +188,7 @@ public class Person implements Serializable, Comparable, ExpectedCompari + (mob != null ? "mob=" + mob + ", " : "") + (instantmsg != null ? "instantmsg=" + instantmsg + ", " : "") + (google != null ? "google=" + google + ", " : "") + + (description != null ? "description=" + description + ", " : "") + "]"; } @@ -219,7 +227,8 @@ public class Person implements Serializable, Comparable, ExpectedCompari String userId = (String)jsonObject.get("id"); String firstName = (String)jsonObject.get("firstName"); String lastName = (String)jsonObject.get("lastName"); - Boolean emailNotificationsEnabled = (Boolean)jsonObject.get("emailNotificationsEnabled"); + String description = (String)jsonObject.get("description"); + JSONObject companyJSON = (JSONObject)jsonObject.get("company"); Company company = null; if(companyJSON != null) @@ -234,13 +243,13 @@ public class Person implements Serializable, Comparable, ExpectedCompari String companyEmail = (String)companyJSON.get("email"); company = new Company(organization, address1, address2, address3, postcode, companyTelephone, fax, companyEmail); } - Person person = new Person(userId, email, enabled, firstName, lastName, company, skypeId, location, telephone, mobile, instantMessageId, googleId); + Person person = new Person(userId, email, enabled, firstName, lastName, company, skypeId, location, telephone, mobile, instantMessageId, googleId, description); return person; } public Person restriced() { - Person p = new Person(getId(), getEmail(), getEnabled(), getFirstName(), getLastName(), null, null, null, null, null, null, null); + Person p = new Person(getId(), getEmail(), getEnabled(), getFirstName(), getLastName(), null, null, null, null, null, null, null, null); return p; } diff --git a/source/test-java/org/alfresco/rest/workflow/api/tests/ProcessDefinitionWorkflowApiTest.java b/source/test-java/org/alfresco/rest/workflow/api/tests/ProcessDefinitionWorkflowApiTest.java index 314340ea3e..0d45981127 100644 --- a/source/test-java/org/alfresco/rest/workflow/api/tests/ProcessDefinitionWorkflowApiTest.java +++ b/source/test-java/org/alfresco/rest/workflow/api/tests/ProcessDefinitionWorkflowApiTest.java @@ -388,9 +388,9 @@ public class ProcessDefinitionWorkflowApiTest extends EnterpriseWorkflowTestApi .createProcessDefinitionQuery() .processDefinitionKey(adhocKey) .singleResult(); - + assertNotNull(activitiDefinition); - + // Get a single process definitions ProcessDefinitionsClient processDefinitionsClient = publicApiClient.processDefinitionsClient(); ProcessDefinition adhocDefinition = processDefinitionsClient.findProcessDefinitionById(activitiDefinition.getId()); @@ -415,7 +415,35 @@ public class ProcessDefinitionWorkflowApiTest extends EnterpriseWorkflowTestApi assertEquals(activitiDefinition.getId(), adhocDefinition.getId()); assertEquals("activitiAdhoc", adhocDefinition.getKey()); } - + + + @Test + public void testGetProcessDefinitionsImage() throws Exception + { + RequestContext requestContext = initApiClientWithTestUser(); + ProcessDefinitionsClient processDefinitionsClient = publicApiClient.processDefinitionsClient(); + + String adhocKey = createProcessDefinitionKey("activitiAdhoc", requestContext); + org.activiti.engine.repository.ProcessDefinition activitiDefinition = activitiProcessEngine.getRepositoryService() + .createProcessDefinitionQuery() + .processDefinitionKey(adhocKey) + .singleResult(); + + assertNotNull(activitiDefinition); + try + { + HttpResponse response = processDefinitionsClient.findImageById(activitiDefinition.getId()); + fail("Exception expected"); + } + catch(PublicApiException expected) + { + assertEquals(HttpStatus.INTERNAL_SERVER_ERROR.value(), expected.getHttpResponse().getStatusCode()); + assertTrue(expected.getMessage().contains("No image available")); + } + + + } + @Test public void testGetProcessDefinitionByIdUnexisting() throws Exception { diff --git a/source/test-java/org/alfresco/rest/workflow/api/tests/ProcessWorkflowApiTest.java b/source/test-java/org/alfresco/rest/workflow/api/tests/ProcessWorkflowApiTest.java index ff398a221e..e2b77cd6d8 100644 --- a/source/test-java/org/alfresco/rest/workflow/api/tests/ProcessWorkflowApiTest.java +++ b/source/test-java/org/alfresco/rest/workflow/api/tests/ProcessWorkflowApiTest.java @@ -657,7 +657,7 @@ public class ProcessWorkflowApiTest extends EnterpriseWorkflowTestApi assertNotNull(processList); assertEquals(3, processList.getList().size()); assertNull(processList.getList().get(0).getProcessVariables()); - + paramMap = new HashMap(); paramMap.put("where", "(processDefinitionKey = 'activitiAdhoc2')"); processList = processesClient.getProcesses(paramMap); @@ -737,7 +737,31 @@ public class ProcessWorkflowApiTest extends EnterpriseWorkflowTestApi processList = processesClient.getProcesses(paramMap); assertNotNull(processList); assertEquals(3, processList.getList().size()); - + + paramMap = new HashMap(); + paramMap.put("where", "(variables/bpm_priority > 'd:int 1')"); + processList = processesClient.getProcesses(paramMap); + assertNotNull(processList); + assertEquals(0, processList.getList().size()); + + paramMap = new HashMap(); + paramMap.put("where", "(variables/bpm_priority >= 'd:int 1')"); + processList = processesClient.getProcesses(paramMap); + assertNotNull(processList); + assertEquals(3, processList.getList().size()); + + paramMap = new HashMap(); + paramMap.put("where", "(variables/bpm_priority < 'd:int 5')"); + processList = processesClient.getProcesses(paramMap); + assertNotNull(processList); + assertEquals(3, processList.getList().size()); + + paramMap = new HashMap(); + paramMap.put("where", "(variables/bpm_priority <= 'd:int 4')"); + processList = processesClient.getProcesses(paramMap); + assertNotNull(processList); + assertEquals(3, processList.getList().size()); + paramMap = new HashMap(); paramMap.put("where", "(variables/bpm_priority = 'd_int 5')"); processList = processesClient.getProcesses(paramMap); @@ -994,7 +1018,31 @@ public class ProcessWorkflowApiTest extends EnterpriseWorkflowTestApi assertEquals(process2.getId(), processList.getList().get(0).getId()); assertEquals(process1.getId(), processList.getList().get(1).getId()); assertEquals(process3.getId(), processList.getList().get(2).getId()); - + + paramMap.put("orderBy", "startedAt ASC"); + processList = processesClient.getProcesses(paramMap); + assertNotNull(processList); + + paramMap.put("orderBy", "endedAt ASC"); + processList = processesClient.getProcesses(paramMap); + assertNotNull(processList); + + paramMap.put("orderBy", "durationInMillis ASC"); + processList = processesClient.getProcesses(paramMap); + assertNotNull(processList); + + // sort on more than 1. + paramMap.put("orderBy", "startedAt, endedAt"); + try + { + processList = processesClient.getProcesses(paramMap); + fail(); + } + catch (PublicApiException e) + { + assertEquals(HttpStatus.BAD_REQUEST.value(), e.getHttpResponse().getStatusCode()); + } + // sort on non existing key paramMap.put("orderBy", "businessKey2 ASC"); try diff --git a/source/test-java/org/alfresco/rest/workflow/api/tests/TaskWorkflowApiTest.java b/source/test-java/org/alfresco/rest/workflow/api/tests/TaskWorkflowApiTest.java index 8a0c7f0878..4a2b96af05 100644 --- a/source/test-java/org/alfresco/rest/workflow/api/tests/TaskWorkflowApiTest.java +++ b/source/test-java/org/alfresco/rest/workflow/api/tests/TaskWorkflowApiTest.java @@ -1541,6 +1541,7 @@ public class TaskWorkflowApiTest extends EnterpriseWorkflowTestApi // Test status filtering - completed params.clear(); params.put("where", "(status = 'completed' AND processId = '" + processInstance.getId() + "')"); + params.put("orderBy", "dueAt DESC"); assertTasksPresentInTaskQuery(params, tasksClient, false, completedTask.getId()); // Test status filtering - any @@ -1575,6 +1576,7 @@ public class TaskWorkflowApiTest extends EnterpriseWorkflowTestApi assertTasksPresentInTaskQuery(params, tasksClient, activeTask.getId()); params.put("where", "(status = 'completed' AND assignee = '" + anotherUserId + "')"); + params.put("orderBy", "endedAt"); assertTasksPresentInTaskQuery(params, tasksClient, completedTask.getId()); params.put("where", "(status = 'any' AND assignee = '" + anotherUserId + "')"); @@ -1870,6 +1872,18 @@ public class TaskWorkflowApiTest extends EnterpriseWorkflowTestApi { assertEquals(HttpStatus.BAD_REQUEST.value(), expected.getHttpResponse().getStatusCode()); } + + params.clear(); + params.put("where", "(status = 'completed' AND processDefinitionName = 'Adhoc Activiti Process')"); + JSONObject response = publicApiClient.processesClient().getTasks(processInstance.getId(), params); + assertNotNull(response); + JSONObject paginationJSON = (JSONObject) response.get("pagination"); + assertEquals(1l, paginationJSON.get("count")); + + params.clear(); + params.put("where", "(status = 'any' AND variables/numberVar < 'd:int 5')"); + assertEquals(0, getResultSizeForTaskQuery(params, tasksClient)); + } finally { @@ -2087,6 +2101,12 @@ public class TaskWorkflowApiTest extends EnterpriseWorkflowTestApi assertEquals(taskList.get(0).getId(), taskJSON.get("id")); taskJSON = (JSONObject) ((JSONObject) tasksListJSON.get(5)).get("entry"); assertEquals(taskList.get(numberOfTasks - 1).getId(), taskJSON.get("id")); + + params.put("orderBy", "dueAt DESC"); + tasksResponseJSON = tasksClient.findTasks(params); + tasksListJSON = (JSONArray) tasksResponseJSON.get("entries"); + assertEquals(6, tasksListJSON.size()); + } finally { diff --git a/source/test-java/org/alfresco/rest/workflow/api/tests/WorkflowApiClient.java b/source/test-java/org/alfresco/rest/workflow/api/tests/WorkflowApiClient.java index 6d6503082d..2ee9772472 100644 --- a/source/test-java/org/alfresco/rest/workflow/api/tests/WorkflowApiClient.java +++ b/source/test-java/org/alfresco/rest/workflow/api/tests/WorkflowApiClient.java @@ -127,7 +127,12 @@ public class WorkflowApiClient extends PublicApiClient JSONObject entry = (JSONObject) response.getJsonResponse().get("entry"); return ProcessDefinitionParser.INSTANCE.parseEntry(entry); } - + + public HttpResponse findImageById(String processDefinitionId) throws PublicApiException + { + return getSingle("process-definitions", processDefinitionId, "image", null, "Failed to get process definition"); + } + public JSONObject findStartFormModel(String processDefinitionId) throws PublicApiException { HttpResponse response = getAll("process-definitions", processDefinitionId, "start-form-model", null, null,