Skip to content

Commit a7948d8

Browse files
Upgrade to Alfresco SDK 2.1.1
Define “Dictionary” site preset to avoid site name customization in properties file.
1 parent dbfc4ab commit a7948d8

File tree

16 files changed

+323
-235
lines changed

16 files changed

+323
-235
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
alfresco-datalist-constraints
22
=============================
33

4-
Use datalists to maintain Alfresco model constraints:
4+
Use datalists to maintain Alfresco model constraints.
5+
6+
Version 1.0.0 instructions:
57

68
1. Deploy repo and share AMPs to Alfresco 4.2 CE
79
2. Create a new site named "Administration"

datalist-model-repo/pom.xml

Lines changed: 100 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,103 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4-
5-
<parent>
6-
<artifactId>alfresco-datalist</artifactId>
7-
<groupId>es.keensoft</groupId>
8-
<version>1.0.0</version>
9-
</parent>
10-
11-
<modelVersion>4.0.0</modelVersion>
12-
<artifactId>datalist-model-repo</artifactId>
13-
<packaging>amp</packaging>
14-
<name>Alfresco components :: DataList Model</name>
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>es.keensoft</groupId>
6+
<artifactId>datalist-model-repo</artifactId>
7+
<version>2.0.0</version>
8+
<name>datalist-model-repo Repository AMP project</name>
9+
<packaging>amp</packaging>
10+
<description>Manages the lifecycle of the site-props-repo Repository AMP (Alfresco Module Package)</description>
11+
12+
<parent>
13+
<groupId>org.alfresco.maven</groupId>
14+
<artifactId>alfresco-sdk-parent</artifactId>
15+
<version>2.1.1</version>
16+
</parent>
17+
18+
<!--
19+
SDK properties have sensible defaults in the SDK parent,
20+
but you can override the properties below to use another version.
21+
For more available properties see the alfresco-sdk-parent POM.
22+
-->
23+
<properties>
24+
<!-- The following are default values for data location and Alfresco Community version.
25+
Uncomment if you need to change (Note. current default version for Enterprise edition is 5.0.1)
26+
<alfresco.version>5.0.d</alfresco.version>
27+
<alfresco.data.location>/absolute/path/to/alf_data_dev</alfresco.data.location> -->
28+
29+
<!-- This control the root logging level for all apps uncomment and change, defaults to WARN
30+
<app.log.root.level>WARN</app.log.root.level>
31+
-->
32+
33+
<!-- Set the enviroment to use, this controls which properties will be picked in src/test/properties
34+
for embedded run, defaults to the 'local' environment. See SDK Parent POM for more info.
35+
<env>local</env>
36+
-->
37+
</properties>
38+
39+
<!-- Here we realize the connection with the Alfresco selected platform
40+
(e.g.version and edition) -->
41+
<dependencyManagement>
42+
<dependencies>
43+
<!-- Setup what versions of the different Alfresco artifacts that will be used (depends on alfresco.version),
44+
so we don't have to specify version in any of the dependency definitions in our POM.
45+
For more info see:
46+
http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Importing_Dependencies
47+
-->
48+
<dependency>
49+
<groupId>${alfresco.groupId}</groupId>
50+
<artifactId>alfresco-platform-distribution</artifactId>
51+
<version>${alfresco.version}</version>
52+
<type>pom</type>
53+
<scope>import</scope>
54+
</dependency>
55+
</dependencies>
56+
</dependencyManagement>
57+
58+
<dependencies>
59+
<!-- Following dependencies are needed for compiling Java code in src/main/java;
60+
<scope>provided</scope> is inherited for each of the following;
61+
for more info, please refer to alfresco-platform-distribution POM -->
62+
<dependency>
63+
<groupId>${alfresco.groupId}</groupId>
64+
<artifactId>alfresco-repository</artifactId>
65+
</dependency>
66+
</dependencies>
67+
68+
<profiles>
69+
<!--
70+
Brings in the extra Enterprise specific repository classes,
71+
if the 'enterprise' profile has been activated, needs to be activated manually.
72+
-->
73+
<profile>
74+
<id>enterprise</id>
75+
<dependencies>
76+
<dependency>
77+
<groupId>${alfresco.groupId}</groupId>
78+
<artifactId>alfresco-enterprise-repository</artifactId>
79+
<version>${alfresco.version}</version>
80+
<scope>provided</scope>
81+
</dependency>
82+
</dependencies>
83+
</profile>
84+
85+
<!--
86+
If the 'amp-to-war' profile is enabled then make sure to bring in the alfresco-rad module,
87+
which has the H2 scripts and other RAD features.
88+
89+
TODO: TO INVESTIGATE: This dependency is already defined in the parent SDK pom in the 'amp-to-war' profile
90+
but this does not work, it is not include...
91+
92+
<profile>
93+
<id>amp-to-war</id>
94+
<dependencies>
95+
<dependency>
96+
<groupId>org.alfresco.maven</groupId>
97+
<artifactId>alfresco-rad</artifactId>
98+
<version>${maven.alfresco.version}</version>
99+
</dependency>
100+
</dependencies>
101+
</profile> -->
102+
</profiles>
15103
</project>

