mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Merge changes on master 7.0.0-A7 projects since 7.0.0-A3 to release/master (#30)
Does not include chemistry-opencmis 1.1.0 (downgraded to 1.0.0) or jackson-databind 2.11.2 (downgraded to 2.10.1) due to test failures. Original upgrades by dependabot.
* Fix latest T-Engine versions and remove redundantly versions in pom.xml files
* Changes from acs-packaging
* From alfresco-core (included json change after 7.0.0-A7)
Bump commons-io from 2.7 to 2.8.0 (#160)
(cherry picked from commit c5a8f5ffb3988bd87719aa43b7089851607b7308)
MNT-21879 : [Security] Multiple json-java vulnerabilities
- updated org.json.json version
(cherry picked from commit edaffa350b29157bdcd1de3737fa491b88093378)
[revert] MNT-21879 : [Security] Multiple json-java vulnerabilities
- updated org.json.json version
(cherry picked from commit 48e2cffb287adb5c5a1d5092ae7fde895c8d0836)
* from alfresco-data-model
SEARCH-2362: Consider changing properties from mandatory/enforced/pro… (#313)
* SEARCH-2362: Consider changing properties from mandatory/enforced/protected to NON mandatory/enforced/protected as incremental changes
* SEARCH-2362 Update tests to check whole set of returned diffs at once.
Co-authored-by: Tom Page <thomas.page@alfresco.com>
(cherry picked from commit 576601564251038311627f230f286b96ea950383)
Bump dependency.cxf.version from 3.3.7 to 3.4.0 (#309)
(cherry picked from commit dc689a911d83b608d49572cada5c2d16441c1eea)
Bump chemistry-opencmis-commons-impl from 1.0.0 to 1.1.0 (#305)
(cherry picked from commit 98fa7b66851aeada1bb6ea05bd6e747e3c55b342)
Bump commons-compress from 1.19 to 1.20 (#303)
(cherry picked from commit f6a950d4a36f05083536638cc5ff7866436f191d)
Bump pdfbox from 2.0.17 to 2.0.20 (#304)
(cherry picked from commit 435b786817ee18c28b84d093c6fbfbc330434e4c)
* From alfresco-remote-api
MNT-21702 : Kerberos SSO fallback mechanism for WebDAV (#765)
Reinstated 'part' of the reverted code change originally made in MNT-16931 to handle fallback correctly for WebDAV in a kerberos environment.
(cherry picked from commit 4091cb9d4b1cd643f9678a4c5c9654963a72c266)
[MNT-21758] Cannot map an AOS / WebDAV drive with Kerberos SSO enabled (#784)
- Add multi catch for Illegal Argument and Not Found when findWebScript is called.
(cherry picked from commit 59517076d2dfc0477870007a7d136cdf907e322f)
SEARCH-2363: Escape special characters when serializing ChildAssociationRefs and AssociationRefs objects (#788)
(cherry picked from commit f941a6e283517c0949f57fefdb1e7e8d7cfb46c4)
ACS-580: Direct access urls - revert initial api version (#792)
(cherry picked from commit 7f4959fdfaeaf1b7debd78df5dcacd4a5b9e809a)
* From alfresco-repository
SEARCH-2289: Restore the support for SOLR 4 in ACS 6.2+ deployments. (#1063)
This configuration is recommended for upgrading scenarios, where you need to upgrade ACS and to re-index the repository with SOLR 6 while using the system with SOLR 4.
(cherry picked from commit e8bba3ca13880be782c2e4c1d82223e70c370f28)
[MNT-21847] - Aync permissions fail when new nodes are created (#1188)
Fix:
*Changed method setFixedAcls on class ADMAccessControlListDAO to continue to propagate through children to apply the correct acl not only when the current child acl matches the shared acl to replace but also when the current child acl matches the new shared acl
Unit Test:
*Refactored the unit test FixedAclUpdaterTest to be able to add in a new test without repeating code: separating the operations that set the permissions from the one that triggers the job into separate methods
*As it was if one test failed, leaving aspects to be processed, the test would run indefinitely (it was programmed to keep running the job while there where nodes with the aspect). Added a verification to stop triggering the job if the number of nodes with the pendingFixAcl did not change between executions.
*Also, if one test failed, it would leave nodes with pendingFixAcl aspect in the database, and the other tests that ran after would also fail, not completing the goal of processing all nodes with the aspect. If a test fails, the folder structure it ran is now deleted so no nodes with the aspect from that structure are processed by the other tests.
*Added a test to find the first folder in a tree where permissions where set async that has the pendingFixAcl aspect and that creates a new node in it to verify the issue
(cherry picked from commit 443e5e226430a2760492fb82214ad520e7e1cb75)
Bump dependency.pdfbox.version from 2.0.20 to 2.0.21 (#1170)
(cherry picked from commit b93d73dec5f0e94d83f62721842b92e617dfba79)
Bump rhino from 1.7.12 to 1.7.13 (#1185)
(cherry picked from commit a5b5f072c64511999d3d27087a1a82f949371ac8)
Bump spring-security-core from 5.2.1.RELEASE to 5.3.4.RELEASE (#1167)
(cherry picked from commit 54f68d823333254cef74343288e99107494b1e28)
REPO-5339 Improve concurrency of SimplePermissionReference (#1189)
* REPO-5339 Improve concurrency of SimplePermissionReference
* REPO-5339 Change locks to synchronised block
* [REPO-5339] Improve concurrency of SimplePermissionReference
- Move to ConcurrentHashMap
- Capacity set to hold Repo + RM + slight overage for custom permissions
- Getting new SimplePermissionReference will not block while getting existing value.
- If a new value needs to be added to the Map, it will block when adding
- If blocked it will wait, in order, until it can attempt to add
- If it was blocked before it will check first if another operation added before adding as an atomic action
* [REPO-5339] Improve concurrency of SimplePermissionReference
- Simplify getPermissionReference by removing Future
* [REPO-5339] Thread Lock detected for AclReadersGet invocations
- Add load capacity and concurrency level
Co-authored-by: Jared Ottley <jared.ottley@alfresco.com>
(cherry picked from commit 39ded1cc0a364d24f737584eed22bef0918a5359)
[MNT-21766]: Significant degradation of performance as file and site count increase (#1217)
* [MNT-21766]: Significant degradation of performance as file and site
count increase
- Added the following indexes on alf_transaction:
idx_alf_txn_ctms_sc, cols (commit_time_ms)
idx_alf_txn_id_ctms, cols (id, commit_time_ms)
- Added the following indexes on alf_node:
idx_alf_node_ver, cols (version)
idx_alf_node_txn, cols (transaction_id)
- Created patch patch.db-V6.3-add-indexes-node-transaction
- Updated version.schema to 14002
- Added system property system.new-node-transaction-indexes.ignored, set
as true by default to not apply the patch automatically
- Created the MySQL update dbscripts to add the new indexes - and also
drop and recreate the pre-existing index idx_alf_txn_ctms on alf_transaction that was
inconsistent with the other DBMS: was indexing only commit_time_ms when
on all other DBMS index idx_alf_txn_ctms was on (commit_time_ms, id)
- Created the Postgres update dbscripts to add the new indexes
(cherry picked from commit d70746f63a6e6a2154d2e37c577955a17c42256e)
SEARCH-2450 Don't expose properties from solr endpoint if the model says not to index them. (#1228)
(cherry picked from commit 2fea6c9484def402e2bfd7c3717071ff8df69c01)
Fix/MNT-21800 CMIS Web Service Check Out returns error (#1232)
* MNT-21800 : CMIS Web Service Check Out returns error
Integrate path into codebase.
(cherry picked from commit 51a7793668ba1c969c5de37603190244e3839cd0)
* Revert dependency.opencmis.version change 1.1.0 back to 1.0.0 done by dependabot on 08/09/2020 as the upgraded failed in alfresco-remote-api tests which are now part of the same repo.
* Trial build with previous rino version
* Revert cxf upgrade to 3.4.0 from 3.7.7 as dependabot failed to apply it in acs-packaging
Revert org-json to 20160212 from 20090211 as dependabot failed to apply it in alfresco-repository
* Revert "Trial build with previous rino version"
This reverts commit 40f8120d5d
.
* Remove READMEs that have been moved to the top level.
* Fix location of keystore
Only copy win64 and linux pdf-renderer to dist zip
Sort out what get included in dist jar and zip
* jackson databind revert
This commit is contained in:
@@ -80,14 +80,14 @@ jobs:
|
||||
before_script:
|
||||
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:11.7 postgres -c 'max_connections=300'
|
||||
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.15.8
|
||||
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.3.4
|
||||
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.3.5
|
||||
script: travis_wait 20 mvn -B test -pl repository -Dtest=AppContext03TestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco -Dalfresco-pdf-renderer.url=http://localhost:8090/ -Djodconverter.url=http://localhost:8090/ -Dimg.url=http://localhost:8090/ -Dtika.url=http://localhost:8090/ -Dtransform.misc.url=http://localhost:8090/
|
||||
|
||||
- name: "Repository - AppContext04TestSuite"
|
||||
before_script:
|
||||
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:11.7 postgres -c 'max_connections=300'
|
||||
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.15.8
|
||||
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.3.4
|
||||
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.3.5
|
||||
script: travis_wait 20 mvn -B test -pl repository -Dtest=AppContext04TestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
||||
|
||||
- name: "Repository - AppContext05TestSuite"
|
||||
@@ -104,7 +104,7 @@ jobs:
|
||||
before_script:
|
||||
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:11.7 postgres -c 'max_connections=300'
|
||||
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.15.8
|
||||
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.3.4
|
||||
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.3.5
|
||||
script: travis_wait 20 mvn -B test -pl repository -Dtest=AppContext06TestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco -Dalfresco-pdf-renderer.url=http://localhost:8090/ -Djodconverter.url=http://localhost:8090/ -Dimg.url=http://localhost:8090/ -Dtika.url=http://localhost:8090/ -Dtransform.misc.url=http://localhost:8090/
|
||||
|
||||
- name: "Repository - AppContextExtraTestSuite"
|
||||
@@ -117,7 +117,7 @@ jobs:
|
||||
before_script:
|
||||
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:11.7 postgres -c 'max_connections=300'
|
||||
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.15.8
|
||||
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.3.4
|
||||
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.3.5
|
||||
script: travis_wait 20 mvn -B test -pl repository -Dtest=MiscContextTestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco -Dalfresco-pdf-renderer.url=http://localhost:8090/ -Djodconverter.url=http://localhost:8090/ -Dimg.url=http://localhost:8090/ -Dtika.url=http://localhost:8090/ -Dtransform.misc.url=http://localhost:8090/
|
||||
|
||||
- name: "Repository - MySQL tests"
|
||||
|
@@ -1,42 +0,0 @@
|
||||
### Alfresco Core
|
||||
[](https://travis-ci.com/Alfresco/alfresco-core)
|
||||
|
||||
Alfresco Core is a library packaged as a jar file which is part of [Alfresco Content Services Repository](https://community.alfresco.com/docs/DOC-6385-project-overview-repository).
|
||||
The library contains the following:
|
||||
* Various helpers and utils
|
||||
* Canned queries interface and supporting classes
|
||||
* Generic encryption supporting classes
|
||||
|
||||
Version 7 of the library uses Spring 5, Quartz 2.3 and does not have Hibernate dependency.
|
||||
|
||||
### Building and testing
|
||||
The project can be built and tested by running Maven command:
|
||||
~~~
|
||||
mvn clean install
|
||||
~~~
|
||||
|
||||
### Artifacts
|
||||
The artifacts can be obtained by:
|
||||
* downloading from [Alfresco repository](https://artifacts.alfresco.com/nexus/content/groups/public)
|
||||
* getting as Maven dependency by adding the dependency to your pom file:
|
||||
~~~
|
||||
<dependency>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-core</artifactId>
|
||||
<version>version</version>
|
||||
</dependency>
|
||||
~~~
|
||||
and Alfresco repository:
|
||||
~~~
|
||||
<repository>
|
||||
<id>alfresco-maven-repo</id>
|
||||
<url>https://artifacts.alfresco.com/nexus/content/groups/public</url>
|
||||
</repository>
|
||||
~~~
|
||||
The SNAPSHOT version of the artifact is **never** published.
|
||||
|
||||
### Old version history
|
||||
The history for older versions can be found in [Alfresco SVN](https://svn.alfresco.com/repos/alfresco-open-mirror/services/alfresco-core/)
|
||||
|
||||
### Contributing guide
|
||||
Please use [this guide](CONTRIBUTING.md) to make a contribution to the project.
|
@@ -1,47 +0,0 @@
|
||||
### Alfresco Data Model
|
||||
[](https://travis-ci.com/Alfresco/alfresco-data-model)
|
||||
|
||||
Data model is a library packaged as a jar file which is part of [Alfresco Content Services Repository](https://community.alfresco.com/docs/DOC-6385-project-overview-repository).
|
||||
The library contains the following:
|
||||
* Dictionary, Repository and Search Services interfaces
|
||||
* Models for data types and Dictionary implementation
|
||||
* Parsers
|
||||
|
||||
Please note that the data model uses version 2 of the Jackson libraries.
|
||||
The upgrade from version 1 was not backward compatible, any projects
|
||||
that are dependent on data model using Jackson 1.x should use the data-model 6.N branch.
|
||||
|
||||
Version 8.0 of data-model depends on alfresco-core 7.0 which is based on Spring 5.
|
||||
|
||||
|
||||
### Building and testing
|
||||
The project can be built and tested by running Maven command:
|
||||
~~~
|
||||
mvn clean install
|
||||
~~~
|
||||
|
||||
### Artifacts
|
||||
The artifacts can be obtained by:
|
||||
* downloading from [Alfresco repository](https://artifacts.alfresco.com/nexus/content/groups/public)
|
||||
* getting as Maven dependency by adding the dependency to your pom file:
|
||||
~~~
|
||||
<dependency>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-data-model</artifactId>
|
||||
<version>version</version>
|
||||
</dependency>
|
||||
~~~
|
||||
and Alfresco repository:
|
||||
~~~
|
||||
<repository>
|
||||
<id>alfresco-maven-repo</id>
|
||||
<url>https://artifacts.alfresco.com/nexus/content/groups/public</url>
|
||||
</repository>
|
||||
~~~
|
||||
The SNAPSHOT version of the artifact is **never** published.
|
||||
|
||||
### Old version history
|
||||
The history for older versions can be found in [Alfresco SVN](https://svn.alfresco.com/repos/alfresco-open-mirror/alfresco/HEAD/root/projects/data-model)
|
||||
|
||||
### Contributing guide
|
||||
Please use [this guide](CONTRIBUTING.md) to make a contribution to the project.
|
@@ -552,19 +552,43 @@ import org.springframework.util.StringUtils;
|
||||
// check mandatory
|
||||
if (isMandatory() != propDef.isMandatory())
|
||||
{
|
||||
isUpdated = true;
|
||||
// Change from mandatory to NON mandatory is an incremental change
|
||||
if (isMandatory() && !propDef.isMandatory())
|
||||
{
|
||||
isUpdatedIncrementally = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
isUpdated = true;
|
||||
}
|
||||
}
|
||||
|
||||
// check mandatory enforced
|
||||
if (isMandatoryEnforced() != propDef.isMandatoryEnforced())
|
||||
{
|
||||
isUpdated = true;
|
||||
// Change from mandatory enforced to NON mandatory enforced is an incremental change
|
||||
if (isMandatoryEnforced() && ! propDef.isMandatoryEnforced())
|
||||
{
|
||||
isUpdatedIncrementally = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
isUpdated = true;
|
||||
}
|
||||
}
|
||||
|
||||
// check protected
|
||||
if (isProtected() != propDef.isProtected())
|
||||
{
|
||||
isUpdated = true;
|
||||
// Change from protected to NON protected is an incremental change
|
||||
if (isProtected() && !propDef.isProtected())
|
||||
{
|
||||
isUpdatedIncrementally = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
isUpdated = true;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
@@ -896,6 +896,58 @@ public class AbstractModelTest extends TestCase
|
||||
" </aspects>" +
|
||||
|
||||
"</model>";
|
||||
public static final String MODEL8_XML =
|
||||
"<model name=\"test8:model8\" xmlns=\"http://www.alfresco.org/model/dictionary/1.0\">" +
|
||||
|
||||
" <imports>" +
|
||||
" <import uri=\"http://www.alfresco.org/model/dictionary/1.0\" prefix=\"d\"/>" +
|
||||
" </imports>" +
|
||||
|
||||
" <namespaces>" +
|
||||
" <namespace uri=\"http://www.alfresco.org/model/test8/1.0\" prefix=\"test8\"/>" +
|
||||
" </namespaces>" +
|
||||
|
||||
" <aspects>" +
|
||||
|
||||
" <aspect name=\"test8:aspectA\">" +
|
||||
" <properties> " +
|
||||
" <property name=\"test8:propA1\"> " +
|
||||
" <title>Prop A1</title> " +
|
||||
" <type>d:text</type> " +
|
||||
" <mandatory enforced=\"true\" protected =\"true\">true</mandatory> " +
|
||||
" </property> " +
|
||||
" </properties> " +
|
||||
" </aspect>" +
|
||||
|
||||
" </aspects>" +
|
||||
|
||||
"</model>";
|
||||
public static final String MODEL8_CHANGE_MANDATORY_PROPERTIES_ASPECTS_XML =
|
||||
"<model name=\"test8:model8\" xmlns=\"http://www.alfresco.org/model/dictionary/1.0\">" +
|
||||
|
||||
" <imports>" +
|
||||
" <import uri=\"http://www.alfresco.org/model/dictionary/1.0\" prefix=\"d\"/>" +
|
||||
" </imports>" +
|
||||
|
||||
" <namespaces>" +
|
||||
" <namespace uri=\"http://www.alfresco.org/model/test8/1.0\" prefix=\"test8\"/>" +
|
||||
" </namespaces>" +
|
||||
|
||||
" <aspects>" +
|
||||
|
||||
" <aspect name=\"test8:aspectA\">" +
|
||||
" <properties> " +
|
||||
" <property name=\"test8:propA1\"> " +
|
||||
" <title>Prop A1</title> " +
|
||||
" <type>d:text</type> " +
|
||||
" <mandatory>false</mandatory> " +
|
||||
" </property> " +
|
||||
" </properties> " +
|
||||
" </aspect>" +
|
||||
|
||||
" </aspects>" +
|
||||
|
||||
"</model>";
|
||||
|
||||
|
||||
public AbstractModelTest()
|
||||
|
@@ -25,12 +25,32 @@
|
||||
*/
|
||||
package org.alfresco.repo.dictionary;
|
||||
|
||||
import static java.util.function.Function.identity;
|
||||
import static java.util.stream.Collectors.averagingDouble;
|
||||
import static java.util.stream.Collectors.toMap;
|
||||
|
||||
import static org.alfresco.repo.dictionary.M2ModelDiff.DIFF_CREATED;
|
||||
import static org.alfresco.repo.dictionary.M2ModelDiff.DIFF_DELETED;
|
||||
import static org.alfresco.repo.dictionary.M2ModelDiff.DIFF_UNCHANGED;
|
||||
import static org.alfresco.repo.dictionary.M2ModelDiff.DIFF_UPDATED;
|
||||
import static org.alfresco.repo.dictionary.M2ModelDiff.DIFF_UPDATED_INC;
|
||||
import static org.alfresco.repo.dictionary.M2ModelDiff.TYPE_ASPECT;
|
||||
import static org.alfresco.repo.dictionary.M2ModelDiff.TYPE_ASSOCIATION;
|
||||
import static org.alfresco.repo.dictionary.M2ModelDiff.TYPE_PROPERTY;
|
||||
import static org.alfresco.repo.dictionary.M2ModelDiff.TYPE_TYPE;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
@@ -40,8 +60,10 @@ import org.alfresco.repo.tenant.TenantService;
|
||||
import org.alfresco.service.namespace.NamespaceException;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.DynamicallySizedThreadPoolExecutor;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.alfresco.util.TraceableThreadFactory;
|
||||
import org.alfresco.util.cache.DefaultAsynchronouslyRefreshedCacheRegistry;
|
||||
import org.apache.commons.collections4.map.UnmodifiableMap;
|
||||
|
||||
public class DiffModelTest extends AbstractModelTest
|
||||
{
|
||||
@@ -91,15 +113,10 @@ public class DiffModelTest extends AbstractModelTest
|
||||
|
||||
List<M2ModelDiff> modelDiffs = dictionaryDAO.diffModel(previousVersion, null);
|
||||
|
||||
for (M2ModelDiff modelDiff : modelDiffs)
|
||||
{
|
||||
System.out.println(modelDiff.toString());
|
||||
}
|
||||
|
||||
assertEquals(6, modelDiffs.size());
|
||||
|
||||
assertEquals(3, countDiffs(modelDiffs, M2ModelDiff.TYPE_TYPE, M2ModelDiff.DIFF_DELETED));
|
||||
assertEquals(3, countDiffs(modelDiffs, M2ModelDiff.TYPE_ASPECT, M2ModelDiff.DIFF_DELETED));
|
||||
Map<Pair<String, String>, Integer> expected = Map.of(
|
||||
new Pair(TYPE_TYPE, DIFF_DELETED), 3,
|
||||
new Pair(TYPE_ASPECT, DIFF_DELETED), 3);
|
||||
assertEquals("Unexpected set of diffs found.", expected, getAllDiffCounts(modelDiffs));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@@ -144,15 +161,10 @@ public class DiffModelTest extends AbstractModelTest
|
||||
|
||||
List<M2ModelDiff> modelDiffs = dictionaryDAO.diffModel(null, newVersion);
|
||||
|
||||
for (M2ModelDiff modelDiff : modelDiffs)
|
||||
{
|
||||
System.out.println(modelDiff.toString());
|
||||
}
|
||||
|
||||
assertEquals(6, modelDiffs.size());
|
||||
|
||||
assertEquals(3, countDiffs(modelDiffs, M2ModelDiff.TYPE_TYPE, M2ModelDiff.DIFF_CREATED));
|
||||
assertEquals(3, countDiffs(modelDiffs, M2ModelDiff.TYPE_ASPECT, M2ModelDiff.DIFF_CREATED));
|
||||
Map<Pair<String, String>, Integer> expected = Map.of(
|
||||
new Pair(TYPE_TYPE, DIFF_CREATED), 3,
|
||||
new Pair(TYPE_ASPECT, DIFF_CREATED), 3);
|
||||
assertEquals("Unexpected set of diffs found.", expected, getAllDiffCounts(modelDiffs));
|
||||
}
|
||||
|
||||
public void testDuplicateModels()
|
||||
@@ -190,27 +202,19 @@ public class DiffModelTest extends AbstractModelTest
|
||||
|
||||
List<M2ModelDiff> modelDiffs = dictionaryDAO.diffModel(previousVersion, newVersion);
|
||||
|
||||
for (M2ModelDiff M2ModelDiff : modelDiffs)
|
||||
{
|
||||
System.out.println(M2ModelDiff.toString());
|
||||
}
|
||||
Map<Pair<String, String>, Integer> expected = Map.of(
|
||||
new Pair(TYPE_TYPE, DIFF_CREATED), 1,
|
||||
new Pair(TYPE_TYPE, DIFF_UNCHANGED), 2,
|
||||
new Pair(TYPE_TYPE, DIFF_DELETED), 1,
|
||||
|
||||
assertEquals(16, modelDiffs.size());
|
||||
new Pair(TYPE_ASPECT, DIFF_CREATED), 1,
|
||||
new Pair(TYPE_ASPECT, DIFF_UNCHANGED), 2,
|
||||
new Pair(TYPE_ASPECT, DIFF_DELETED), 1,
|
||||
|
||||
assertEquals(1, countDiffs(modelDiffs, M2ModelDiff.TYPE_TYPE, M2ModelDiff.DIFF_CREATED));
|
||||
assertEquals(2, countDiffs(modelDiffs, M2ModelDiff.TYPE_TYPE, M2ModelDiff.DIFF_UNCHANGED));
|
||||
assertEquals(0, countDiffs(modelDiffs, M2ModelDiff.TYPE_TYPE, M2ModelDiff.DIFF_UPDATED));
|
||||
assertEquals(1, countDiffs(modelDiffs, M2ModelDiff.TYPE_TYPE, M2ModelDiff.DIFF_DELETED));
|
||||
|
||||
assertEquals(1, countDiffs(modelDiffs, M2ModelDiff.TYPE_ASPECT, M2ModelDiff.DIFF_CREATED));
|
||||
assertEquals(2, countDiffs(modelDiffs, M2ModelDiff.TYPE_ASPECT, M2ModelDiff.DIFF_UNCHANGED));
|
||||
assertEquals(0, countDiffs(modelDiffs, M2ModelDiff.TYPE_ASPECT, M2ModelDiff.DIFF_UPDATED));
|
||||
assertEquals(1, countDiffs(modelDiffs, M2ModelDiff.TYPE_ASPECT, M2ModelDiff.DIFF_DELETED));
|
||||
|
||||
assertEquals(0, countDiffs(modelDiffs, M2ModelDiff.TYPE_PROPERTY, M2ModelDiff.DIFF_CREATED));
|
||||
assertEquals(6, countDiffs(modelDiffs, M2ModelDiff.TYPE_PROPERTY, M2ModelDiff.DIFF_UNCHANGED));
|
||||
assertEquals(1, countDiffs(modelDiffs, M2ModelDiff.TYPE_PROPERTY, M2ModelDiff.DIFF_UPDATED));
|
||||
assertEquals(1, countDiffs(modelDiffs, M2ModelDiff.TYPE_PROPERTY, M2ModelDiff.DIFF_DELETED));
|
||||
new Pair(TYPE_PROPERTY, DIFF_UNCHANGED), 6,
|
||||
new Pair(TYPE_PROPERTY, DIFF_UPDATED), 1,
|
||||
new Pair(TYPE_PROPERTY, DIFF_DELETED), 1);
|
||||
assertEquals("Unexpected set of diffs found.", expected, getAllDiffCounts(modelDiffs));
|
||||
}
|
||||
|
||||
public void testIncUpdatePropertiesAdded()
|
||||
@@ -227,17 +231,12 @@ public class DiffModelTest extends AbstractModelTest
|
||||
|
||||
List<M2ModelDiff> modelDiffs = dictionaryDAO.diffModel(previousVersion, newVersion);
|
||||
|
||||
for (M2ModelDiff modelDiff : modelDiffs)
|
||||
{
|
||||
System.out.println(modelDiff.toString());
|
||||
}
|
||||
|
||||
assertEquals(8, modelDiffs.size());
|
||||
|
||||
assertEquals(1, countDiffs(modelDiffs, M2ModelDiff.TYPE_TYPE, M2ModelDiff.DIFF_UNCHANGED));
|
||||
assertEquals(1, countDiffs(modelDiffs, M2ModelDiff.TYPE_ASPECT, M2ModelDiff.DIFF_UNCHANGED));
|
||||
assertEquals(4, countDiffs(modelDiffs, M2ModelDiff.TYPE_PROPERTY, M2ModelDiff.DIFF_UNCHANGED));
|
||||
assertEquals(2, countDiffs(modelDiffs, M2ModelDiff.TYPE_PROPERTY, M2ModelDiff.DIFF_CREATED));
|
||||
Map<Pair<String, String>, Integer> expected = Map.of(
|
||||
new Pair(TYPE_TYPE, DIFF_UNCHANGED), 1,
|
||||
new Pair(TYPE_ASPECT, DIFF_UNCHANGED), 1,
|
||||
new Pair(TYPE_PROPERTY, DIFF_UNCHANGED), 4,
|
||||
new Pair(TYPE_PROPERTY, DIFF_CREATED), 2);
|
||||
assertEquals("Unexpected set of diffs found.", expected, getAllDiffCounts(modelDiffs));
|
||||
}
|
||||
|
||||
public void testIncUpdateTypesAndAspectsAdded()
|
||||
@@ -254,20 +253,13 @@ public class DiffModelTest extends AbstractModelTest
|
||||
|
||||
List<M2ModelDiff> modelDiffs = dictionaryDAO.diffModel(previousVersion, newVersion);
|
||||
|
||||
for (M2ModelDiff modelDiff : modelDiffs)
|
||||
{
|
||||
System.out.println(modelDiff.toString());
|
||||
}
|
||||
|
||||
assertEquals(8, modelDiffs.size());
|
||||
|
||||
assertEquals(1, countDiffs(modelDiffs, M2ModelDiff.TYPE_TYPE, M2ModelDiff.DIFF_UNCHANGED));
|
||||
assertEquals(1, countDiffs(modelDiffs, M2ModelDiff.TYPE_ASPECT, M2ModelDiff.DIFF_UNCHANGED));
|
||||
|
||||
assertEquals(1, countDiffs(modelDiffs, M2ModelDiff.TYPE_TYPE, M2ModelDiff.DIFF_CREATED));
|
||||
assertEquals(1, countDiffs(modelDiffs, M2ModelDiff.TYPE_ASPECT, M2ModelDiff.DIFF_CREATED));
|
||||
|
||||
assertEquals(4, countDiffs(modelDiffs, M2ModelDiff.TYPE_PROPERTY, M2ModelDiff.DIFF_UNCHANGED));
|
||||
Map<Pair<String, String>, Integer> expected = Map.of(
|
||||
new Pair(TYPE_TYPE, DIFF_UNCHANGED), 1,
|
||||
new Pair(TYPE_ASPECT, DIFF_UNCHANGED), 1,
|
||||
new Pair(TYPE_TYPE, DIFF_CREATED), 1,
|
||||
new Pair(TYPE_ASPECT, DIFF_CREATED), 1,
|
||||
new Pair(TYPE_PROPERTY, DIFF_UNCHANGED), 4);
|
||||
assertEquals("Unexpected set of diffs found.", expected, getAllDiffCounts(modelDiffs));
|
||||
}
|
||||
|
||||
public void testIncUpdateAssociationsAdded()
|
||||
@@ -284,21 +276,13 @@ public class DiffModelTest extends AbstractModelTest
|
||||
|
||||
List<M2ModelDiff> modelDiffs = dictionaryDAO.diffModel(previousVersion, newVersion);
|
||||
|
||||
for (M2ModelDiff modelDiff : modelDiffs)
|
||||
{
|
||||
System.out.println(modelDiff.toString());
|
||||
}
|
||||
|
||||
assertEquals(12, modelDiffs.size());
|
||||
|
||||
assertEquals(1, countDiffs(modelDiffs, M2ModelDiff.TYPE_TYPE, M2ModelDiff.DIFF_UPDATED_INC));
|
||||
assertEquals(1, countDiffs(modelDiffs, M2ModelDiff.TYPE_TYPE, M2ModelDiff.DIFF_UNCHANGED));
|
||||
|
||||
assertEquals(2, countDiffs(modelDiffs, M2ModelDiff.TYPE_ASPECT, M2ModelDiff.DIFF_UNCHANGED));
|
||||
|
||||
assertEquals(6, countDiffs(modelDiffs, M2ModelDiff.TYPE_PROPERTY, M2ModelDiff.DIFF_UNCHANGED));
|
||||
|
||||
assertEquals(2, countDiffs(modelDiffs, M2ModelDiff.TYPE_ASSOCIATION, M2ModelDiff.DIFF_CREATED));
|
||||
Map<Pair<String, String>, Integer> expected = Map.of(
|
||||
new Pair(TYPE_TYPE, DIFF_UPDATED_INC), 1,
|
||||
new Pair(TYPE_TYPE, DIFF_UNCHANGED), 1,
|
||||
new Pair(TYPE_ASPECT, DIFF_UNCHANGED), 2,
|
||||
new Pair(TYPE_PROPERTY, DIFF_UNCHANGED), 6,
|
||||
new Pair(TYPE_ASSOCIATION, DIFF_CREATED), 2);
|
||||
assertEquals("Unexpected set of diffs found.", expected, getAllDiffCounts(modelDiffs));
|
||||
}
|
||||
|
||||
public void testIncUpdateTitleDescription()
|
||||
@@ -315,16 +299,11 @@ public class DiffModelTest extends AbstractModelTest
|
||||
|
||||
List<M2ModelDiff> modelDiffs = dictionaryDAO.diffModel(previousVersion, newVersion);
|
||||
|
||||
for (M2ModelDiff modelDiff : modelDiffs)
|
||||
{
|
||||
System.out.println(modelDiff.toString());
|
||||
}
|
||||
|
||||
assertEquals(4, modelDiffs.size());
|
||||
|
||||
assertEquals(1, countDiffs(modelDiffs, M2ModelDiff.TYPE_TYPE, M2ModelDiff.DIFF_UPDATED_INC));
|
||||
assertEquals(1, countDiffs(modelDiffs, M2ModelDiff.TYPE_ASPECT, M2ModelDiff.DIFF_UNCHANGED));
|
||||
assertEquals(2, countDiffs(modelDiffs, M2ModelDiff.TYPE_PROPERTY, M2ModelDiff.DIFF_UPDATED_INC));
|
||||
Map<Pair<String, String>, Integer> expected = Map.of(
|
||||
new Pair(TYPE_TYPE, DIFF_UPDATED_INC), 1,
|
||||
new Pair(TYPE_ASPECT, DIFF_UNCHANGED), 1,
|
||||
new Pair(TYPE_PROPERTY, DIFF_UPDATED_INC), 2);
|
||||
assertEquals("Unexpected set of diffs found.", expected, getAllDiffCounts(modelDiffs));
|
||||
}
|
||||
|
||||
public void testNonIncUpdatePropertiesRemoved()
|
||||
@@ -341,17 +320,12 @@ public class DiffModelTest extends AbstractModelTest
|
||||
|
||||
List<M2ModelDiff> modelDiffs = dictionaryDAO.diffModel(previousVersion, newVersion);
|
||||
|
||||
for (M2ModelDiff modelDiff : modelDiffs)
|
||||
{
|
||||
System.out.println(modelDiff.toString());
|
||||
}
|
||||
|
||||
assertEquals(8, modelDiffs.size());
|
||||
|
||||
assertEquals(1, countDiffs(modelDiffs, M2ModelDiff.TYPE_TYPE, M2ModelDiff.DIFF_UNCHANGED));
|
||||
assertEquals(1, countDiffs(modelDiffs, M2ModelDiff.TYPE_ASPECT, M2ModelDiff.DIFF_UNCHANGED));
|
||||
assertEquals(4, countDiffs(modelDiffs, M2ModelDiff.TYPE_PROPERTY, M2ModelDiff.DIFF_UNCHANGED));
|
||||
assertEquals(2, countDiffs(modelDiffs, M2ModelDiff.TYPE_PROPERTY, M2ModelDiff.DIFF_DELETED));
|
||||
Map<Pair<String, String>, Integer> expected = Map.of(
|
||||
new Pair(TYPE_TYPE, DIFF_UNCHANGED), 1,
|
||||
new Pair(TYPE_ASPECT, DIFF_UNCHANGED), 1,
|
||||
new Pair(TYPE_PROPERTY, DIFF_UNCHANGED), 4,
|
||||
new Pair(TYPE_PROPERTY, DIFF_DELETED), 2);
|
||||
assertEquals("Unexpected set of diffs found.", expected, getAllDiffCounts(modelDiffs));
|
||||
}
|
||||
|
||||
public void testNonIncUpdateTypesAndAspectsRemoved()
|
||||
@@ -368,20 +342,13 @@ public class DiffModelTest extends AbstractModelTest
|
||||
|
||||
List<M2ModelDiff> modelDiffs = dictionaryDAO.diffModel(previousVersion, newVersion);
|
||||
|
||||
for (M2ModelDiff modelDiff : modelDiffs)
|
||||
{
|
||||
System.out.println(modelDiff.toString());
|
||||
}
|
||||
|
||||
assertEquals(8, modelDiffs.size());
|
||||
|
||||
assertEquals(1, countDiffs(modelDiffs, M2ModelDiff.TYPE_TYPE, M2ModelDiff.DIFF_UNCHANGED));
|
||||
assertEquals(1, countDiffs(modelDiffs, M2ModelDiff.TYPE_ASPECT, M2ModelDiff.DIFF_UNCHANGED));
|
||||
|
||||
assertEquals(1, countDiffs(modelDiffs, M2ModelDiff.TYPE_TYPE, M2ModelDiff.DIFF_DELETED));
|
||||
assertEquals(1, countDiffs(modelDiffs, M2ModelDiff.TYPE_ASPECT, M2ModelDiff.DIFF_DELETED));
|
||||
|
||||
assertEquals(4, countDiffs(modelDiffs, M2ModelDiff.TYPE_PROPERTY, M2ModelDiff.DIFF_UNCHANGED));
|
||||
Map<Pair<String, String>, Integer> expected = Map.of(
|
||||
new Pair(TYPE_TYPE, DIFF_UNCHANGED), 1,
|
||||
new Pair(TYPE_ASPECT, DIFF_UNCHANGED), 1,
|
||||
new Pair(TYPE_TYPE, DIFF_DELETED), 1,
|
||||
new Pair(TYPE_ASPECT, DIFF_DELETED), 1,
|
||||
new Pair(TYPE_PROPERTY, DIFF_UNCHANGED), 4);
|
||||
assertEquals("Unexpected set of diffs found.", expected, getAllDiffCounts(modelDiffs));
|
||||
}
|
||||
|
||||
public void testNonIncUpdateDefaultAspectAdded()
|
||||
@@ -398,16 +365,11 @@ public class DiffModelTest extends AbstractModelTest
|
||||
|
||||
List<M2ModelDiff> modelDiffs = dictionaryDAO.diffModel(previousVersion, newVersion);
|
||||
|
||||
for (M2ModelDiff modelDiff : modelDiffs)
|
||||
{
|
||||
System.out.println(modelDiff.toString());
|
||||
}
|
||||
|
||||
assertEquals(4, modelDiffs.size());
|
||||
|
||||
assertEquals(1, countDiffs(modelDiffs, M2ModelDiff.TYPE_TYPE, M2ModelDiff.DIFF_UPDATED));
|
||||
assertEquals(1, countDiffs(modelDiffs, M2ModelDiff.TYPE_ASPECT, M2ModelDiff.DIFF_UNCHANGED));
|
||||
assertEquals(2, countDiffs(modelDiffs, M2ModelDiff.TYPE_PROPERTY, M2ModelDiff.DIFF_UNCHANGED));
|
||||
Map<Pair<String, String>, Integer> expected = Map.of(
|
||||
new Pair(TYPE_TYPE, DIFF_UPDATED), 1,
|
||||
new Pair(TYPE_ASPECT, DIFF_UNCHANGED), 1,
|
||||
new Pair(TYPE_PROPERTY, DIFF_UNCHANGED), 2);
|
||||
assertEquals("Unexpected set of diffs found.", expected, getAllDiffCounts(modelDiffs));
|
||||
}
|
||||
|
||||
public void testNonIncUpdateAssociationsRemoved()
|
||||
@@ -424,21 +386,13 @@ public class DiffModelTest extends AbstractModelTest
|
||||
|
||||
List<M2ModelDiff> modelDiffs = dictionaryDAO.diffModel(previousVersion, newVersion);
|
||||
|
||||
for (M2ModelDiff modelDiff : modelDiffs)
|
||||
{
|
||||
System.out.println(modelDiff.toString());
|
||||
}
|
||||
|
||||
assertEquals(12, modelDiffs.size());
|
||||
|
||||
assertEquals(1, countDiffs(modelDiffs, M2ModelDiff.TYPE_TYPE, M2ModelDiff.DIFF_UPDATED));
|
||||
assertEquals(1, countDiffs(modelDiffs, M2ModelDiff.TYPE_TYPE, M2ModelDiff.DIFF_UNCHANGED));
|
||||
|
||||
assertEquals(2, countDiffs(modelDiffs, M2ModelDiff.TYPE_ASPECT, M2ModelDiff.DIFF_UNCHANGED));
|
||||
|
||||
assertEquals(6, countDiffs(modelDiffs, M2ModelDiff.TYPE_PROPERTY, M2ModelDiff.DIFF_UNCHANGED));
|
||||
|
||||
assertEquals(2, countDiffs(modelDiffs, M2ModelDiff.TYPE_ASSOCIATION, M2ModelDiff.DIFF_DELETED));
|
||||
Map<Pair<String, String>, Integer> expected = Map.of(
|
||||
new Pair(TYPE_TYPE, DIFF_UPDATED), 1,
|
||||
new Pair(TYPE_TYPE, DIFF_UNCHANGED), 1,
|
||||
new Pair(TYPE_ASPECT, DIFF_UNCHANGED), 2,
|
||||
new Pair(TYPE_PROPERTY, DIFF_UNCHANGED), 6,
|
||||
new Pair(TYPE_ASSOCIATION, DIFF_DELETED), 2);
|
||||
assertEquals("Unexpected set of diffs found.", expected, getAllDiffCounts(modelDiffs));
|
||||
}
|
||||
|
||||
public void testIncUpdatePropertiesAddedToMandatoryAspect()
|
||||
@@ -455,15 +409,10 @@ public class DiffModelTest extends AbstractModelTest
|
||||
|
||||
List<M2ModelDiff> modelDiffs = dictionaryDAO.diffModel(previousVersion, newVersion);
|
||||
|
||||
for (M2ModelDiff modelDiff : modelDiffs)
|
||||
{
|
||||
System.out.println(modelDiff.toString());
|
||||
}
|
||||
|
||||
assertEquals(3, modelDiffs.size());
|
||||
|
||||
assertEquals(2, countDiffs(modelDiffs, M2ModelDiff.TYPE_ASPECT, M2ModelDiff.DIFF_UNCHANGED));
|
||||
assertEquals(1, countDiffs(modelDiffs, M2ModelDiff.TYPE_PROPERTY, M2ModelDiff.DIFF_CREATED));
|
||||
Map<Pair<String, String>, Integer> expected = Map.of(
|
||||
new Pair(TYPE_ASPECT, DIFF_UNCHANGED), 2,
|
||||
new Pair(TYPE_PROPERTY, DIFF_CREATED), 1);
|
||||
assertEquals("Unexpected set of diffs found.", expected, getAllDiffCounts(modelDiffs));
|
||||
}
|
||||
|
||||
public void testNonIncUpdatePropertiesRemovedFromMandatoryAspect()
|
||||
@@ -480,29 +429,70 @@ public class DiffModelTest extends AbstractModelTest
|
||||
|
||||
List<M2ModelDiff> modelDiffs = dictionaryDAO.diffModel(previousVersion, newVersion);
|
||||
|
||||
for (M2ModelDiff modelDiff : modelDiffs)
|
||||
{
|
||||
System.out.println(modelDiff.toString());
|
||||
}
|
||||
|
||||
assertEquals(3, modelDiffs.size());
|
||||
|
||||
assertEquals(2, countDiffs(modelDiffs, M2ModelDiff.TYPE_ASPECT, M2ModelDiff.DIFF_UNCHANGED));
|
||||
assertEquals(1, countDiffs(modelDiffs, M2ModelDiff.TYPE_PROPERTY, M2ModelDiff.DIFF_DELETED));
|
||||
Map<Pair<String, String>, Integer> expected = Map.of(
|
||||
new Pair(TYPE_ASPECT, DIFF_UNCHANGED), 2,
|
||||
new Pair(TYPE_PROPERTY, DIFF_DELETED), 1);
|
||||
assertEquals("Unexpected set of diffs found.", expected, getAllDiffCounts(modelDiffs));
|
||||
}
|
||||
|
||||
private int countDiffs(List<M2ModelDiff> M2ModelDiffs, String elementType, String diffType)
|
||||
/**
|
||||
* Changing a property from mandatory/enforced/protected to NON mandatory/enforced/protected
|
||||
* is an incremental change and it should be allowed.
|
||||
*/
|
||||
public void testIncChangeMandatoryProperties()
|
||||
{
|
||||
int count = 0;
|
||||
for (M2ModelDiff modelDiff : M2ModelDiffs)
|
||||
{
|
||||
if (modelDiff.getDiffType().equals(diffType) && modelDiff.getElementType().equals(elementType))
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(AbstractModelTest.MODEL8_XML.getBytes());
|
||||
M2Model model = M2Model.createModel(byteArrayInputStream);
|
||||
QName modelName = dictionaryDAO.putModel(model);
|
||||
CompiledModel previousVersion = dictionaryDAO.getCompiledModel(modelName);
|
||||
|
||||
byteArrayInputStream = new ByteArrayInputStream(AbstractModelTest.MODEL8_CHANGE_MANDATORY_PROPERTIES_ASPECTS_XML.getBytes());
|
||||
model = M2Model.createModel(byteArrayInputStream);
|
||||
modelName = dictionaryDAO.putModel(model);
|
||||
CompiledModel newVersion = dictionaryDAO.getCompiledModel(modelName);
|
||||
|
||||
List<M2ModelDiff> modelDiffs = dictionaryDAO.diffModel(previousVersion, newVersion);
|
||||
|
||||
Map<Pair<String, String>, Integer> expected = Map.of(
|
||||
new Pair(TYPE_ASPECT, DIFF_UNCHANGED), 1,
|
||||
new Pair(TYPE_PROPERTY, DIFF_UPDATED_INC), 1);
|
||||
assertEquals("Unexpected set of diffs found.", expected, getAllDiffCounts(modelDiffs));
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Changing a property from NOT mandatory/enforced/protected to mandatory/enforced/protected
|
||||
* is considered to be a non incremental change.
|
||||
*/
|
||||
public void testNonIncChangeMandatoryProperties()
|
||||
{
|
||||
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(AbstractModelTest.MODEL8_CHANGE_MANDATORY_PROPERTIES_ASPECTS_XML.getBytes());
|
||||
M2Model model = M2Model.createModel(byteArrayInputStream);
|
||||
QName modelName = dictionaryDAO.putModel(model);
|
||||
CompiledModel previousVersion = dictionaryDAO.getCompiledModel(modelName);
|
||||
|
||||
byteArrayInputStream = new ByteArrayInputStream(AbstractModelTest.MODEL8_XML.getBytes());
|
||||
model = M2Model.createModel(byteArrayInputStream);
|
||||
modelName = dictionaryDAO.putModel(model);
|
||||
CompiledModel newVersion = dictionaryDAO.getCompiledModel(modelName);
|
||||
|
||||
List<M2ModelDiff> modelDiffs = dictionaryDAO.diffModel(previousVersion, newVersion);
|
||||
|
||||
Map<Pair<String, String>, Integer> expected = Map.of(
|
||||
new Pair(TYPE_ASPECT, DIFF_UNCHANGED), 1,
|
||||
new Pair(TYPE_PROPERTY, DIFF_UPDATED), 1);
|
||||
assertEquals("Unexpected set of diffs found.", expected, getAllDiffCounts(modelDiffs));
|
||||
}
|
||||
|
||||
/**
|
||||
* Count the diffs grouping by element type and diff type.
|
||||
*
|
||||
* @param m2ModelDiffs The list of diffs returned from the dictionaryDAO.
|
||||
* @return A map from (elementType, diffType) to the number of occurrences of matching diffs in the list.
|
||||
*/
|
||||
private Map<Pair<String, String>, Integer> getAllDiffCounts(List<M2ModelDiff> m2ModelDiffs)
|
||||
{
|
||||
return m2ModelDiffs.stream()
|
||||
.map(modelDiff -> new Pair<>(modelDiff.getElementType(), modelDiff.getDiffType()))
|
||||
.collect(toMap(identity(), pair -> 1, Integer::sum));
|
||||
}
|
||||
}
|
||||
|
@@ -34,7 +34,7 @@ COPY ${resource_path}/war ${TOMCAT_DIR}/webapps
|
||||
COPY ${resource_path}/connector/* ${TOMCAT_DIR}/lib/
|
||||
COPY ${resource_path}/alfresco-mmt/* ${TOMCAT_DIR}/alfresco-mmt/
|
||||
COPY ${resource_path}/dependency/licenses/ /licenses/
|
||||
COPY ${resource_path}/dependency/keystore/metadata-keystore ${TOMCAT_DIR}/shared/classes/alfresco/extension/keystore/
|
||||
COPY ${resource_path}/dependency/keystore/metadata-keystore/keystore ${TOMCAT_DIR}/shared/classes/alfresco/extension/keystore
|
||||
|
||||
# Change the value of the shared.loader= property to the following:
|
||||
# shared.loader=${catalina.base}/shared/classes
|
||||
|
@@ -1,4 +1,4 @@
|
||||
TRANSFORMERS_TAG=2.3.4
|
||||
SOLR6_TAG=1.4.2
|
||||
TRANSFORMERS_TAG=2.3.5
|
||||
SOLR6_TAG=2.0.0
|
||||
POSTGRES_TAG=11.7
|
||||
ACTIVEMQ_TAG=5.15.8
|
||||
|
@@ -21,7 +21,8 @@ public class ImapDeleteMessagesTests extends EmailTest
|
||||
adminSite = dataSite.usingAdmin().createIMAPSite();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
|
||||
// TODO uncomment once https://issues.alfresco.com/jira/browse/MNT-21648 is solved
|
||||
/* @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify message can be deleted from IMAP client by admin")
|
||||
@Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
|
||||
public void adminShouldDeleteMessage() throws Exception
|
||||
@@ -31,7 +32,7 @@ public class ImapDeleteMessagesTests extends EmailTest
|
||||
.and().usingResource(testFile).assertThat().existsInRepo().deleteMessage()
|
||||
.and().assertThat().doesNotContainMessages(testFile)
|
||||
.then().usingResource(testFile).assertThat().doesNotExistInRepo();
|
||||
}
|
||||
} */
|
||||
|
||||
@TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify deleting message via IMAP client by user with MANAGER role")
|
||||
|
25
pom.xml
25
pom.xml
@@ -56,20 +56,20 @@
|
||||
<dependency.alfresco-greenmail.version>6.2</dependency.alfresco-greenmail.version>
|
||||
<dependency.acs-event-model.version>0.0.8</dependency.acs-event-model.version>
|
||||
|
||||
<dependency.spring.version>5.2.8.RELEASE</dependency.spring.version>
|
||||
<dependency.spring.version>5.2.9.RELEASE</dependency.spring.version>
|
||||
<dependency.antlr.version>3.5.2</dependency.antlr.version>
|
||||
<dependency.jackson.version>2.11.2</dependency.jackson.version>
|
||||
<dependency.jackson-databind.version>2.10.1</dependency.jackson-databind.version>
|
||||
<dependency.cxf.version>3.3.7</dependency.cxf.version>
|
||||
<dependency.opencmis.version>1.0.0</dependency.opencmis.version>
|
||||
<dependency.pdfbox.version>2.0.20</dependency.pdfbox.version>
|
||||
<dependency.pdfbox.version>2.0.21</dependency.pdfbox.version>
|
||||
<dependency.webscripts.version>8.8</dependency.webscripts.version>
|
||||
<dependency.bouncycastle.version>1.66</dependency.bouncycastle.version>
|
||||
<dependency.mockito-core.version>3.4.6</dependency.mockito-core.version>
|
||||
<dependency.mockito-core.version>3.5.11</dependency.mockito-core.version>
|
||||
<dependency.org-json.version>20090211</dependency.org-json.version>
|
||||
<dependency.commons-dbcp.version>1.4-DBCP330</dependency.commons-dbcp.version>
|
||||
<dependency.guava.version>28.2-jre</dependency.guava.version>
|
||||
<dependency.commons-io.version>2.7</dependency.commons-io.version>
|
||||
<dependency.commons-io.version>2.8.0</dependency.commons-io.version>
|
||||
<dependency.gson.version>2.8.5</dependency.gson.version>
|
||||
<dependency.httpclient.version>4.5.12</dependency.httpclient.version>
|
||||
<dependency.httpcore.version>4.4.13</dependency.httpcore.version>
|
||||
@@ -81,7 +81,7 @@
|
||||
<dependency.groovy.version>2.5.9</dependency.groovy.version>
|
||||
<dependency.javax.mail.version>1.6.2</dependency.javax.mail.version>
|
||||
<dependency.tika.version>1.24.1</dependency.tika.version>
|
||||
<dependency.spring-security.version>5.2.1.RELEASE</dependency.spring-security.version>
|
||||
<dependency.spring-security.version>5.3.4.RELEASE</dependency.spring-security.version>
|
||||
<dependency.truezip.version>7.7.10</dependency.truezip.version>
|
||||
<dependency.poi.version>4.1.2</dependency.poi.version>
|
||||
<dependency.ooxml-schemas.version>1.4</dependency.ooxml-schemas.version>
|
||||
@@ -93,9 +93,9 @@
|
||||
<dependency.awaitility.version>4.0.3</dependency.awaitility.version>
|
||||
|
||||
<alfresco.googledrive.version>3.2.0</alfresco.googledrive.version>
|
||||
<alfresco.aos-module.version>1.3.1</alfresco.aos-module.version>
|
||||
<alfresco.aos-module.version>1.4.0-M1</alfresco.aos-module.version>
|
||||
|
||||
<dependency.postgresql.version>42.2.15</dependency.postgresql.version>
|
||||
<dependency.postgresql.version>42.2.16</dependency.postgresql.version>
|
||||
<dependency.mysql.version>8.0.19</dependency.mysql.version>
|
||||
<dependency.mariadb.version>2.6.2</dependency.mariadb.version>
|
||||
|
||||
@@ -103,7 +103,7 @@
|
||||
<dependency.rest-assured.version>3.3.0</dependency.rest-assured.version>
|
||||
<dependency.javax.json.version>1.1.4</dependency.javax.json.version>
|
||||
<dependency.tas-restapi.version>1.47</dependency.tas-restapi.version>
|
||||
<dependency.tas-cmis.version>1.13</dependency.tas-cmis.version>
|
||||
<dependency.tas-cmis.version>1.14</dependency.tas-cmis.version>
|
||||
<dependency.tas-email.version>1.8</dependency.tas-email.version>
|
||||
<dependency.tas-webdav.version>1.6</dependency.tas-webdav.version>
|
||||
<dependency.tas-ftp.version>1.5</dependency.tas-ftp.version>
|
||||
@@ -174,11 +174,6 @@
|
||||
<classifier>win64</classifier>
|
||||
<type>tgz</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-pdf-renderer</artifactId>
|
||||
<version>${dependency.alfresco-pdf-renderer.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-server-root</artifactId>
|
||||
@@ -243,7 +238,7 @@
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<version>1.14</version>
|
||||
<version>1.15</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
@@ -525,7 +520,7 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-compress</artifactId>
|
||||
<version>1.19</version>
|
||||
<version>1.20</version>
|
||||
</dependency>
|
||||
<!-- upgrade dependency from TIKA -->
|
||||
<dependency>
|
||||
|
@@ -1,41 +0,0 @@
|
||||
### Alfresco Remote API
|
||||
[](https://travis-ci.com/Alfresco/alfresco-remote-api)
|
||||
|
||||
Remote API is a library packaged as a jar file which is part of [Alfresco Content Services Repository](https://community.alfresco.com/docs/DOC-6385-project-overview-repository).
|
||||
The library contains the following:
|
||||
* REST API framework
|
||||
* WebScript implementations including [V1 REST APIs](https://community.alfresco.com/community/ecm/blog/2017/05/02/v1-rest-api-10-things-you-should-know)
|
||||
* [OpenCMIS](https://chemistry.apache.org/java/opencmis.html) implementations
|
||||
|
||||
### Building and testing
|
||||
The project can be built by running Maven command:
|
||||
~~~
|
||||
mvn clean install
|
||||
~~~
|
||||
The tests are combined in test classes split by test type or Spring application context used in the test, see classes in _src/test/java/org/alfresco_. All of these classes as well as individual tests can be run by specifying the test class name and a set of DB connection properties, for example:
|
||||
~~~
|
||||
mvn clean test -Dtest=SomeTest -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql:alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
||||
~~~
|
||||
|
||||
### Artifacts
|
||||
The artifacts can be obtained by:
|
||||
* downloading from [Alfresco repository](https://artifacts.alfresco.com/nexus/content/groups/public)
|
||||
* getting as Maven dependency by adding the dependency to your pom file:
|
||||
~~~
|
||||
<dependency>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-remote-api</artifactId>
|
||||
<version>version</version>
|
||||
</dependency>
|
||||
~~~
|
||||
and Alfresco Maven repository:
|
||||
~~~
|
||||
<repository>
|
||||
<id>alfresco-maven-repo</id>
|
||||
<url>https://artifacts.alfresco.com/nexus/content/groups/public</url>
|
||||
</repository>
|
||||
~~~
|
||||
The SNAPSHOT version of the artifact is **never** published.
|
||||
|
||||
### Contributing guide
|
||||
Please use [this guide](CONTRIBUTING.md) to make a contribution to the project.
|
@@ -221,7 +221,6 @@
|
||||
<dependency>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-pdf-renderer</artifactId>
|
||||
<version>${dependency.alfresco-pdf-renderer.version}</version>
|
||||
<classifier>win64</classifier>
|
||||
<type>tgz</type>
|
||||
</dependency>
|
||||
@@ -266,7 +265,6 @@
|
||||
<dependency>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-pdf-renderer</artifactId>
|
||||
<version>${dependency.alfresco-pdf-renderer.version}</version>
|
||||
<classifier>linux</classifier>
|
||||
<type>tgz</type>
|
||||
</dependency>
|
||||
@@ -303,54 +301,6 @@
|
||||
<alfresco-pdf-renderer.exe>${project.build.directory}/test-binaries/alfresco-pdf-renderer/alfresco-pdf-renderer</alfresco-pdf-renderer.exe>
|
||||
</properties>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>osx-alfresco-pdf-renderer-test</id>
|
||||
<activation>
|
||||
<os>
|
||||
<family>mac</family>
|
||||
</os>
|
||||
</activation>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-pdf-renderer</artifactId>
|
||||
<version>${dependency.alfresco-pdf-renderer.version}</version>
|
||||
<classifier>osx</classifier>
|
||||
<type>tgz</type>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<inherited>false</inherited>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>extract-alfresco-pdf-renderer-test</id>
|
||||
<phase>generate-test-resources</phase>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<skip>${skipTests}</skip>
|
||||
<target>
|
||||
<echo message="Extracting alfresco-pdf-renderer (OS-X) for testing..." />
|
||||
<mkdir dir="${project.build.directory}/test-binaries/alfresco-pdf-renderer" />
|
||||
<exec failonerror="true" executable="tar" dir="${project.build.directory}/test-binaries/alfresco-pdf-renderer">
|
||||
<arg value="xf" />
|
||||
<arg value="${settings.localRepository}/org/alfresco/alfresco-pdf-renderer/${dependency.alfresco-pdf-renderer.version}/alfresco-pdf-renderer-${dependency.alfresco-pdf-renderer.version}-osx.tgz" />
|
||||
</exec>
|
||||
</target>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<properties>
|
||||
<alfresco-pdf-renderer.exe>${project.build.directory}/test-binaries/alfresco-pdf-renderer/alfresco-pdf-renderer</alfresco-pdf-renderer.exe>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
<build>
|
||||
<pluginManagement>
|
||||
|
@@ -438,7 +438,7 @@ import org.springframework.extensions.webscripts.json.JSONUtils;
|
||||
{
|
||||
public String convert(ChildAssociationRef source)
|
||||
{
|
||||
return source.toString();
|
||||
return org.json.simple.JSONObject.escape(source.toString());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -454,7 +454,7 @@ import org.springframework.extensions.webscripts.json.JSONUtils;
|
||||
{
|
||||
public String convert(AssociationRef source)
|
||||
{
|
||||
return source.toString();
|
||||
return org.json.simple.JSONObject.escape(source.toString());
|
||||
}
|
||||
});
|
||||
|
||||
|
@@ -366,7 +366,22 @@ public abstract class BaseKerberosAuthenticationFilter extends BaseSSOAuthentica
|
||||
}
|
||||
|
||||
// Send back a request for SPNEGO authentication
|
||||
logonStartAgain(context, req, resp, true);
|
||||
|
||||
// MNT-21702 fixing Kerberos SSO fallback machanism for WebDAV
|
||||
if (req.getRequestURL().toString().contains("webdav"))
|
||||
{
|
||||
if ( getLogger().isDebugEnabled()) {
|
||||
getLogger().debug("WebDAV request, fallback");
|
||||
}
|
||||
logonStartAgain(context, req, resp, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( getLogger().isDebugEnabled()) {
|
||||
getLogger().debug("Non-WebDAV request, don't fallback");
|
||||
}
|
||||
logonStartAgain(context, req, resp, true);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@@ -208,7 +208,7 @@ public abstract class BaseSSOAuthenticationFilter extends BaseAuthenticationFilt
|
||||
{
|
||||
match = container.getRegistry().findWebScript(req.getMethod(), getScriptUrl(req));
|
||||
}
|
||||
catch (NotFoundException notFoundEx)
|
||||
catch (NotFoundException | IllegalArgumentException Ex)
|
||||
{
|
||||
getLogger().debug(req.getMethod() + " " + getScriptUrl(req) + "not found in Public API Container.");
|
||||
}
|
||||
|
@@ -37,7 +37,6 @@ import org.alfresco.rest.api.model.Document;
|
||||
import org.alfresco.rest.api.model.Folder;
|
||||
import org.alfresco.rest.api.model.LockInfo;
|
||||
import org.alfresco.rest.api.model.Node;
|
||||
import org.alfresco.rest.api.model.DirectAccessUrlRequest;
|
||||
import org.alfresco.rest.api.model.PathInfo;
|
||||
import org.alfresco.rest.api.model.UserInfo;
|
||||
import org.alfresco.rest.framework.resource.content.BasicContentInfo;
|
||||
@@ -45,7 +44,6 @@ import org.alfresco.rest.framework.resource.content.BinaryResource;
|
||||
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.DirectAccessUrl;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
@@ -268,10 +266,6 @@ public interface Nodes
|
||||
*/
|
||||
Node unlock(String nodeId, Parameters parameters);
|
||||
|
||||
DirectAccessUrl requestContentUrl(String nodeId, DirectAccessUrlRequest directAccessUrlRequest);
|
||||
|
||||
DirectAccessUrl requestContentUrl(NodeRef nodeRef, DirectAccessUrlRequest directAccessUrlRequest);
|
||||
|
||||
/**
|
||||
* Convert from node properties (map of QName to Serializable) retrieved from
|
||||
* the respository to a map of String to Object that can be formatted/expressed
|
||||
|
@@ -26,14 +26,12 @@
|
||||
|
||||
package org.alfresco.rest.api;
|
||||
|
||||
import org.alfresco.rest.api.model.DirectAccessUrlRequest;
|
||||
import org.alfresco.rest.api.model.Rendition;
|
||||
import org.alfresco.rest.framework.core.exceptions.ConstraintViolatedException;
|
||||
import org.alfresco.rest.framework.core.exceptions.NotFoundException;
|
||||
import org.alfresco.rest.framework.resource.content.BinaryResource;
|
||||
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.service.cmr.repository.DirectAccessUrl;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
import java.util.List;
|
||||
@@ -188,7 +186,5 @@ public interface Renditions
|
||||
* @return the rendition stream
|
||||
*/
|
||||
BinaryResource getContentNoValidation(NodeRef nodeRef, String versionId, String renditionId, Parameters parameters);
|
||||
|
||||
DirectAccessUrl requestContentUrl(String nodeId, String versionId, String renditionId, DirectAccessUrlRequest directAccessUrlRequest);
|
||||
}
|
||||
|
||||
|
@@ -37,7 +37,6 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
@@ -90,7 +89,6 @@ import org.alfresco.rest.api.model.Document;
|
||||
import org.alfresco.rest.api.model.Folder;
|
||||
import org.alfresco.rest.api.model.LockInfo;
|
||||
import org.alfresco.rest.api.model.Node;
|
||||
import org.alfresco.rest.api.model.DirectAccessUrlRequest;
|
||||
import org.alfresco.rest.api.model.NodePermissions;
|
||||
import org.alfresco.rest.api.model.PathInfo;
|
||||
import org.alfresco.rest.api.model.PathInfo.ElementInfo;
|
||||
@@ -141,7 +139,6 @@ import org.alfresco.service.cmr.repository.ContentData;
|
||||
import org.alfresco.service.cmr.repository.ContentIOException;
|
||||
import org.alfresco.service.cmr.repository.ContentService;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.cmr.repository.DirectAccessUrl;
|
||||
import org.alfresco.service.cmr.repository.DuplicateChildNodeNameException;
|
||||
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
||||
import org.alfresco.service.cmr.repository.MimetypeService;
|
||||
@@ -169,7 +166,6 @@ import org.alfresco.util.PropertyCheck;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.joda.time.DateTime;
|
||||
import org.springframework.dao.ConcurrencyFailureException;
|
||||
import org.springframework.extensions.surf.util.Content;
|
||||
import org.springframework.extensions.webscripts.servlet.FormData;
|
||||
@@ -3374,68 +3370,6 @@ public class NodesImpl implements Nodes
|
||||
return getFolderOrDocument(nodeId, parameters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DirectAccessUrl requestContentUrl(String nodeId, DirectAccessUrlRequest nodeDirectAccess)
|
||||
{
|
||||
NodeRef nodeRef = validateOrLookupNode(nodeId, null);
|
||||
return requestContentUrl(nodeRef, nodeDirectAccess);
|
||||
}
|
||||
|
||||
private void checkExpiryDate(Date expiryDate)
|
||||
{
|
||||
DateTime now = DateTime.now();
|
||||
if (now.isAfter(expiryDate.getTime()))
|
||||
{
|
||||
throw new InvalidArgumentException("Invalid expiry date. Expiry date can't be in the past.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DirectAccessUrl requestContentUrl(NodeRef nodeRef, DirectAccessUrlRequest directAccessUrlRequest)
|
||||
{
|
||||
if (nodeRef == null)
|
||||
{
|
||||
throw new InvalidArgumentException("Missing nodeRef");
|
||||
}
|
||||
|
||||
Date expiresAt = null;
|
||||
if (directAccessUrlRequest != null)
|
||||
{
|
||||
if (directAccessUrlRequest.getExpiresAt() != null && directAccessUrlRequest.getValidFor() != null)
|
||||
{
|
||||
throw new InvalidArgumentException("Direct access url can not have both expiresAt and validFor set.");
|
||||
}
|
||||
|
||||
if (directAccessUrlRequest.getExpiresAt() != null)
|
||||
{
|
||||
checkExpiryDate(directAccessUrlRequest.getExpiresAt());
|
||||
|
||||
expiresAt = directAccessUrlRequest.getExpiresAt();
|
||||
}
|
||||
else if (directAccessUrlRequest.getValidFor() != null)
|
||||
{
|
||||
Date expiration = new Date();
|
||||
long expTimeMillis = expiration.getTime();
|
||||
|
||||
expTimeMillis += (directAccessUrlRequest.getValidFor() * 1000);
|
||||
expiration.setTime(expTimeMillis);
|
||||
|
||||
checkExpiryDate(expiration);
|
||||
|
||||
expiresAt = expiration;
|
||||
}
|
||||
}
|
||||
|
||||
DirectAccessUrl directAccessUrl = contentService.getDirectAccessUrl(nodeRef, expiresAt);
|
||||
|
||||
if (directAccessUrl == null)
|
||||
{
|
||||
throw new DisabledServiceException("Direct access url isn't available.");
|
||||
}
|
||||
|
||||
return directAccessUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if same permission is sent more than once
|
||||
* @param locallySetPermissions
|
||||
|
@@ -39,7 +39,6 @@ import org.alfresco.rest.antlr.WhereClauseParser;
|
||||
import org.alfresco.rest.api.Nodes;
|
||||
import org.alfresco.rest.api.Renditions;
|
||||
import org.alfresco.rest.api.model.ContentInfo;
|
||||
import org.alfresco.rest.api.model.DirectAccessUrlRequest;
|
||||
import org.alfresco.rest.api.model.Rendition;
|
||||
import org.alfresco.rest.api.model.Rendition.RenditionStatus;
|
||||
import org.alfresco.rest.framework.core.exceptions.ApiException;
|
||||
@@ -62,7 +61,6 @@ import org.alfresco.rest.workflow.api.impl.MapBasedQueryWalker;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.ContentData;
|
||||
import org.alfresco.service.cmr.repository.DirectAccessUrl;
|
||||
import org.alfresco.service.cmr.repository.MimetypeService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
@@ -718,18 +716,5 @@ public class RenditionsImpl implements Renditions, ResourceLoaderAware
|
||||
return status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DirectAccessUrl requestContentUrl(String nodeId, String versionId, String renditionId, DirectAccessUrlRequest directAccessUrlRequest)
|
||||
{
|
||||
final NodeRef validatedNodeRef = validateNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, nodeId, versionId, null);
|
||||
NodeRef renditionNodeRef = getRenditionByName(validatedNodeRef, renditionId, null);
|
||||
|
||||
if (renditionNodeRef == null)
|
||||
{
|
||||
throw new NotFoundException("The rendition with id: " + renditionId + " was not found.");
|
||||
}
|
||||
|
||||
return nodes.requestContentUrl(renditionNodeRef, directAccessUrlRequest);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Remote API
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2020 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.rest.api.model;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class DirectAccessUrlRequest
|
||||
{
|
||||
private Date expiresAt;
|
||||
private Long validFor;
|
||||
|
||||
public DirectAccessUrlRequest()
|
||||
{
|
||||
}
|
||||
|
||||
public Date getExpiresAt()
|
||||
{
|
||||
return expiresAt;
|
||||
}
|
||||
|
||||
public void setExpiresAt(Date expiresAt)
|
||||
{
|
||||
this.expiresAt = expiresAt;
|
||||
}
|
||||
|
||||
public Long getValidFor()
|
||||
{
|
||||
return validFor;
|
||||
}
|
||||
|
||||
public void setValidFor(Long validFor)
|
||||
{
|
||||
this.validFor = validFor;
|
||||
}
|
||||
}
|
@@ -27,28 +27,21 @@
|
||||
package org.alfresco.rest.api.nodes;
|
||||
|
||||
import org.alfresco.rest.api.Renditions;
|
||||
import org.alfresco.rest.api.model.DirectAccessUrlRequest;
|
||||
import org.alfresco.rest.api.model.Rendition;
|
||||
import org.alfresco.rest.framework.BinaryProperties;
|
||||
import org.alfresco.rest.framework.Operation;
|
||||
import org.alfresco.rest.framework.WebApiDescription;
|
||||
import org.alfresco.rest.framework.WebApiParam;
|
||||
import org.alfresco.rest.framework.core.ResourceParameter;
|
||||
import org.alfresco.rest.framework.resource.RelationshipResource;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceBinaryAction;
|
||||
import org.alfresco.rest.framework.resource.content.BinaryResource;
|
||||
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.rest.framework.webscripts.WithResponse;
|
||||
import org.alfresco.service.cmr.repository.DirectAccessUrl;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.util.PropertyCheck;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -109,13 +102,4 @@ public class NodeRenditionsRelation implements RelationshipResourceAction.Read<R
|
||||
return renditions.getContent(nodeRef, renditionId, parameters);
|
||||
}
|
||||
|
||||
@Operation("request-content-url")
|
||||
@WebApiParam(name = "directAccessUrlRequest", title = "Direct access url request", description = "Direct access url request", kind = ResourceParameter.KIND.HTTP_BODY_OBJECT)
|
||||
@WebApiDescription(title = "Request content url",
|
||||
description="Generates a direct access url.",
|
||||
successStatus = HttpServletResponse.SC_OK)
|
||||
public DirectAccessUrl requestContentUrl(String nodeId, String renditionId, DirectAccessUrlRequest directAccessUrlRequest, Parameters parameters, WithResponse withResponse)
|
||||
{
|
||||
return renditions.requestContentUrl(nodeId, null, renditionId, directAccessUrlRequest);
|
||||
}
|
||||
}
|
||||
|
@@ -27,28 +27,21 @@
|
||||
package org.alfresco.rest.api.nodes;
|
||||
|
||||
import org.alfresco.rest.api.Renditions;
|
||||
import org.alfresco.rest.api.model.DirectAccessUrlRequest;
|
||||
import org.alfresco.rest.api.model.Rendition;
|
||||
import org.alfresco.rest.framework.BinaryProperties;
|
||||
import org.alfresco.rest.framework.Operation;
|
||||
import org.alfresco.rest.framework.WebApiDescription;
|
||||
import org.alfresco.rest.framework.WebApiParam;
|
||||
import org.alfresco.rest.framework.core.ResourceParameter;
|
||||
import org.alfresco.rest.framework.resource.RelationshipResource;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceBinaryAction;
|
||||
import org.alfresco.rest.framework.resource.content.BinaryResource;
|
||||
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.rest.framework.webscripts.WithResponse;
|
||||
import org.alfresco.service.cmr.repository.DirectAccessUrl;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.util.PropertyCheck;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -122,15 +115,4 @@ public class NodeVersionRenditionsRelation implements RelationshipResourceAction
|
||||
return renditions.getContent(nodeRef, versionId, renditionId, parameters);
|
||||
}
|
||||
|
||||
@Operation("request-content-url")
|
||||
@WebApiParam(name = "directAccessUrlRequest", title = "Direct access url request", description = "Direct access url request", kind = ResourceParameter.KIND.HTTP_BODY_OBJECT)
|
||||
@WebApiDescription(title = "Request content url",
|
||||
description="Generates a direct access url.",
|
||||
successStatus = HttpServletResponse.SC_OK)
|
||||
public DirectAccessUrl requestContentUrl(String nodeId, String versionId, DirectAccessUrlRequest directAccessUrlRequest, Parameters parameters, WithResponse withResponse)
|
||||
{
|
||||
String renditionId = parameters.getRelationship2Id();
|
||||
|
||||
return renditions.requestContentUrl(nodeId, versionId, renditionId, directAccessUrlRequest);
|
||||
}
|
||||
}
|
||||
|
@@ -31,14 +31,11 @@ import org.alfresco.repo.policy.BehaviourFilter;
|
||||
import org.alfresco.repo.version.Version2Model;
|
||||
import org.alfresco.repo.version.VersionModel;
|
||||
import org.alfresco.rest.api.model.Node;
|
||||
import org.alfresco.rest.api.model.DirectAccessUrlRequest;
|
||||
import org.alfresco.rest.api.model.UserInfo;
|
||||
import org.alfresco.rest.api.model.VersionOptions;
|
||||
import org.alfresco.rest.framework.BinaryProperties;
|
||||
import org.alfresco.rest.framework.Operation;
|
||||
import org.alfresco.rest.framework.WebApiDescription;
|
||||
import org.alfresco.rest.framework.WebApiParam;
|
||||
import org.alfresco.rest.framework.core.ResourceParameter;
|
||||
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
|
||||
import org.alfresco.rest.framework.core.exceptions.PermissionDeniedException;
|
||||
import org.alfresco.rest.framework.resource.RelationshipResource;
|
||||
@@ -49,7 +46,6 @@ import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.rest.framework.webscripts.WithResponse;
|
||||
import org.alfresco.service.cmr.coci.CheckOutCheckInService;
|
||||
import org.alfresco.service.cmr.repository.DirectAccessUrl;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.security.AccessStatus;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
@@ -282,23 +278,6 @@ public class NodeVersionsRelation extends AbstractNodeRelation implements
|
||||
}
|
||||
}
|
||||
|
||||
@Operation("request-content-url")
|
||||
@WebApiParam(name = "directAccessUrlRequest", title = "Direct access url request", description = "Direct access url request", kind = ResourceParameter.KIND.HTTP_BODY_OBJECT)
|
||||
@WebApiDescription(title = "Request content url",
|
||||
description="Generates a direct access url.",
|
||||
successStatus = HttpServletResponse.SC_OK)
|
||||
public DirectAccessUrl requestContentUrl(String nodeId, String versionId, DirectAccessUrlRequest directAccessUrlRequest, Parameters parameters, WithResponse withResponse)
|
||||
{
|
||||
Version version = findVersion(nodeId, versionId);
|
||||
|
||||
if (version == null)
|
||||
{
|
||||
throw new EntityNotFoundException(nodeId + "-" + versionId);
|
||||
}
|
||||
|
||||
return nodes.requestContentUrl(version.getFrozenStateNodeRef(), directAccessUrlRequest);
|
||||
}
|
||||
|
||||
public Version findVersion(String nodeId, String versionLabelId)
|
||||
{
|
||||
NodeRef nodeRef = nodes.validateOrLookupNode(nodeId, null);
|
||||
|
@@ -32,13 +32,11 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import org.alfresco.rest.api.Nodes;
|
||||
import org.alfresco.rest.api.model.LockInfo;
|
||||
import org.alfresco.rest.api.model.Node;
|
||||
import org.alfresco.rest.api.model.DirectAccessUrlRequest;
|
||||
import org.alfresco.rest.api.model.NodeTarget;
|
||||
import org.alfresco.rest.framework.BinaryProperties;
|
||||
import org.alfresco.rest.framework.Operation;
|
||||
import org.alfresco.rest.framework.WebApiDescription;
|
||||
import org.alfresco.rest.framework.WebApiParam;
|
||||
import org.alfresco.rest.framework.core.ResourceParameter;
|
||||
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
|
||||
import org.alfresco.rest.framework.resource.EntityResource;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.BinaryResourceAction;
|
||||
@@ -47,7 +45,6 @@ import org.alfresco.rest.framework.resource.content.BasicContentInfo;
|
||||
import org.alfresco.rest.framework.resource.content.BinaryResource;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.rest.framework.webscripts.WithResponse;
|
||||
import org.alfresco.service.cmr.repository.DirectAccessUrl;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
@@ -192,15 +189,5 @@ public class NodesEntityResource implements
|
||||
return nodes.unlock(nodeId, parameters);
|
||||
}
|
||||
|
||||
@Operation("request-content-url")
|
||||
@WebApiParam(name = "directAccessUrlRequest", title = "Direct access url request", description = "Direct access url request", kind = ResourceParameter.KIND.HTTP_BODY_OBJECT)
|
||||
@WebApiDescription(title = "Request content url",
|
||||
description="Generates a direct access url.",
|
||||
successStatus = HttpServletResponse.SC_OK)
|
||||
public DirectAccessUrl requestContentUrl(String nodeId, DirectAccessUrlRequest directAccessUrlRequest, Parameters parameters, WithResponse withResponse)
|
||||
{
|
||||
return nodes.requestContentUrl(nodeId, directAccessUrlRequest);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -6,55 +6,119 @@
|
||||
* %%
|
||||
* 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
|
||||
* 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
|
||||
* 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.web.scripts.solr;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.web.scripts.solr.SOLRSerializer.SOLRTypeConverter;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.ISO8601DateFormat;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
public class SOLRSerializerTest
|
||||
{
|
||||
@Test
|
||||
@Test
|
||||
public void testDateSerializer()
|
||||
{
|
||||
SOLRTypeConverter typeConverter = new SOLRTypeConverter(null);
|
||||
|
||||
trip(typeConverter, "1912-01-01T00:40:00-06:00", "1912-01-01T06:40:00.000Z");
|
||||
trip(typeConverter, "1812-01-01T00:40:00-06:00", "1812-01-01T06:40:00.000Z");
|
||||
trip(typeConverter, "1845-01-01T00:40:00-06:00", "1845-01-01T06:40:00.000Z");
|
||||
trip(typeConverter, "1846-01-01T00:40:00-06:00", "1846-01-01T06:40:00.000Z");
|
||||
trip(typeConverter, "1847-01-01T00:40:00-06:00", "1847-01-01T06:40:00.000Z");
|
||||
trip(typeConverter, "1848-01-01T00:40:00-06:00", "1848-01-01T06:40:00.000Z");
|
||||
SOLRTypeConverter typeConverter = new SOLRTypeConverter(null);
|
||||
|
||||
trip(typeConverter, "1912-01-01T00:40:00-06:00", "1912-01-01T06:40:00.000Z");
|
||||
trip(typeConverter, "1812-01-01T00:40:00-06:00", "1812-01-01T06:40:00.000Z");
|
||||
trip(typeConverter, "1845-01-01T00:40:00-06:00", "1845-01-01T06:40:00.000Z");
|
||||
trip(typeConverter, "1846-01-01T00:40:00-06:00", "1846-01-01T06:40:00.000Z");
|
||||
trip(typeConverter, "1847-01-01T00:40:00-06:00", "1847-01-01T06:40:00.000Z");
|
||||
trip(typeConverter, "1848-01-01T00:40:00-06:00", "1848-01-01T06:40:00.000Z");
|
||||
|
||||
}
|
||||
|
||||
private void trip(SOLRTypeConverter typeConverter, String iso, String zulu)
|
||||
{
|
||||
Date testDate = ISO8601DateFormat.parse(iso);
|
||||
String strDate = typeConverter.INSTANCE.convert(String.class, testDate);
|
||||
assertEquals(zulu, strDate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test SOLR Serialization including values with special characters for ChildAssociationRef
|
||||
*/
|
||||
@Test
|
||||
public void testChildAssociationRefToJSONString()
|
||||
{
|
||||
SOLRSerializer solrSerializer = new SOLRSerializer();
|
||||
solrSerializer.setDictionaryService(Mockito.mock(DictionaryService.class));
|
||||
solrSerializer.setNamespaceService(Mockito.mock(NamespaceService.class));
|
||||
solrSerializer.init();
|
||||
|
||||
// Create a Child QName including special character \
|
||||
QName childQName = QName.createQName("hello", "wo\rld");
|
||||
|
||||
ChildAssociationRef childAssociationRef = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS,
|
||||
new NodeRef("workspace://SpacesStore/parent"), childQName,
|
||||
new NodeRef("workspace://SpacesStore/child"));
|
||||
String validJsonString = solrSerializer.serializeToJSONString(childAssociationRef);
|
||||
String jsonObjectString = String.format("{ \"key\": \"%s\" }", validJsonString);
|
||||
|
||||
try
|
||||
{
|
||||
new JSONObject(jsonObjectString);
|
||||
}
|
||||
catch (JSONException e)
|
||||
{
|
||||
assertTrue("JSON String " + jsonObjectString + " is not a valid JSON", false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test SOLR Serialization including values with special characters for AssociationRef
|
||||
*/
|
||||
@Test
|
||||
public void testAssociationRefToJSONString()
|
||||
{
|
||||
SOLRSerializer solrSerializer = new SOLRSerializer();
|
||||
solrSerializer.setDictionaryService(Mockito.mock(DictionaryService.class));
|
||||
solrSerializer.setNamespaceService(Mockito.mock(NamespaceService.class));
|
||||
solrSerializer.init();
|
||||
AssociationRef associationRef = new AssociationRef(
|
||||
new NodeRef("workspace://SpacesStore/wo\rld"),
|
||||
ContentModel.ASSOC_ATTACHMENTS,
|
||||
new NodeRef("workspace://SpacesStore/hello"));
|
||||
String validJsonString = solrSerializer.serializeToJSONString(associationRef);
|
||||
String jsonObjectString = String.format("{ \"key\": \"%s\" }", validJsonString);
|
||||
|
||||
try
|
||||
{
|
||||
new JSONObject(jsonObjectString);
|
||||
}
|
||||
catch (JSONException e)
|
||||
{
|
||||
assertTrue("JSON String " + jsonObjectString + " is not a valid JSON", false);
|
||||
}
|
||||
}
|
||||
|
||||
private void trip( SOLRTypeConverter typeConverter, String iso, String zulu)
|
||||
{
|
||||
Date testDate = ISO8601DateFormat.parse(iso);
|
||||
String strDate = typeConverter.INSTANCE.convert(String.class, testDate);
|
||||
assertEquals(zulu, strDate);
|
||||
}
|
||||
}
|
||||
|
@@ -51,7 +51,6 @@ import org.alfresco.rest.api.tests.client.data.ContentInfo;
|
||||
import org.alfresco.rest.api.tests.client.data.Document;
|
||||
import org.alfresco.rest.api.tests.client.data.Folder;
|
||||
import org.alfresco.rest.api.tests.client.data.Node;
|
||||
import org.alfresco.rest.api.tests.client.data.DirectAccessUrl;
|
||||
import org.alfresco.rest.api.tests.client.data.Rendition;
|
||||
import org.alfresco.rest.api.tests.client.data.SiteMember;
|
||||
import org.alfresco.rest.api.tests.client.data.SiteRole;
|
||||
@@ -847,30 +846,6 @@ public abstract class AbstractBaseApiTest extends EnterpriseTestApi
|
||||
return RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
|
||||
}
|
||||
|
||||
protected DirectAccessUrl requestContentUrl(String nodeId, String body, int expectedStatus) throws Exception
|
||||
{
|
||||
HttpResponse response = post(getNodeOperationUrl(nodeId, "request-content-url"), body, null, null, null, expectedStatus);
|
||||
|
||||
if (response.getJsonResponse().get("error") != null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return RestApiUtil.parseRestApiEntry(response.getJsonResponse(), DirectAccessUrl.class);
|
||||
}
|
||||
|
||||
protected DirectAccessUrl requestContentUrl(String nodeId, String versionId, String body, int expectedStatus) throws Exception
|
||||
{
|
||||
HttpResponse response = post(getNodeVersionsOperationUrl(nodeId, versionId, "request-content-url"), body, null, null, null, expectedStatus);
|
||||
|
||||
if (response.getJsonResponse().get("error") != null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return RestApiUtil.parseRestApiEntry(response.getJsonResponse(), DirectAccessUrl.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* This test helper method uses "update binary content" to create one or more new versions. The file must already exist.
|
||||
*
|
||||
@@ -1042,21 +1017,6 @@ public abstract class AbstractBaseApiTest extends EnterpriseTestApi
|
||||
return URL_NODES + "/" + nodeId + "/" + URL_RENDITIONS;
|
||||
}
|
||||
|
||||
protected String getNodeRenditionOperationUrl(String nodeId, String renditionId, String operation)
|
||||
{
|
||||
return URL_NODES + "/" + nodeId + "/" + URL_RENDITIONS+ "/" + renditionId + "/" + operation;
|
||||
}
|
||||
|
||||
protected String getNodeVersionsUrl(String nodeId, String versionId)
|
||||
{
|
||||
return URL_NODES + "/" + nodeId + "/" + URL_VERSIONS + "/" + versionId;
|
||||
}
|
||||
|
||||
protected String getNodeVersionsOperationUrl(String nodeId, String versionId, String operation)
|
||||
{
|
||||
return URL_NODES + "/" + nodeId + "/" + URL_VERSIONS + "/" + versionId + "/" + operation;
|
||||
}
|
||||
|
||||
protected String getNodeVersionsUrl(String nodeId)
|
||||
{
|
||||
return URL_NODES + "/" + nodeId + "/" + URL_VERSIONS;
|
||||
@@ -1067,11 +1027,6 @@ public abstract class AbstractBaseApiTest extends EnterpriseTestApi
|
||||
return URL_NODES + "/" + nodeId + "/" + URL_VERSIONS + "/" + versionId + "/" + URL_RENDITIONS;
|
||||
}
|
||||
|
||||
protected String getNodeVersionRenditionsOperationUrl(String nodeId, String versionId, String renditionId, String operation)
|
||||
{
|
||||
return URL_NODES + "/" + nodeId + "/" + URL_VERSIONS + "/" + versionId + "/" + URL_RENDITIONS + "/" + renditionId + "/" + operation;
|
||||
}
|
||||
|
||||
protected String getNodeChildrenUrl(String nodeId)
|
||||
{
|
||||
return URL_NODES + "/" + nodeId + "/" + URL_CHILDREN;
|
||||
|
@@ -76,7 +76,6 @@ import org.alfresco.rest.api.tests.client.PublicApiClient.Paging;
|
||||
import org.alfresco.rest.api.tests.client.PublicApiHttpClient.BinaryPayload;
|
||||
import org.alfresco.rest.api.tests.client.data.Association;
|
||||
import org.alfresco.rest.api.tests.client.data.ContentInfo;
|
||||
import org.alfresco.rest.api.tests.client.data.DirectAccessUrlRequest;
|
||||
import org.alfresco.rest.api.tests.client.data.Document;
|
||||
import org.alfresco.rest.api.tests.client.data.Folder;
|
||||
import org.alfresco.rest.api.tests.client.data.Node;
|
||||
@@ -103,7 +102,6 @@ import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.util.GUID;
|
||||
import org.alfresco.util.TempFileProvider;
|
||||
import org.apache.commons.collections.map.MultiValueMap;
|
||||
import org.joda.time.DateTime;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
@@ -4434,73 +4432,6 @@ public class NodeApiTest extends AbstractSingleNetworkSiteTest
|
||||
deleteNode(folderId);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRequestContentUrl() throws Exception
|
||||
{
|
||||
setRequestContext(user1);
|
||||
|
||||
// create folder
|
||||
Folder folderResp = createFolder(Nodes.PATH_MY, "folder" + RUNID);
|
||||
String folderId = folderResp.getId();
|
||||
|
||||
// create doc d1
|
||||
String d1Name = "content" + RUNID + "_1l";
|
||||
Document d1 = createTextFile(folderId, d1Name, "The quick brown fox jumps over the lazy dog 1.");
|
||||
String nodeId = d1.getId();
|
||||
|
||||
// node found but direct access isn't available
|
||||
requestContentUrl(nodeId, null, 501);
|
||||
|
||||
// unknown alias
|
||||
requestContentUrl("testSomeUndefinedAlias", null, 404);
|
||||
|
||||
// no content
|
||||
requestContentUrl(Nodes.PATH_MY, null, 400);
|
||||
requestContentUrl(Nodes.PATH_SHARED, null, 400);
|
||||
|
||||
{
|
||||
requestContentUrl(nodeId, toJsonAsStringNonNull(new DirectAccessUrlRequest()), 501);
|
||||
|
||||
{
|
||||
DirectAccessUrlRequest directAccessUrlRequest = new DirectAccessUrlRequest();
|
||||
directAccessUrlRequest.setExpiresAt(DateTime.now().plusSeconds(30).toDate());
|
||||
directAccessUrlRequest.setValidFor(60L);
|
||||
|
||||
requestContentUrl(nodeId, toJsonAsStringNonNull(directAccessUrlRequest), 400);
|
||||
}
|
||||
|
||||
{
|
||||
DirectAccessUrlRequest directAccessUrlRequest = new DirectAccessUrlRequest();
|
||||
directAccessUrlRequest.setValidFor(60L);
|
||||
|
||||
requestContentUrl(nodeId, toJsonAsStringNonNull(directAccessUrlRequest), 501);
|
||||
}
|
||||
|
||||
{
|
||||
DirectAccessUrlRequest directAccessUrlRequest = new DirectAccessUrlRequest();
|
||||
directAccessUrlRequest.setValidFor(-60L);
|
||||
|
||||
requestContentUrl(nodeId, toJsonAsStringNonNull(directAccessUrlRequest), 400);
|
||||
}
|
||||
|
||||
{
|
||||
DirectAccessUrlRequest directAccessUrlRequest = new DirectAccessUrlRequest();
|
||||
directAccessUrlRequest.setExpiresAt(DateTime.now().plusSeconds(30).toDate());
|
||||
requestContentUrl(nodeId, toJsonAsStringNonNull(directAccessUrlRequest), 501);
|
||||
}
|
||||
|
||||
{
|
||||
DirectAccessUrlRequest directAccessUrlRequest = new DirectAccessUrlRequest();
|
||||
directAccessUrlRequest.setExpiresAt(DateTime.now().minusSeconds(30).toDate());
|
||||
requestContentUrl(nodeId, toJsonAsStringNonNull(directAccessUrlRequest), 400);
|
||||
}
|
||||
}
|
||||
|
||||
// node not accessible
|
||||
setRequestContext(user2);
|
||||
requestContentUrl(nodeId, null, 403);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMoveFileCreatedByDeletedUser() throws Exception
|
||||
{
|
||||
|
@@ -31,17 +31,14 @@ import org.alfresco.rest.AbstractSingleNetworkSiteTest;
|
||||
import org.alfresco.rest.api.tests.client.HttpResponse;
|
||||
import org.alfresco.rest.api.tests.client.PublicApiClient.Paging;
|
||||
import org.alfresco.rest.api.tests.client.data.ContentInfo;
|
||||
import org.alfresco.rest.api.tests.client.data.DirectAccessUrlRequest;
|
||||
import org.alfresco.rest.api.tests.client.data.Document;
|
||||
import org.alfresco.rest.api.tests.client.data.Node;
|
||||
import org.alfresco.rest.api.tests.client.data.Rendition;
|
||||
import org.alfresco.rest.api.tests.util.RestApiUtil;
|
||||
import static org.alfresco.rest.api.tests.util.RestApiUtil.toJsonAsString;
|
||||
|
||||
import static org.alfresco.rest.api.tests.util.RestApiUtil.toJsonAsStringNonNull;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.*;
|
||||
@@ -369,112 +366,4 @@ public class NodeVersionRenditionsApiTest extends AbstractSingleNetworkSiteTest
|
||||
{
|
||||
return "public";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRequestContentUrl() throws Exception
|
||||
{
|
||||
setRequestContext(user1);
|
||||
|
||||
String myFolderNodeId = getMyNodeId();
|
||||
|
||||
// create folder
|
||||
String f1Id = createFolder(myFolderNodeId, "f1").getId();
|
||||
|
||||
try
|
||||
{
|
||||
int verCnt = 1;
|
||||
int cnt = 1;
|
||||
String versionLabel = "1.0";
|
||||
|
||||
String textContentSuffix = "Amazingly few discotheques provide jukeboxes ";
|
||||
String contentName = "content-2-" + System.currentTimeMillis();
|
||||
String content = textContentSuffix + cnt;
|
||||
|
||||
// request minor version on upload (& no pre-request for renditions for live node)
|
||||
Boolean majorVersion = true;
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("majorVersion", majorVersion.toString());
|
||||
|
||||
// create a new file
|
||||
Document documentResp = createTextFile(f1Id, contentName, content, "UTF-8", params);
|
||||
String docId = documentResp.getId();
|
||||
assertTrue(documentResp.getAspectNames().contains("cm:versionable"));
|
||||
assertNotNull(documentResp.getProperties());
|
||||
assertEquals(versionLabel, documentResp.getProperties().get("cm:versionLabel"));
|
||||
|
||||
cnt = 2;
|
||||
versionLabel = updateFileVersions(user1, docId, cnt, textContentSuffix, verCnt, majorVersion, versionLabel);
|
||||
verCnt = verCnt+cnt;
|
||||
|
||||
assertEquals("3.0", versionLabel);
|
||||
assertEquals(3, verCnt);
|
||||
|
||||
// check version history count
|
||||
HttpResponse response = getAll(getNodeVersionsUrl(docId), null, null, 200);
|
||||
List<Node> nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
|
||||
assertEquals(verCnt, nodes.size());
|
||||
|
||||
// pause briefly
|
||||
Thread.sleep(DELAY_IN_MS);
|
||||
|
||||
// found but direct access isn't available
|
||||
checkCreateAndGetVersionRendition(docId, "1.0", "doclib");
|
||||
post(getNodeVersionRenditionsOperationUrl(docId, "1.0", "doclib", "request-content-url"), null, null, 501);
|
||||
|
||||
checkCreateAndGetVersionRendition(docId, "3.0", "doclib");
|
||||
post(getNodeVersionRenditionsOperationUrl(docId, "3.0", "doclib", "request-content-url"), null, null, 501);
|
||||
|
||||
checkCreateAndGetVersionRendition(docId, "2.0", "doclib");
|
||||
post(getNodeVersionRenditionsOperationUrl(docId, "2.0", "doclib", "request-content-url"), null, null, 501);
|
||||
|
||||
{
|
||||
post(getNodeVersionRenditionsOperationUrl(docId, "2.0", "doclib", "request-content-url"), toJsonAsStringNonNull(new DirectAccessUrlRequest()), null, null, null,
|
||||
501);
|
||||
|
||||
{
|
||||
DirectAccessUrlRequest directAccessUrlRequest = new DirectAccessUrlRequest();
|
||||
directAccessUrlRequest.setExpiresAt(DateTime.now().plusSeconds(30).toDate());
|
||||
directAccessUrlRequest.setValidFor(60L);
|
||||
|
||||
post(getNodeVersionRenditionsOperationUrl(docId, "2.0", "doclib", "request-content-url"), toJsonAsStringNonNull(directAccessUrlRequest), null, null, null, 400);
|
||||
}
|
||||
|
||||
{
|
||||
DirectAccessUrlRequest directAccessUrlRequest = new DirectAccessUrlRequest();
|
||||
directAccessUrlRequest.setValidFor(60L);
|
||||
|
||||
post(getNodeVersionRenditionsOperationUrl(docId, "2.0", "doclib", "request-content-url"), toJsonAsStringNonNull(directAccessUrlRequest), null, null, null, 501);
|
||||
}
|
||||
|
||||
{
|
||||
DirectAccessUrlRequest directAccessUrlRequest = new DirectAccessUrlRequest();
|
||||
directAccessUrlRequest.setValidFor(-60L);
|
||||
|
||||
post(getNodeVersionRenditionsOperationUrl(docId, "2.0", "doclib", "request-content-url"), toJsonAsStringNonNull(directAccessUrlRequest), null, null, null, 400);
|
||||
}
|
||||
|
||||
{
|
||||
DirectAccessUrlRequest directAccessUrlRequest = new DirectAccessUrlRequest();
|
||||
directAccessUrlRequest.setExpiresAt(DateTime.now().plusSeconds(30).toDate());
|
||||
post(getNodeVersionRenditionsOperationUrl(docId, "2.0", "doclib", "request-content-url"), toJsonAsStringNonNull(directAccessUrlRequest), null, null, null, 501);
|
||||
}
|
||||
|
||||
{
|
||||
DirectAccessUrlRequest directAccessUrlRequest = new DirectAccessUrlRequest();
|
||||
directAccessUrlRequest.setExpiresAt(DateTime.now().minusSeconds(30).toDate());
|
||||
post(getNodeVersionRenditionsOperationUrl(docId, "2.0", "doclib", "request-content-url"), toJsonAsStringNonNull(directAccessUrlRequest), null, null, null, 400);
|
||||
}
|
||||
}
|
||||
|
||||
// also live node
|
||||
checkCreateAndGetVersionRendition(docId, null, "doclib");
|
||||
post(getNodeVersionRenditionsOperationUrl(docId, null, "doclib", "request-content-url"), null, null, 501);
|
||||
}
|
||||
finally
|
||||
{
|
||||
// some cleanup
|
||||
setRequestContext(user1);
|
||||
deleteNode(f1Id, true, 204);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -33,13 +33,11 @@ import org.alfresco.rest.api.tests.client.HttpResponse;
|
||||
import org.alfresco.rest.api.tests.client.PublicApiClient;
|
||||
import org.alfresco.rest.api.tests.client.PublicApiClient.Paging;
|
||||
import org.alfresco.rest.api.tests.client.PublicApiHttpClient;
|
||||
import org.alfresco.rest.api.tests.client.data.DirectAccessUrlRequest;
|
||||
import org.alfresco.rest.api.tests.client.data.Document;
|
||||
import org.alfresco.rest.api.tests.client.data.Node;
|
||||
import org.alfresco.rest.api.tests.util.RestApiUtil;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.alfresco.util.TempFileProvider;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
@@ -1319,91 +1317,6 @@ public class NodeVersionsApiTest extends AbstractSingleNetworkSiteTest
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRequestContentUrl() throws Exception
|
||||
{
|
||||
// create folder
|
||||
setRequestContext(user1);
|
||||
|
||||
String f1Id = null;
|
||||
|
||||
try
|
||||
{
|
||||
f1Id = createFolder(Nodes.PATH_MY, "testRequestContentUrl-f1").getId();
|
||||
|
||||
String textContentSuffix = "Amazingly few discotheques provide jukeboxes ";
|
||||
String contentName = "content-1";
|
||||
|
||||
int cnt = 6;
|
||||
Pair<String, String> pair = uploadTextFileVersions(user1, f1Id, contentName, cnt, textContentSuffix, 0, null, null);
|
||||
String versionLabel = pair.getFirst();
|
||||
String docId = pair.getSecond();
|
||||
|
||||
assertEquals("1.5", versionLabel); // 1.0, 1.1, ... 1.5
|
||||
|
||||
// node and version found but direct access isn't available
|
||||
requestContentUrl(docId, "1.2", null,501);
|
||||
requestContentUrl(docId, "1.5", null,501);
|
||||
|
||||
// node not found
|
||||
requestContentUrl("testSomeUndefinedAlias", "1.6", null,404);
|
||||
|
||||
// version not found
|
||||
requestContentUrl(docId, "1.6", null,404);
|
||||
|
||||
{
|
||||
requestContentUrl(docId, "1.5", toJsonAsStringNonNull(new DirectAccessUrlRequest()), 501);
|
||||
|
||||
{
|
||||
DirectAccessUrlRequest directAccessUrlRequest = new DirectAccessUrlRequest();
|
||||
directAccessUrlRequest.setExpiresAt(DateTime.now().plusSeconds(30).toDate());
|
||||
directAccessUrlRequest.setValidFor(60L);
|
||||
|
||||
requestContentUrl(docId, "1.5", toJsonAsStringNonNull(directAccessUrlRequest), 400);
|
||||
}
|
||||
|
||||
{
|
||||
DirectAccessUrlRequest directAccessUrlRequest = new DirectAccessUrlRequest();
|
||||
directAccessUrlRequest.setValidFor(60L);
|
||||
|
||||
requestContentUrl(docId, "1.5", toJsonAsStringNonNull(directAccessUrlRequest), 501);
|
||||
}
|
||||
|
||||
{
|
||||
DirectAccessUrlRequest directAccessUrlRequest = new DirectAccessUrlRequest();
|
||||
directAccessUrlRequest.setValidFor(-60L);
|
||||
|
||||
requestContentUrl(docId, "1.5", toJsonAsStringNonNull(directAccessUrlRequest), 400);
|
||||
}
|
||||
|
||||
{
|
||||
DirectAccessUrlRequest directAccessUrlRequest = new DirectAccessUrlRequest();
|
||||
directAccessUrlRequest.setExpiresAt(DateTime.now().plusSeconds(30).toDate());
|
||||
requestContentUrl(docId, "1.5", toJsonAsStringNonNull(directAccessUrlRequest), 501);
|
||||
}
|
||||
|
||||
{
|
||||
DirectAccessUrlRequest directAccessUrlRequest = new DirectAccessUrlRequest();
|
||||
directAccessUrlRequest.setExpiresAt(DateTime.now().minusSeconds(30).toDate());
|
||||
requestContentUrl(docId, "1.5", toJsonAsStringNonNull(directAccessUrlRequest), 400);
|
||||
}
|
||||
}
|
||||
|
||||
// node not accessible
|
||||
setRequestContext(user2);
|
||||
requestContentUrl(docId, "1.5", null,403);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (f1Id != null)
|
||||
{
|
||||
// some cleanup
|
||||
setRequestContext(user1);
|
||||
deleteNode(f1Id, true, 204);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getScope()
|
||||
{
|
||||
|
@@ -27,7 +27,6 @@
|
||||
package org.alfresco.rest.api.tests;
|
||||
|
||||
import static org.alfresco.rest.api.tests.util.RestApiUtil.toJsonAsString;
|
||||
import static org.alfresco.rest.api.tests.util.RestApiUtil.toJsonAsStringNonNull;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
@@ -47,7 +46,6 @@ import org.alfresco.rest.api.tests.client.PublicApiClient.ExpectedErrorResponse;
|
||||
import org.alfresco.rest.api.tests.client.PublicApiClient.ExpectedPaging;
|
||||
import org.alfresco.rest.api.tests.client.PublicApiClient.Paging;
|
||||
import org.alfresco.rest.api.tests.client.data.ContentInfo;
|
||||
import org.alfresco.rest.api.tests.client.data.DirectAccessUrlRequest;
|
||||
import org.alfresco.rest.api.tests.client.data.Document;
|
||||
import org.alfresco.rest.api.tests.client.data.Rendition;
|
||||
import org.alfresco.rest.api.tests.client.data.Rendition.RenditionStatus;
|
||||
@@ -59,7 +57,6 @@ import org.alfresco.service.cmr.repository.ContentService;
|
||||
import org.alfresco.service.cmr.site.SiteVisibility;
|
||||
import org.alfresco.service.cmr.thumbnail.ThumbnailService;
|
||||
import org.alfresco.util.TempFileProvider;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -974,121 +971,4 @@ public class RenditionsTest extends AbstractBaseApiTest
|
||||
return synchronousTransformClient.isSupported(MimetypeMap.MIMETYPE_WORD, -1, null,
|
||||
MimetypeMap.MIMETYPE_PDF, Collections.emptyMap(), null, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRequestContentUrl() throws Exception
|
||||
{
|
||||
setRequestContext(networkN1.getId(), userOneN1.getId(), null);
|
||||
|
||||
// Create a folder within the site document's library
|
||||
String folderName = "folder" + System.currentTimeMillis();
|
||||
String folder_Id = addToDocumentLibrary(userOneN1Site, folderName, TYPE_CM_FOLDER, userOneN1.getId());
|
||||
|
||||
// Create multipart request
|
||||
String fileName = "quick.pdf";
|
||||
File file = getResourceFile(fileName);
|
||||
MultiPartBuilder multiPartBuilder = MultiPartBuilder.create().setFileData(new FileData(fileName, file));
|
||||
MultiPartRequest reqBody = multiPartBuilder.build();
|
||||
|
||||
// Upload quick.pdf file into 'folder'
|
||||
HttpResponse response = post(getNodeChildrenUrl(folder_Id), reqBody.getBody(), null, reqBody.getContentType(), 201);
|
||||
Document document = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
|
||||
String contentNodeId = document.getId();
|
||||
|
||||
// pause briefly
|
||||
Thread.sleep(DELAY_IN_MS);
|
||||
|
||||
// Get rendition (not created yet) information for node
|
||||
response = getSingle(getNodeRenditionsUrl(contentNodeId), "doclib", 200);
|
||||
Rendition rendition = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Rendition.class);
|
||||
assertNotNull(rendition);
|
||||
assertEquals(RenditionStatus.NOT_CREATED, rendition.getStatus());
|
||||
|
||||
// the rendition hasn't been created yet
|
||||
post(getNodeRenditionOperationUrl(contentNodeId, rendition.getId(), "request-content-url"), null, null, 404);
|
||||
|
||||
// Create and get 'doclib' rendition
|
||||
rendition = createAndGetRendition(contentNodeId, "doclib");
|
||||
assertNotNull(rendition);
|
||||
assertEquals(RenditionStatus.CREATED, rendition.getStatus());
|
||||
|
||||
// found but direct access isn't available
|
||||
post(getNodeRenditionOperationUrl(contentNodeId, rendition.getId(), "request-content-url"), null, null, 501);
|
||||
|
||||
{
|
||||
post(getNodeRenditionOperationUrl(contentNodeId, rendition.getId(), "request-content-url"), toJsonAsStringNonNull(new DirectAccessUrlRequest()), null, null, null, 501);
|
||||
|
||||
{
|
||||
DirectAccessUrlRequest directAccessUrlRequest = new DirectAccessUrlRequest();
|
||||
directAccessUrlRequest.setExpiresAt(DateTime.now().plusSeconds(30).toDate());
|
||||
directAccessUrlRequest.setValidFor(60L);
|
||||
|
||||
post(getNodeRenditionOperationUrl(contentNodeId, rendition.getId(), "request-content-url"), toJsonAsStringNonNull(directAccessUrlRequest), null, null, null, 400);
|
||||
}
|
||||
|
||||
{
|
||||
DirectAccessUrlRequest directAccessUrlRequest = new DirectAccessUrlRequest();
|
||||
directAccessUrlRequest.setValidFor(60L);
|
||||
|
||||
post(getNodeRenditionOperationUrl(contentNodeId, rendition.getId(), "request-content-url"), toJsonAsStringNonNull(directAccessUrlRequest), null, null, null, 501);
|
||||
}
|
||||
|
||||
{
|
||||
DirectAccessUrlRequest directAccessUrlRequest = new DirectAccessUrlRequest();
|
||||
directAccessUrlRequest.setValidFor(-60L);
|
||||
|
||||
post(getNodeRenditionOperationUrl(contentNodeId, rendition.getId(), "request-content-url"), toJsonAsStringNonNull(directAccessUrlRequest), null, null, null, 400);
|
||||
}
|
||||
|
||||
{
|
||||
DirectAccessUrlRequest directAccessUrlRequest = new DirectAccessUrlRequest();
|
||||
directAccessUrlRequest.setExpiresAt(DateTime.now().plusSeconds(30).toDate());
|
||||
post(getNodeRenditionOperationUrl(contentNodeId, rendition.getId(), "request-content-url"), toJsonAsStringNonNull(directAccessUrlRequest), null, null, null, 501);
|
||||
}
|
||||
|
||||
{
|
||||
DirectAccessUrlRequest directAccessUrlRequest = new DirectAccessUrlRequest();
|
||||
directAccessUrlRequest.setExpiresAt(DateTime.now().minusSeconds(30).toDate());
|
||||
post(getNodeRenditionOperationUrl(contentNodeId, rendition.getId(), "request-content-url"), toJsonAsStringNonNull(directAccessUrlRequest), null, null, null, 400);
|
||||
}
|
||||
}
|
||||
|
||||
// nodeId in the path parameter does not represent a file
|
||||
post(getNodeRenditionOperationUrl(folder_Id, "doclib", "request-content-url"), null, null, 400);
|
||||
|
||||
// nodeId in the path parameter does not exist
|
||||
post(getNodeRenditionOperationUrl(UUID.randomUUID().toString(), "doclib", "request-content-url"), null, null, 404);
|
||||
|
||||
// renditionId in the path parameter is not registered/available
|
||||
post(getNodeRenditionOperationUrl(contentNodeId, ("renditionId" + System.currentTimeMillis()), "request-content-url"), null, null, 404);
|
||||
|
||||
// Create a node without any content. Test only if OpenOffice is available
|
||||
if (isOpenOfficeAvailable())
|
||||
{
|
||||
String emptyContentNodeId = addToDocumentLibrary(userOneN1Site, "emptyDoc.txt", TYPE_CM_CONTENT, userOneN1.getId());
|
||||
getSingle(getNodeRenditionsUrl(emptyContentNodeId), "doclib", 200);
|
||||
}
|
||||
|
||||
// Create multipart request
|
||||
String jpgFileName = "quick.jpg";
|
||||
File jpgFile = getResourceFile(fileName);
|
||||
reqBody = MultiPartBuilder.create().setFileData(new FileData(jpgFileName, jpgFile)).build();
|
||||
|
||||
// Upload quick.jpg file into 'folder'
|
||||
response = post(getNodeChildrenUrl(folder_Id), reqBody.getBody(), null, reqBody.getContentType(), 201);
|
||||
Document jpgImage = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
|
||||
String jpgImageNodeId = jpgImage.getId();
|
||||
|
||||
// List all available renditions (includes those that have been created and
|
||||
// those that are yet to be created)
|
||||
response = getAll(getNodeRenditionsUrl(jpgImageNodeId), getPaging(0, 50), 200);
|
||||
List<Rendition> renditions = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Rendition.class);
|
||||
// Check there is no pdf rendition is available for the jpg file
|
||||
Rendition pdf = getRendition(renditions, "pdf");
|
||||
assertNull(pdf);
|
||||
|
||||
// The renditionId (pdf) is registered but it is not applicable for the node's
|
||||
// mimeType
|
||||
post(getNodeRenditionOperationUrl(jpgImageNodeId, "pdf", "request-content-url"), null, null, 404);
|
||||
}
|
||||
}
|
||||
|
@@ -1,49 +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.rest.api.tests.client.data;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Represents a direct access content url.
|
||||
*
|
||||
*/
|
||||
public class DirectAccessUrl extends org.alfresco.service.cmr.repository.DirectAccessUrl implements Serializable, ExpectedComparison
|
||||
{
|
||||
|
||||
@Override
|
||||
public void expected(Object o)
|
||||
{
|
||||
assertTrue("o is an instance of " + o.getClass(), o instanceof DirectAccessUrl);
|
||||
|
||||
DirectAccessUrl other = (DirectAccessUrl) o;
|
||||
|
||||
AssertUtil.assertEquals("contentUrl", getContentUrl(), other.getContentUrl());
|
||||
}
|
||||
|
||||
}
|
@@ -1,50 +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.rest.api.tests.client.data;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Represents a direct access url request.
|
||||
*
|
||||
*/
|
||||
public class DirectAccessUrlRequest extends org.alfresco.rest.api.model.DirectAccessUrlRequest implements Serializable, ExpectedComparison
|
||||
{
|
||||
|
||||
@Override
|
||||
public void expected(Object o)
|
||||
{
|
||||
assertTrue("o is an instance of " + o.getClass(), o instanceof DirectAccessUrlRequest);
|
||||
|
||||
DirectAccessUrlRequest other = (DirectAccessUrlRequest) o;
|
||||
|
||||
AssertUtil.assertEquals("expiresAt", getExpiresAt(), other.getExpiresAt());
|
||||
AssertUtil.assertEquals("validFor", getValidFor(), other.getValidFor());
|
||||
}
|
||||
|
||||
}
|
@@ -1,41 +0,0 @@
|
||||
### Alfresco Repository
|
||||
[](https://travis-ci.com/Alfresco/alfresco-repository)
|
||||
|
||||
Repository is a library packaged as a jar file which is part of [Alfresco Content Services Repository](https://community.alfresco.com/docs/DOC-6385-project-overview-repository).
|
||||
The library contains the following:
|
||||
* DAOs and SQL scripts
|
||||
* Various Service implementations
|
||||
* Utility classes
|
||||
|
||||
### Building and testing
|
||||
The project can be built by running Maven command:
|
||||
~~~
|
||||
mvn clean install
|
||||
~~~
|
||||
The tests are combined in test classes split by test type or Spring application context used in the test, see classes in _src/test/java/org/alfresco_. All of these classes as well as individual tests can be run by specifying the test class name and a set of DB connection properties, for example:
|
||||
~~~
|
||||
mvn clean test -Dtest=SomeRepoTest -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql:alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
||||
~~~
|
||||
|
||||
### Artifacts
|
||||
The artifacts can be obtained by:
|
||||
* downloading from [Alfresco repository](https://artifacts.alfresco.com/nexus/content/groups/public)
|
||||
* getting as Maven dependency by adding the dependency to your pom file:
|
||||
~~~
|
||||
<dependency>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-repository</artifactId>
|
||||
<version>version</version>
|
||||
</dependency>
|
||||
~~~
|
||||
and Alfresco Maven repository:
|
||||
~~~
|
||||
<repository>
|
||||
<id>alfresco-maven-repo</id>
|
||||
<url>https://artifacts.alfresco.com/nexus/content/groups/public</url>
|
||||
</repository>
|
||||
~~~
|
||||
The SNAPSHOT version of the artifact is **never** published.
|
||||
|
||||
### Contributing guide
|
||||
Please use [this guide](CONTRIBUTING.md) to make a contribution to the project.
|
@@ -142,7 +142,7 @@
|
||||
<dependency>
|
||||
<groupId>org.mozilla</groupId>
|
||||
<artifactId>rhino</artifactId>
|
||||
<version>1.7.12</version>
|
||||
<version>1.7.13</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
@@ -276,7 +276,6 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.pdfbox</groupId>
|
||||
<artifactId>pdfbox</artifactId>
|
||||
<version>${dependency.pdfbox.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.pdfbox</groupId>
|
||||
@@ -1068,7 +1067,6 @@
|
||||
<dependency>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-pdf-renderer</artifactId>
|
||||
<version>${dependency.alfresco-pdf-renderer.version}</version>
|
||||
<classifier>win64</classifier>
|
||||
<type>tgz</type>
|
||||
</dependency>
|
||||
@@ -1113,7 +1111,6 @@
|
||||
<dependency>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-pdf-renderer</artifactId>
|
||||
<version>${dependency.alfresco-pdf-renderer.version}</version>
|
||||
<classifier>linux</classifier>
|
||||
<type>tgz</type>
|
||||
</dependency>
|
||||
@@ -1150,54 +1147,6 @@
|
||||
<alfresco-pdf-renderer.exe>${project.build.directory}/test-binaries/alfresco-pdf-renderer/alfresco-pdf-renderer</alfresco-pdf-renderer.exe>
|
||||
</properties>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>osx-alfresco-pdf-renderer-test</id>
|
||||
<activation>
|
||||
<os>
|
||||
<family>mac</family>
|
||||
</os>
|
||||
</activation>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-pdf-renderer</artifactId>
|
||||
<version>${dependency.alfresco-pdf-renderer.version}</version>
|
||||
<classifier>osx</classifier>
|
||||
<type>tgz</type>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<inherited>false</inherited>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>extract-alfresco-pdf-renderer-test</id>
|
||||
<phase>generate-test-resources</phase>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<skip>${skipTests}</skip>
|
||||
<target>
|
||||
<echo message="Extracting alfresco-pdf-renderer (OS-X) for testing..." />
|
||||
<mkdir dir="${project.build.directory}/test-binaries/alfresco-pdf-renderer" />
|
||||
<exec failonerror="true" executable="tar" dir="${project.build.directory}/test-binaries/alfresco-pdf-renderer">
|
||||
<arg value="xf" />
|
||||
<arg value="${settings.localRepository}/org/alfresco/alfresco-pdf-renderer/${dependency.alfresco-pdf-renderer.version}/alfresco-pdf-renderer-${dependency.alfresco-pdf-renderer.version}-osx.tgz" />
|
||||
</exec>
|
||||
</target>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<properties>
|
||||
<alfresco-pdf-renderer.exe>${project.build.directory}/test-binaries/alfresco-pdf-renderer/alfresco-pdf-renderer</alfresco-pdf-renderer.exe>
|
||||
</properties>
|
||||
</profile>
|
||||
|
||||
</profiles>
|
||||
|
||||
|
@@ -81,22 +81,19 @@ public class TransactionAwareHolder<T> extends Holder<T>
|
||||
{
|
||||
this.internalHolder = internalHolder;
|
||||
this.value = internalHolder.getValue();
|
||||
txListener = new TxAwareHolderListener();
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getValue()
|
||||
{
|
||||
if (TransactionSynchronizationManager.isSynchronizationActive())
|
||||
{
|
||||
AlfrescoTransactionSupport.bindListener(txListener);
|
||||
}
|
||||
registerTxListenerIfNeeded();
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(T value)
|
||||
{
|
||||
registerTxListenerIfNeeded();
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@@ -109,6 +106,17 @@ public class TransactionAwareHolder<T> extends Holder<T>
|
||||
'}';
|
||||
}
|
||||
|
||||
// MNT-21800 CMIS Web Service Check Out returns error
|
||||
private void registerTxListenerIfNeeded()
|
||||
{
|
||||
if (this.txListener == null && TransactionSynchronizationManager.isSynchronizationActive())
|
||||
{
|
||||
TxAwareHolderListener listener = new TxAwareHolderListener();
|
||||
AlfrescoTransactionSupport.bindListener(listener);
|
||||
this.txListener = listener;
|
||||
}
|
||||
}
|
||||
|
||||
private class TxAwareHolderListener extends TransactionListenerAdapter
|
||||
{
|
||||
@Override
|
||||
|
@@ -430,8 +430,8 @@ public class ADMAccessControlListDAO implements AccessControlListDAO
|
||||
// {
|
||||
// setFixedAcls(child.getId(), inheritFrom, mergeFrom, sharedAclToReplace, changes, false);
|
||||
// }
|
||||
// Already replaced
|
||||
if(acl.equals(sharedAclToReplace))
|
||||
// Still has old shared ACL or already replaced
|
||||
if(acl.equals(sharedAclToReplace) || acl.equals(mergeFrom))
|
||||
{
|
||||
propagateOnChildren = setFixAclPending(child.getId(), inheritFrom, mergeFrom, sharedAclToReplace, changes, false, asyncCall, propagateOnChildren);
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
||||
* Copyright (C) 2005 - 2020 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
@@ -25,11 +25,11 @@
|
||||
*/
|
||||
package org.alfresco.repo.security.permissions.impl;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.locks.ReadWriteLock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.Pair;
|
||||
|
||||
/**
|
||||
* A simple permission reference.
|
||||
@@ -40,59 +40,27 @@ public final class SimplePermissionReference extends AbstractPermissionReference
|
||||
{
|
||||
private static final long serialVersionUID = 637302438293417818L;
|
||||
|
||||
private static ReadWriteLock lock = new ReentrantReadWriteLock();
|
||||
|
||||
private static HashMap<QName, HashMap<String, SimplePermissionReference>> instances = new HashMap<QName, HashMap<String, SimplePermissionReference>>();
|
||||
//Use thread-safe map initiallized with a slightly larger capacity to reduce the posibility of two or more threads attempting to resize at the same time
|
||||
private static ConcurrentMap<Pair<QName, String>, SimplePermissionReference> instances = new ConcurrentHashMap<>(100, 0.9f, 2);
|
||||
|
||||
/**
|
||||
* Factory method to create simple permission refrences
|
||||
* Factory method to create simple permission references
|
||||
*
|
||||
* @return a simple permission reference
|
||||
*/
|
||||
public static SimplePermissionReference getPermissionReference(QName qName, String name)
|
||||
{
|
||||
lock.readLock().lock();
|
||||
try
|
||||
{
|
||||
HashMap<String, SimplePermissionReference> typed = instances.get(qName);
|
||||
if(typed != null)
|
||||
Pair<QName, String> key = new Pair<>(qName, name);
|
||||
SimplePermissionReference instance = instances.get(key);
|
||||
if (instance == null)
|
||||
{
|
||||
SimplePermissionReference instance = typed.get(name);
|
||||
if(instance != null)
|
||||
{
|
||||
return instance;
|
||||
}
|
||||
instance = new SimplePermissionReference(qName, name);
|
||||
instances.putIfAbsent(key, instance);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
lock.readLock().unlock();
|
||||
}
|
||||
|
||||
lock.writeLock().lock();
|
||||
try
|
||||
{
|
||||
HashMap<String, SimplePermissionReference> typed = instances.get(qName);
|
||||
if(typed == null)
|
||||
{
|
||||
typed = new HashMap<String, SimplePermissionReference>();
|
||||
instances.put(qName, typed);
|
||||
}
|
||||
SimplePermissionReference instance = typed.get(name);
|
||||
if(instance == null)
|
||||
{
|
||||
instance = new SimplePermissionReference(qName, name);
|
||||
typed.put(name, instance);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
finally
|
||||
{
|
||||
lock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* The type
|
||||
*/
|
||||
|
@@ -690,20 +690,18 @@ public class SOLRTrackingComponentImpl implements SearchTrackingComponent
|
||||
return new ArrayList<Long>(visited);
|
||||
}
|
||||
|
||||
|
||||
/** Get properties that we want to be indexed. */
|
||||
protected Map<QName, Serializable> getProperties(Long nodeId)
|
||||
{
|
||||
Map<QName, Serializable> props = null;
|
||||
|
||||
// ALF-10641
|
||||
// Residual properties are un-indexed -> break serlialisation
|
||||
// Residual properties are un-indexed -> break serialisation
|
||||
nodeDAO.setCheckNodeConsistency();
|
||||
Map<QName, Serializable> sourceProps = nodeDAO.getNodeProperties(nodeId);
|
||||
props = new HashMap<QName, Serializable>((int)(sourceProps.size() * 1.3));
|
||||
Map<QName, Serializable> props = new HashMap<>(sourceProps.size());
|
||||
for(QName propertyQName : sourceProps.keySet())
|
||||
{
|
||||
PropertyDefinition propDef = dictionaryService.getProperty(propertyQName);
|
||||
if(propDef != null)
|
||||
if(propDef != null && propDef.isIndexed())
|
||||
{
|
||||
props.put(propertyQName, sourceProps.get(propertyQName));
|
||||
}
|
||||
|
@@ -169,7 +169,9 @@ CREATE TABLE alf_transaction
|
||||
change_txn_id VARCHAR(56) NOT NULL,
|
||||
commit_time_ms BIGINT,
|
||||
PRIMARY KEY (id),
|
||||
KEY idx_alf_txn_ctms (commit_time_ms)
|
||||
KEY idx_alf_txn_ctms (commit_time_ms, id),
|
||||
KEY idx_alf_txn_ctms_sc (commit_time_ms),
|
||||
key idx_alf_txn_id_ctms (id, commit_time_ms)
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
CREATE TABLE alf_store
|
||||
@@ -210,6 +212,8 @@ CREATE TABLE alf_node
|
||||
KEY idx_alf_node_crd (audit_created, store_id, type_qname_id),
|
||||
KEY idx_alf_node_mor (audit_modifier, store_id, type_qname_id),
|
||||
KEY idx_alf_node_mod (audit_modified, store_id, type_qname_id),
|
||||
KEY idx_alf_node_ver (version),
|
||||
KEY idx_alf_node_txn (transaction_id),
|
||||
CONSTRAINT fk_alf_node_acl FOREIGN KEY (acl_id) REFERENCES alf_access_control_list (id),
|
||||
CONSTRAINT fk_alf_node_store FOREIGN KEY (store_id) REFERENCES alf_store (id),
|
||||
CONSTRAINT fk_alf_node_tqn FOREIGN KEY (type_qname_id) REFERENCES alf_qname (id),
|
||||
|
@@ -1681,6 +1681,16 @@
|
||||
<columnname>type_qname_id</columnname>
|
||||
</columnnames>
|
||||
</index>
|
||||
<index name="idx_alf_node_ver" unique="false">
|
||||
<columnnames>
|
||||
<columnname>version</columnname>
|
||||
</columnnames>
|
||||
</index>
|
||||
<index name="idx_alf_node_txn" unique="false">
|
||||
<columnnames>
|
||||
<columnname>transaction_id</columnname>
|
||||
</columnnames>
|
||||
</index>
|
||||
</indexes>
|
||||
</table>
|
||||
<table name="alf_node_aspects">
|
||||
@@ -2630,6 +2640,18 @@
|
||||
<index name="idx_alf_txn_ctms" unique="false">
|
||||
<columnnames>
|
||||
<columnname>commit_time_ms</columnname>
|
||||
<columnname>id</columnname>
|
||||
</columnnames>
|
||||
</index>
|
||||
<index name="idx_alf_txn_ctms_sc" unique="false">
|
||||
<columnnames>
|
||||
<columnname>commit_time_ms</columnname>
|
||||
</columnnames>
|
||||
</index>
|
||||
<index name="idx_alf_txn_id_ctms" unique="false">
|
||||
<columnnames>
|
||||
<columnname>id</columnname>
|
||||
<columnname>commit_time_ms</columnname>
|
||||
</columnnames>
|
||||
</index>
|
||||
</indexes>
|
||||
|
@@ -184,6 +184,8 @@ CREATE TABLE alf_transaction
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
CREATE INDEX idx_alf_txn_ctms ON alf_transaction (commit_time_ms, id);
|
||||
CREATE INDEX idx_alf_txn_ctms_sc ON alf_transaction (commit_time_ms);
|
||||
CREATE INDEX idx_alf_txn_id_ctms ON alf_transaction (id, commit_time_ms);
|
||||
|
||||
CREATE SEQUENCE alf_store_seq START WITH 1 INCREMENT BY 1;
|
||||
CREATE TABLE alf_store
|
||||
@@ -231,6 +233,8 @@ CREATE INDEX fk_alf_node_acl ON alf_node (acl_id);
|
||||
CREATE INDEX fk_alf_node_store ON alf_node (store_id);
|
||||
CREATE INDEX idx_alf_node_tqn ON alf_node (type_qname_id, store_id, id);
|
||||
CREATE INDEX fk_alf_node_loc ON alf_node (locale_id);
|
||||
CREATE INDEX idx_alf_node_ver ON alf_node (version);
|
||||
CREATE INDEX idx_alf_node_txn ON alf_node (transaction_id);
|
||||
|
||||
CREATE INDEX fk_alf_store_root ON alf_store (root_node_id);
|
||||
ALTER TABLE alf_store ADD CONSTRAINT fk_alf_store_root FOREIGN KEY (root_node_id) REFERENCES alf_node (id);
|
||||
|
@@ -1739,6 +1739,16 @@
|
||||
<columnname>id</columnname>
|
||||
</columnnames>
|
||||
</index>
|
||||
<index name="idx_alf_node_ver" unique="false">
|
||||
<columnnames>
|
||||
<columnname>version</columnname>
|
||||
</columnnames>
|
||||
</index>
|
||||
<index name="idx_alf_node_txn" unique="false">
|
||||
<columnnames>
|
||||
<columnname>transaction_id</columnname>
|
||||
</columnnames>
|
||||
</index>
|
||||
</indexes>
|
||||
</table>
|
||||
<table name="alf_node_aspects">
|
||||
@@ -2703,6 +2713,17 @@
|
||||
<columnname>id</columnname>
|
||||
</columnnames>
|
||||
</index>
|
||||
<index name="idx_alf_txn_ctms_sc" unique="false">
|
||||
<columnnames>
|
||||
<columnname>commit_time_ms</columnname>
|
||||
</columnnames>
|
||||
</index>
|
||||
<index name="idx_alf_txn_id_ctms" unique="false">
|
||||
<columnnames>
|
||||
<columnname>id</columnname>
|
||||
<columnname>commit_time_ms</columnname>
|
||||
</columnnames>
|
||||
</index>
|
||||
</indexes>
|
||||
</table>
|
||||
<table name="alf_usage_delta">
|
||||
|
@@ -55,6 +55,7 @@
|
||||
<ref bean="patch.db-V5.2-remove-jbpm-tables-from-db" />
|
||||
<ref bean="patch.db-V6.0-change-set-indexes" />
|
||||
<ref bean="patch.db-V6.3-remove-alf_server-table" />
|
||||
<ref bean="patch.db-V6.3-add-indexes-node-transaction" />
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
@@ -0,0 +1,35 @@
|
||||
--
|
||||
-- Title: Update alf_node and alf_transaction indexes for more performance
|
||||
-- Database: MySQL
|
||||
-- Since: V6.3
|
||||
-- Author: Eva Vasques
|
||||
--
|
||||
-- Please contact support@alfresco.com if you need assistance with the upgrade.
|
||||
--
|
||||
|
||||
DROP INDEX idx_alf_node_ver; --(optional)
|
||||
CREATE INDEX idx_alf_node_ver ON alf_node (version);
|
||||
|
||||
DROP INDEX idx_alf_node_txn; --(optional)
|
||||
CREATE INDEX idx_alf_node_txn ON alf_node (transaction_id);
|
||||
|
||||
DROP INDEX idx_alf_txn_ctms; --(optional)
|
||||
CREATE INDEX idx_alf_txn_ctms ON alf_transaction (commit_time_ms, id);
|
||||
|
||||
DROP INDEX idx_alf_txn_ctms_sc; --(optional)
|
||||
CREATE INDEX idx_alf_txn_ctms_sc ON alf_transaction (commit_time_ms);
|
||||
|
||||
DROP INDEX idx_alf_txn_id_ctms; --(optional)
|
||||
CREATE INDEX idx_alf_txn_id_ctms ON alf_transaction (id, commit_time_ms);
|
||||
|
||||
--
|
||||
-- Record script finish
|
||||
--
|
||||
DELETE FROM alf_applied_patch WHERE id = 'patch.db-V6.3-add-indexes-node-transaction';
|
||||
INSERT INTO alf_applied_patch
|
||||
(id, description, fixes_from_schema, fixes_to_schema, applied_to_schema, target_schema, applied_on_date, applied_to_server, was_executed, succeeded, report)
|
||||
VALUES
|
||||
(
|
||||
'patch.db-V6.3-add-indexes-node-transaction', 'Create aditional indexes on alf_node and alf_transaction',
|
||||
0, 14001, -1, 14002, null, 'UNKNOWN', ${TRUE}, ${TRUE}, 'Script completed'
|
||||
);
|
@@ -0,0 +1,32 @@
|
||||
--
|
||||
-- Title: Update alf_node and alf_transaction indexes for more performance
|
||||
-- Database: PostgreSQL
|
||||
-- Since: V6.3
|
||||
-- Author: Eva Vasques
|
||||
--
|
||||
-- Please contact support@alfresco.com if you need assistance with the upgrade.
|
||||
--
|
||||
|
||||
DROP INDEX idx_alf_node_ver; --(optional)
|
||||
CREATE INDEX idx_alf_node_ver ON alf_node (version);
|
||||
|
||||
DROP INDEX idx_alf_node_txn; --(optional)
|
||||
CREATE INDEX idx_alf_node_txn ON alf_node (transaction_id);
|
||||
|
||||
DROP INDEX idx_alf_txn_ctms_sc; --(optional)
|
||||
CREATE INDEX idx_alf_txn_ctms_sc ON alf_transaction (commit_time_ms);
|
||||
|
||||
DROP INDEX idx_alf_txn_id_ctms; --(optional)
|
||||
CREATE INDEX idx_alf_txn_id_ctms ON alf_transaction (id, commit_time_ms);
|
||||
|
||||
--
|
||||
-- Record script finish
|
||||
--
|
||||
DELETE FROM alf_applied_patch WHERE id = 'patch.db-V6.3-add-indexes-node-transaction';
|
||||
INSERT INTO alf_applied_patch
|
||||
(id, description, fixes_from_schema, fixes_to_schema, applied_to_schema, target_schema, applied_on_date, applied_to_server, was_executed, succeeded, report)
|
||||
VALUES
|
||||
(
|
||||
'patch.db-V6.3-add-indexes-node-transaction', 'Create aditional indexes on alf_node and alf_transaction',
|
||||
0, 14001, -1, 14002, null, 'UNKNOWN', ${TRUE}, ${TRUE}, 'Script completed'
|
||||
);
|
@@ -403,3 +403,5 @@ patch.db-V5.2-remove-jbpm-tables-from-db.description=Removes all JBPM related ta
|
||||
patch.db-V6.0-change-set-indexes.description=Add additional indexes to support acl tracking.
|
||||
|
||||
patch.db-V6.3-remove-alf_server-table.description=Remove alf_server table.
|
||||
|
||||
patch.db-V6.3-add-indexes-node-transaction.description=Create additional indexes on alf_node and alf_transaction
|
@@ -1408,4 +1408,16 @@
|
||||
<value>classpath:alfresco/dbscripts/upgrade/6.3/${db.script.dialect}/remove-alf_server-table.sql</value>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="patch.db-V6.3-add-indexes-node-transaction" class="org.alfresco.repo.admin.patch.impl.SchemaUpgradeScriptPatch" parent="basePatch">
|
||||
<property name="id"><value>patch.db-V6.3-add-indexes-node-transaction</value></property>
|
||||
<property name="description"><value>patch.db-V6.3-add-indexes-node-transaction.description</value></property>
|
||||
<property name="fixesFromSchema"><value>0</value></property>
|
||||
<property name="fixesToSchema"><value>14001</value></property>
|
||||
<property name="targetSchema"><value>14002</value></property>
|
||||
<property name="ignored"><value>${system.new-node-transaction-indexes.ignored}</value></property>
|
||||
<property name="scriptUrl">
|
||||
<value>classpath:alfresco/dbscripts/upgrade/6.3/${db.script.dialect}/add-indexes-node-transaction.sql</value>
|
||||
</property>
|
||||
</bean>
|
||||
</beans>
|
||||
|
@@ -3,7 +3,7 @@
|
||||
repository.name=Main Repository
|
||||
|
||||
# Schema number
|
||||
version.schema=14001
|
||||
version.schema=14002
|
||||
|
||||
# Directory configuration
|
||||
|
||||
@@ -1333,3 +1333,6 @@ system.prop_table_cleaner.algorithm=V2
|
||||
# Configure the expiration time of the direct access url. This is the length of time in seconds that the link is valid for.
|
||||
# Note: It is up to the actual ContentStore implementation if it can fulfil this request or not.
|
||||
alfresco.content.directAccessUrl.lifetimeInSec=300
|
||||
|
||||
# Creates additional indexes on alf_node and alf_transaction. Recommended for large repositories.
|
||||
system.new-node-transaction-indexes.ignored=true
|
@@ -153,18 +153,15 @@
|
||||
</bean>
|
||||
|
||||
<bean id="solrAdminClient" class="org.alfresco.repo.solr.SOLRAdminClient" init-method="init">
|
||||
<property name="solrHost" value="${solr.host}"/>
|
||||
<property name="solrPort" value="${solr.port}"/>
|
||||
<property name="solrsslPort" value="${solr.port.ssl}"/>
|
||||
<property name="solrUser" value="${solr.solrUser}"/>
|
||||
<property name="solrPassword" value="${solr.solrPassword}"/>
|
||||
<property name="solrPingCronExpression" value="${solr.solrPingCronExpression}"/>
|
||||
<property name="solrConnectTimeout" value="${solr.solrConnectTimeout}"/>
|
||||
<property name="httpClientFactory" ref="solrHttpClientFactory"/>
|
||||
<property name="baseUrl" value="${solr.baseUrl}"/>
|
||||
<property name="scheduler">
|
||||
<ref bean="searchSchedulerFactory" />
|
||||
</property>
|
||||
<property name="storeMappings">
|
||||
<ref bean="solr4.store.mappings" />
|
||||
</property>
|
||||
<property name="useDynamicShardRegistration" value="${solr.useDynamicShardRegistration}" />
|
||||
</bean>
|
||||
|
||||
|
||||
|
@@ -25,7 +25,10 @@
|
||||
*/
|
||||
package org.alfresco.repo.domain.permissions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
@@ -41,6 +44,7 @@ import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransacti
|
||||
import org.alfresco.repo.transaction.TransactionListenerAdapter;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
@@ -69,6 +73,7 @@ public class FixedAclUpdaterTest extends TestCase
|
||||
private Repository repository;
|
||||
private FixedAclUpdater fixedAclUpdater;
|
||||
private NodeRef folderAsyncCallNodeRef;
|
||||
private NodeRef folderAsyncCallWithCreateNodeRef;
|
||||
private NodeRef folderSyncCallNodeRef;
|
||||
private PermissionsDaoComponent permissionsDaoComponent;
|
||||
private PermissionService permissionService;
|
||||
@@ -100,6 +105,10 @@ public class FixedAclUpdaterTest extends TestCase
|
||||
filesPerLevel);
|
||||
folderSyncCallNodeRef = txnHelper.doInTransaction(cb2);
|
||||
|
||||
RetryingTransactionCallback<NodeRef> cb3 = createFolderHierchyCallback(home, fileFolderService,
|
||||
"rootFolderAsyncWithCreateCall", filesPerLevel);
|
||||
folderAsyncCallWithCreateNodeRef = txnHelper.doInTransaction(cb3);
|
||||
|
||||
// change setFixedAclMaxTransactionTime to lower value so setInheritParentPermissions on created folder
|
||||
// hierarchy require async call
|
||||
setFixedAclMaxTransactionTime(permissionsDaoComponent, home, 50);
|
||||
@@ -147,8 +156,10 @@ public class FixedAclUpdaterTest extends TestCase
|
||||
aspect.add(ContentModel.ASPECT_TEMPORARY);
|
||||
nodeDAO.addNodeAspects(nodeDAO.getNodePair(folderAsyncCallNodeRef).getFirst(), aspect);
|
||||
nodeDAO.addNodeAspects(nodeDAO.getNodePair(folderSyncCallNodeRef).getFirst(), aspect);
|
||||
nodeDAO.addNodeAspects(nodeDAO.getNodePair(folderAsyncCallWithCreateNodeRef).getFirst(), aspect);
|
||||
fileFolderService.delete(folderAsyncCallNodeRef);
|
||||
fileFolderService.delete(folderSyncCallNodeRef);
|
||||
fileFolderService.delete(folderAsyncCallWithCreateNodeRef);
|
||||
return null;
|
||||
}, false, true);
|
||||
}
|
||||
@@ -189,7 +200,34 @@ public class FixedAclUpdaterTest extends TestCase
|
||||
testWork(folderAsyncCallNodeRef, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAsyncWithNodeCreation()
|
||||
{
|
||||
testWorkWithNodeCreation(folderAsyncCallWithCreateNodeRef, true);
|
||||
}
|
||||
|
||||
private void testWork(NodeRef folderRef, boolean asyncCall)
|
||||
{
|
||||
setPermissionsOnTree(folderRef, asyncCall);
|
||||
triggerFixedACLJob(folderRef);
|
||||
}
|
||||
|
||||
private void testWorkWithNodeCreation(NodeRef folderRef, boolean asyncCall)
|
||||
{
|
||||
setPermissionsOnTree(folderRef, asyncCall);
|
||||
|
||||
// MNT-21847 - Create a new content in folder that has the aspect applied
|
||||
txnHelper.doInTransaction((RetryingTransactionCallback<Void>) () -> {
|
||||
NodeRef folderWithPendingAcl = getFirstFolderWithAclPending(folderRef);
|
||||
assertNotNull("No children folders were found with pendingFixACl aspect", folderWithPendingAcl);
|
||||
createFile(fileFolderService, folderWithPendingAcl, "NewFile", ContentModel.TYPE_CONTENT);
|
||||
return null;
|
||||
}, false, true);
|
||||
|
||||
triggerFixedACLJob(folderRef);
|
||||
}
|
||||
|
||||
private void setPermissionsOnTree(NodeRef folderRef, boolean asyncCall)
|
||||
{
|
||||
// kick it off by setting inherit parent permissions == false
|
||||
txnHelper.doInTransaction((RetryingTransactionCallback<Void>) () -> {
|
||||
@@ -203,21 +241,61 @@ public class FixedAclUpdaterTest extends TestCase
|
||||
assertTrue("There are no nodes to process", getNodesCountWithPendingFixedAclAspect() > 0);
|
||||
return null;
|
||||
}, false, true);
|
||||
}
|
||||
|
||||
// run the fixedAclUpdater until there is nothing more to fix (running the updater
|
||||
// may create more to fix up)
|
||||
private void triggerFixedACLJob(NodeRef folder)
|
||||
{
|
||||
// run the fixedAclUpdater until there is nothing more to fix (running the updater may create more to fix up) or
|
||||
// the count doesn't change, meaning we have a problem.
|
||||
txnHelper.doInTransaction((RetryingTransactionCallback<Void>) () -> {
|
||||
int count = 0;
|
||||
int previousCount = 0;
|
||||
do
|
||||
{
|
||||
previousCount = count;
|
||||
count = fixedAclUpdater.execute();
|
||||
} while (count > 0);
|
||||
} while (count > 0 && previousCount != count);
|
||||
return null;
|
||||
}, false, true);
|
||||
|
||||
// check if nodes with ASPECT_PENDING_FIX_ACL are processed
|
||||
txnHelper.doInTransaction((RetryingTransactionCallback<Void>) () -> {
|
||||
assertEquals("Not all nodes were processed", 0, getNodesCountWithPendingFixedAclAspect());
|
||||
//Remove the tree that failed so it does not influence the other test results
|
||||
removeNodesWithPendingAcl(folder);
|
||||
return null;
|
||||
}, false, true);
|
||||
}
|
||||
|
||||
private NodeRef getFirstFolderWithAclPending(NodeRef parentNodeRef)
|
||||
{
|
||||
NodeRef folderWithPendingFixedAcl = null;
|
||||
List<FileInfo> primaryChildFolders = fileFolderService.listFolders(parentNodeRef);
|
||||
for (int i = 0; i < primaryChildFolders.size(); i++)
|
||||
{
|
||||
NodeRef thisChildFolder = primaryChildFolders.get(i).getNodeRef();
|
||||
Long thisChildNodeId = nodeDAO.getNodePair(thisChildFolder).getFirst();
|
||||
if (nodeDAO.hasNodeAspect(thisChildNodeId, ContentModel.ASPECT_PENDING_FIX_ACL))
|
||||
{
|
||||
folderWithPendingFixedAcl = thisChildFolder;
|
||||
break;
|
||||
}
|
||||
|
||||
if (folderWithPendingFixedAcl == null)
|
||||
{
|
||||
folderWithPendingFixedAcl = getFirstFolderWithAclPending(thisChildFolder);
|
||||
}
|
||||
}
|
||||
return folderWithPendingFixedAcl;
|
||||
}
|
||||
|
||||
private void removeNodesWithPendingAcl(NodeRef folder)
|
||||
{
|
||||
txnHelper.doInTransaction((RetryingTransactionCallback<Void>) () -> {
|
||||
Set<QName> aspect = new HashSet<>();
|
||||
aspect.add(ContentModel.ASPECT_TEMPORARY);
|
||||
nodeDAO.addNodeAspects(nodeDAO.getNodePair(folder).getFirst(), aspect);
|
||||
fileFolderService.delete(folder);
|
||||
return null;
|
||||
}, false, true);
|
||||
}
|
||||
|
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* 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.solr;
|
||||
|
||||
import static java.util.Collections.emptyMap;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.mockito.MockitoAnnotations.initMocks;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.repo.domain.node.NodeDAO;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
|
||||
/** Unit tests for {@link org.alfresco.repo.solr.SOLRTrackingComponent}. */
|
||||
public class SOLRTrackingComponentUnitTest
|
||||
{
|
||||
/** A pair of QNames for use in the tests. */
|
||||
private static final QName FIRST_PROPERTY = QName.createQName("the://first/property");
|
||||
private static final QName SECOND_PROPERTY = QName.createQName("the://second/property");
|
||||
/** A node id for use in the tests. */
|
||||
private static final long NODE_ID = 123L;
|
||||
|
||||
/** The class under test. */
|
||||
@InjectMocks
|
||||
private SOLRTrackingComponentImpl solrTrackingComponent;
|
||||
@Mock
|
||||
private NodeDAO nodeDAO;
|
||||
@Mock
|
||||
private DictionaryService dictionaryService;
|
||||
|
||||
@Before
|
||||
public void setUp()
|
||||
{
|
||||
initMocks(this);
|
||||
}
|
||||
|
||||
/** Check that properties of different types can be returned. */
|
||||
@Test
|
||||
public void testGetProperties_indexedPropertiesPassedThrough()
|
||||
{
|
||||
Map<QName, Serializable> propertiesFromDB = Map.of(FIRST_PROPERTY, "value1", SECOND_PROPERTY, 2);
|
||||
when(nodeDAO.getNodeProperties(NODE_ID)).thenReturn(propertiesFromDB);
|
||||
PropertyDefinition firstDefinition = mock(PropertyDefinition.class);
|
||||
when(firstDefinition.isIndexed()).thenReturn(true);
|
||||
when(dictionaryService.getProperty(FIRST_PROPERTY)).thenReturn(firstDefinition);
|
||||
PropertyDefinition secondDefinition = mock(PropertyDefinition.class);
|
||||
when(secondDefinition.isIndexed()).thenReturn(true);
|
||||
when(dictionaryService.getProperty(SECOND_PROPERTY)).thenReturn(secondDefinition);
|
||||
|
||||
Map<QName, Serializable> properties = solrTrackingComponent.getProperties(NODE_ID);
|
||||
|
||||
assertEquals("Expected both properties to be returned.", propertiesFromDB, properties);
|
||||
}
|
||||
|
||||
/** Check that a property is not indexed if it is not registered in the dictionary service. */
|
||||
@Test
|
||||
public void testGetProperties_propertyWithoutModelIsNotIndexed()
|
||||
{
|
||||
Map<QName, Serializable> propertiesFromDB = Map.of(FIRST_PROPERTY, "value1");
|
||||
when(nodeDAO.getNodeProperties(NODE_ID)).thenReturn(propertiesFromDB);
|
||||
when(dictionaryService.getProperty(FIRST_PROPERTY)).thenReturn(null);
|
||||
|
||||
Map<QName, Serializable> properties = solrTrackingComponent.getProperties(NODE_ID);
|
||||
|
||||
assertEquals("Expected residual property to be skipped.", emptyMap(), properties);
|
||||
}
|
||||
|
||||
/** Check that a property is not indexed if the model contains <index enabled="false"/> */
|
||||
@Test
|
||||
public void testGetProperties_propertySkippedIfIndexFalseSet()
|
||||
{
|
||||
Map<QName, Serializable> propertiesFromDB = Map.of(FIRST_PROPERTY, "value1");
|
||||
when(nodeDAO.getNodeProperties(NODE_ID)).thenReturn(propertiesFromDB);
|
||||
PropertyDefinition firstDefinition = mock(PropertyDefinition.class);
|
||||
when(firstDefinition.isIndexed()).thenReturn(false);
|
||||
when(dictionaryService.getProperty(FIRST_PROPERTY)).thenReturn(firstDefinition);
|
||||
|
||||
Map<QName, Serializable> properties = solrTrackingComponent.getProperties(NODE_ID);
|
||||
|
||||
assertEquals("Unexpected property when index enabled set to false.", emptyMap(), properties);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user