datalist-model-repo/src/main/amp/config/alfresco/extension/datalist-model-context.xml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,22 @@
77
<property name="models">
88
<list>
99
<value>alfresco/extension/model/datalist-model.xml</value>
10-
<value>alfresco/extension/model/custom-model.xml</value>
1110
</list>
1211
</property>
1312
</bean>
1413
<bean id="extension.dlm.resourceBundle" class="org.alfresco.i18n.ResourceBundleBootstrapComponent">
1514
<property name="resourceBundles">
1615
<list>
1716
<value>alfresco.messages.datalist-model</value>
18-
<value>alfresco.messages.custom-model</value>
1917
</list>
2018
</property>
2119
</bean>
2220

23-
<bean id="webscript.es.keensoft.datalist.datalist.get"
24-
class="es.keensoft.alfresco.action.webscript.DataListWebScript" parent="webscript">
21+
<bean id="webscript.es.keensoft.datalist.datalist.get" class="es.keensoft.alfresco.action.webscript.DataListWebScript" parent="webscript">
2522
<property name="nodeService" ref="NodeService"/>
2623
<property name="siteService" ref="SiteService"/>
2724
<property name="transactionService" ref="TransactionService" />
2825
<property name="taggingService" ref="TaggingService" />
29-
<!-- TODO Customize this value with Site shortname used to manage option lists -->
30-
<property name="publicSiteName" value="administration" />
3126
</bean>
3227

3328
</beans>

datalist-model-repo/src/main/amp/config/alfresco/extension/model/custom-model.xml

Lines changed: 0 additions & 35 deletions
This file was deleted.

datalist-model-repo/src/main/amp/config/alfresco/messages/custom-model.properties

Lines changed: 0 additions & 1 deletion
This file was deleted.

datalist-model-repo/src/main/java/es/keensoft/alfresco/action/webscript/DataListWebScript.java

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import org.alfresco.service.cmr.repository.ChildAssociationRef;
99
import org.alfresco.service.cmr.repository.NodeRef;
1010
import org.alfresco.service.cmr.repository.NodeService;
11+
import org.alfresco.service.cmr.site.SiteInfo;
1112
import org.alfresco.service.cmr.site.SiteService;
1213
import org.alfresco.service.cmr.tagging.TaggingService;
1314
import org.alfresco.service.namespace.RegexQNamePattern;
@@ -26,12 +27,12 @@ public class DataListWebScript extends AbstractWebScript {
2627
private static final String JSON_VALUE = "value";
2728

2829
private static final String DATALIST_CONTAINER_ID = "dataLists";
30+
private static final String DATALIST_PRESET = "datalist-site-dashboard";
2931

3032
private NodeService nodeService;
3133
private SiteService siteService;
3234
private TransactionService transactionService;
3335
private TaggingService taggingService;
34-
private String publicSiteName;
3536

3637
@Override
3738
public void execute(WebScriptRequest request, WebScriptResponse response) throws IOException {
@@ -41,33 +42,38 @@ public void execute(WebScriptRequest request, WebScriptResponse response) throws
4142
JSONArray objProcess = new JSONArray();
4243

4344
try {
44-
45-
NodeRef dataListContainer = SiteServiceImpl.getSiteContainer(publicSiteName, DATALIST_CONTAINER_ID, true, siteService, transactionService, taggingService);
46-
List<ChildAssociationRef> dataListsNodes = nodeService.getChildAssocs(dataListContainer);
47-
48-
for (ChildAssociationRef dataList : dataListsNodes) {
45+
46+
List<SiteInfo> sites = siteService.listSites(null, DATALIST_PRESET);
47+
48+
for (SiteInfo site : sites) {
49+
50+
NodeRef dataListContainer = SiteServiceImpl.getSiteContainer(site.getShortName(), DATALIST_CONTAINER_ID, true, siteService, transactionService, taggingService);
51+
List<ChildAssociationRef> dataListsNodes = nodeService.getChildAssocs(dataListContainer);
4952

50-
if (dataList.getTypeQName().isMatch(ContentModel.ASSOC_CONTAINS)) {
53+
for (ChildAssociationRef dataList : dataListsNodes) {
5154

52-
if (nodeService.getProperty(dataList.getChildRef(), ContentModel.PROP_TITLE).toString().equals(targetedDataListName)) {
55+
if (dataList.getTypeQName().isMatch(ContentModel.ASSOC_CONTAINS)) {
5356

54-
List<ChildAssociationRef> itemsNodes = nodeService.getChildAssocs(dataList.getChildRef(), ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);
55-
56-
for (ChildAssociationRef item : itemsNodes) {
57-
58-
if (nodeService.getType(item.getChildRef()).isMatch(DatalistModel.DATALIST_MODEL_ITEM_TYPE)) {
59-
JSONObject obj = new JSONObject();
60-
obj.put(JSON_CODE, nodeService.getProperty(item.getChildRef(), DatalistModel.DATALIST_MODEL_CODE_PROPERTY).toString());
61-
obj.put(JSON_VALUE, nodeService.getProperty(item.getChildRef(), DatalistModel.DATALIST_MODEL_VALUE_PROPERTY).toString());
62-
objProcess.put(obj);
63-
} else {
64-
// Ignore other datalist types
65-
continue;
66-
}
67-
}
57+
if (nodeService.getProperty(dataList.getChildRef(), ContentModel.PROP_TITLE).toString().equals(targetedDataListName)) {
58+
59+
List<ChildAssociationRef> itemsNodes = nodeService.getChildAssocs(dataList.getChildRef(), ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);
60+
61+
for (ChildAssociationRef item : itemsNodes) {
62+
63+
if (nodeService.getType(item.getChildRef()).isMatch(DatalistModel.DATALIST_MODEL_ITEM_TYPE)) {
64+
JSONObject obj = new JSONObject();
65+
obj.put(JSON_CODE, nodeService.getProperty(item.getChildRef(), DatalistModel.DATALIST_MODEL_CODE_PROPERTY).toString());
66+
obj.put(JSON_VALUE, nodeService.getProperty(item.getChildRef(), DatalistModel.DATALIST_MODEL_VALUE_PROPERTY).toString());
67+
objProcess.put(obj);
68+
} else {
69+
// Ignore other datalist types
70+
continue;
71+
}
72+
}
73+
74+
}
6875

6976
}
70-
7177
}
7278

7379
}
@@ -90,10 +96,6 @@ public void setSiteService(SiteService siteService) {
9096
this.siteService = siteService;
9197
}
9298

93-
public void setPublicSiteName(String publicSiteName) {
94-
this.publicSiteName = publicSiteName;
95-
}
96-
9799
public void setTransactionService(TransactionService transactionService) {
98100
this.transactionService = transactionService;
99101
}

datalist-model-repo/src/main/java/es/keensoft/alfresco/model/DatalistModel.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,4 @@ public class DatalistModel {
99
public static final QName DATALIST_MODEL_VALUE_PROPERTY = QName.createQName(DATALIST_MODEL_URI, "value");
1010
public static final QName DATALIST_MODEL_ITEM_TYPE = QName.createQName(DATALIST_MODEL_URI, "optionList");
1111

12-
public static final String CUSTOM_MODEL_URI = "http://www.alfresco.com/model/keensoft/1.0";
13-
public static final QName CUSTOM_MODEL_SAMPLE_ASPECT = QName.createQName(CUSTOM_MODEL_URI, "sample");
14-
public static final QName CUSTOM_MODEL_OPTION_PROPERTY = QName.createQName(CUSTOM_MODEL_URI, "option");
15-
public static final QName CUSTOM_MODEL_ANOTHER_OPTION_PROPERTY = QName.createQName(CUSTOM_MODEL_URI, "anotherOption");
16-
1712
}

0 commit comments

Comments
 (0)