Skip to content

Commit 9ddb148

Browse files
author
Nathan McMinn
committed
Merge branch 'pr/19'
Merging changes to support SDK 2.2 / Alf 5.1.e
2 parents e5c62b7 + ed80e92 commit 9ddb148

File tree

18 files changed

+478
-184
lines changed

18 files changed

+478
-184
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ alf_data_dev/*
88
solr/solr_home
99
*.log.*
1010
*.log
11+
Users/*
12+
Users
1113

pdf-toolkit-repo/pom.xml

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,18 @@
1111
<artifactId>pdf-toolkit</artifactId>
1212
<version>1.3-SNAPSHOT</version>
1313
</parent>
14-
14+
15+
<properties>
16+
<!-- Defines the target WAR artifactId to run this amp, only used with the -Pamp-to-war switch
17+
. | Allowed values: alfresco | share. Defaults to a repository AMP, but could point to your custom corporate Alfresco WAR -->
18+
<alfresco.client.war>alfresco</alfresco.client.war>
19+
<!-- Defines the target WAR groupId to run this amp, only used with the -Pamp-to-war switch
20+
. | Could be org.alfresco | org.alfresco.enterprise or your corporate groupId -->
21+
<!-- <alfresco.client.war.groupId>org.alfresco</alfresco.client.war.groupId> -->
22+
<!-- Defines the target WAR version to run this amp, only used with the -Pamp-to-war switch -->
23+
<!-- <alfresco.client.war.version>${alfresco.version}</alfresco.client.war.version> -->
24+
</properties>
25+
1526
<!--
1627
Following dependencies are needed for compiling Java code in src/main/java; <scope>provided</scope>
1728
is inherited for each of the following; for more info, please refer to alfresco-integration-parent
@@ -32,12 +43,6 @@
3243
<artifactId>alfresco-repository</artifactId>
3344
</dependency>
3445
<dependency>
35-
<groupId>org.alfresco</groupId>
36-
<artifactId>alfresco-enterprise-repository</artifactId>
37-
<version>${alfresco.version}</version>
38-
<scope>provided</scope>
39-
</dependency>
40-
<dependency>
4146
<groupId>org.apache.pdfbox</groupId>
4247
<artifactId>pdfbox</artifactId>
4348
<version>1.7.0-alfresco-patched</version>
@@ -73,15 +78,30 @@
7378
</dependency>
7479
</dependencies>
7580

76-
<properties>
77-
<!-- Defines the target WAR artifactId to run this amp, only used with the -Pamp-to-war switch
78-
. | Allowed values: alfresco | share. Defaults to a repository AMP, but could point to your custom corporate Alfresco WAR -->
79-
<alfresco.client.war>alfresco</alfresco.client.war>
80-
<!-- Defines the target WAR groupId to run this amp, only used with the -Pamp-to-war switch
81-
. | Could be org.alfresco | org.alfresco.enterprise or your corporate groupId -->
82-
<!-- <alfresco.client.war.groupId>org.alfresco</alfresco.client.war.groupId> -->
83-
<!-- Defines the target WAR version to run this amp, only used with the -Pamp-to-war switch -->
84-
<!-- <alfresco.client.war.version>${alfresco.version}</alfresco.client.war.version> -->
85-
</properties>
81+
<profiles>
82+
83+
<!--
84+
Brings in the extra Enterprise specific repository classes,
85+
if the 'enterprise' profile has been activated, needs to be activated manually. -->
86+
<profile>
87+
<id>enterprise</id>
88+
<dependencies>
89+
<dependency>
90+
<groupId>${alfresco.groupId}</groupId>
91+
<artifactId>alfresco-enterprise-repository</artifactId>
92+
<version>${alfresco.version}</version>
93+
<scope>provided</scope>
94+
</dependency>
95+
</dependencies>
96+
</profile>
97+
98+
<!-- If we are running in embedded Tomcat skip unit tests -->
99+
<profile>
100+
<id>run</id>
101+
<properties>
102+
<skipTests>true</skipTests>
103+
</properties>
104+
</profile>
105+
</profiles>
86106

87107
</project>

pdf-toolkit-repo/src/main/amp/config/alfresco/module/org.alfresco.extension.pdftoolkit/context/alfresco-pdf-toolkit-context.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,6 @@
128128

129129
<!-- Page count web script -->
130130
<bean id="webscript.org.alfresco.extension.pdftoolkit.pagecount.get" class="org.alfresco.extension.pdftoolkit.webscripts.GetPageCount" parent="webscript">
131-
<property name="ServiceRegistry" ref="ServiceRegistry"/>
131+
<property name="serviceRegistry" ref="ServiceRegistry"/>
132132
</bean>
133133
</beans>

pdf-toolkit-repo/src/main/amp/config/alfresco/module/org.alfresco.extension.pdftoolkit/context/service-context.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@
3939

4040
<!-- Page count web script -->
4141
<bean id="webscript.org.alfresco.extension.pdftoolkit.pagecount.get" class="org.alfresco.extension.pdftoolkit.webscripts.GetPageCount" parent="webscript">
42-
<property name="ServiceRegistry" ref="ServiceRegistry"/>
42+
<property name="serviceRegistry" ref="ServiceRegistry"/>
4343
</bean>
4444
</beans>

pdf-toolkit-repo/src/main/java/org/alfresco/extension/pdftoolkit/constants/PDFToolkitConstants.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ public abstract class PDFToolkitConstants
4343
public static final String PARAM_KEY_TYPE = "key-type";
4444
public static final String PARAM_ALIAS = "alias";
4545
public static final String PARAM_STORE_PASSWORD = "store-password";
46-
46+
public static final String PARAM_NEW_REVISION = "new-revision";
47+
4748
public static final String PARAM_SPLIT_FREQUENCY = "split-frequency";
4849

4950
public static final String PARAM_WATERMARK_IMAGE = "watermark-image";

pdf-toolkit-repo/src/main/java/org/alfresco/extension/pdftoolkit/repo/action/executer/PDFSignatureActionExecuter.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ protected void addParameterDefinitions(List<ParameterDefinition> paramList)
8686
paramList.add(new ParameterDefinitionImpl(PDFToolkitConstants.PARAM_ALIAS, DataTypeDefinition.TEXT, true, getParamDisplayLabel(PDFToolkitConstants.PARAM_ALIAS)));
8787
paramList.add(new ParameterDefinitionImpl(PDFToolkitConstants.PARAM_STORE_PASSWORD, DataTypeDefinition.TEXT, true, getParamDisplayLabel(PDFToolkitConstants.PARAM_STORE_PASSWORD)));
8888
paramList.add(new ParameterDefinitionImpl(PDFToolkitConstants.PARAM_DESTINATION_NAME, DataTypeDefinition.TEXT, false, getParamDisplayLabel(PDFToolkitConstants.PARAM_DESTINATION_NAME)));
89+
paramList.add(new ParameterDefinitionImpl(PDFToolkitConstants.PARAM_NEW_REVISION, DataTypeDefinition.BOOLEAN, false, getParamDisplayLabel(PDFToolkitConstants.PARAM_NEW_REVISION), false));
8990

9091
super.addParameterDefinitions(paramList);
9192

pdf-toolkit-repo/src/main/java/org/alfresco/extension/pdftoolkit/service/PDFToolkitServiceImpl.java

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,14 @@ public NodeRef signPDF(NodeRef targetNodeRef, Map<String, Serializable> params)
411411
int height = getInteger(params.get(PARAM_HEIGHT));
412412
int width = getInteger(params.get(PARAM_WIDTH));
413413
int pageNumber = getInteger(params.get(PARAM_PAGE));
414-
414+
415+
// By default, append the signature as a new PDF revision to avoid
416+
// invalidating any signatures that might already exist on the doc
417+
boolean appendToExisting = true;
418+
if (params.get(PARAM_NEW_REVISION) != null) {
419+
appendToExisting = Boolean.valueOf(String.valueOf(params.get(PARAM_NEW_REVISION)));
420+
}
421+
415422
// New keystore parameters
416423
String alias = (String)params.get(PARAM_ALIAS);
417424
String storePassword = (String)params.get(PARAM_STORE_PASSWORD);
@@ -464,7 +471,15 @@ else if (keyType.equalsIgnoreCase(KEY_TYPE_PKCS12))
464471
File file = new File(tempDir, ffs.getFileInfo(targetNodeRef).getName());
465472

466473
FileOutputStream fout = new FileOutputStream(file);
467-
PdfStamper stamp = PdfStamper.createSignature(reader, fout, '\0');
474+
475+
// When adding a second signature, append must be called on PdfStamper.createSignature
476+
// to avoid invalidating previous signatures
477+
PdfStamper stamp = null;
478+
if (appendToExisting) {
479+
stamp = PdfStamper.createSignature(reader, fout, '\0', tempDir, true);
480+
} else {
481+
stamp = PdfStamper.createSignature(reader, fout, '\0');
482+
}
468483
PdfSignatureAppearance sap = stamp.getSignatureAppearance();
469484
sap.setCrypto(key, chain, null, PdfSignatureAppearance.WINCER_SIGNED);
470485

@@ -1528,15 +1543,15 @@ private Rectangle positionSignature(String position, Rectangle pageRect, int wid
15281543
}
15291544
else if (position.equals(POSITION_BOTTOMRIGHT))
15301545
{
1531-
r = new Rectangle(pageWidth - width, pageHeight, pageWidth, pageHeight - height);
1546+
r = new Rectangle(pageWidth - width, height, pageWidth, 0);
15321547
}
15331548
else if (position.equals(POSITION_TOPLEFT))
15341549
{
15351550
r = new Rectangle(0, pageHeight, width, pageHeight - height);
15361551
}
15371552
else if (position.equals(POSITION_TOPRIGHT))
15381553
{
1539-
r = new Rectangle(pageWidth - width, height, pageWidth, 0);
1554+
r = new Rectangle(pageWidth - width, pageHeight, pageWidth, pageHeight - height);
15401555
}
15411556
else if (position.equals(POSITION_CENTER))
15421557
{

pdf-toolkit-share/pom.xml

Lines changed: 69 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,79 @@
1212
<version>1.3-SNAPSHOT</version>
1313
</parent>
1414

15-
<!--
16-
Following dependencies are needed for compiling Java code in src/main/java; <scope>provided</scope>
17-
is inherited for each of the following; for more info, please refer to alfresco-integration-parent
18-
POM definition
19-
@TODO - document
20-
-->
15+
<properties>
16+
<!-- Defines the target WAR artifactId to run this amp, only used with the -Pamp-to-war switch
17+
Allowed values: alfresco | share. In this case it's configured to use OOTB share -->
18+
<app.amp.client.war.artifactId>share</app.amp.client.war.artifactId>
19+
20+
<!-- Defines the log level used in log4j.properties -->
21+
<app.log.root.level>WARN</app.log.root.level>
22+
</properties>
23+
2124
<dependencies>
2225
<dependency>
2326
<groupId>${alfresco.groupId}</groupId>
24-
<artifactId>alfresco-repository</artifactId>
27+
<artifactId>share</artifactId>
28+
<version>${alfresco.version}</version>
29+
<classifier>classes</classifier>
30+
<scope>provided</scope>
31+
</dependency>
32+
33+
<dependency>
34+
<groupId>org.springframework.extensions.surf</groupId>
35+
<artifactId>spring-surf-api</artifactId>
36+
<scope>provided</scope>
37+
</dependency>
38+
39+
<!--===============================================================
40+
The following dependencies are needed to be able to compile the
41+
custom functional tests that are based on Page Objects (PO)
42+
===============================================================-->
43+
44+
<!-- Bring in the Share Page Objects (PO) used in our functional tests.
45+
It contains page objects such as LoginPage and it also brings
46+
in selenium-grid and selenium. -->
47+
<dependency>
48+
<groupId>${alfresco.groupId}</groupId>
49+
<artifactId>share-po</artifactId>
50+
<version>${alfresco.version}</version>
51+
<scope>test</scope>
52+
</dependency>
53+
<!-- Bring in the Share Page Object (PO) Tests that comes with Alfresco. It has
54+
the org.alfresco.po.share.AbstractTest class that our custom tests extend. -->
55+
<dependency>
56+
<groupId>${alfresco.groupId}</groupId>
57+
<artifactId>share-po</artifactId>
58+
<version>${alfresco.version}</version>
59+
<classifier>tests</classifier>
60+
<scope>test</scope>
61+
62+
<!-- Exclude selenium as it is already brought in by share-po dependency above -->
63+
<exclusions>
64+
<exclusion>
65+
<groupId>org.seleniumhq.selenium</groupId>
66+
<artifactId>selenium-java</artifactId>
67+
</exclusion>
68+
<exclusion>
69+
<groupId>org.seleniumhq.selenium</groupId>
70+
<artifactId>selenium-server</artifactId>
71+
</exclusion>
72+
</exclusions>
73+
</dependency>
74+
<!-- Test NG is defined with test scope in share-po, so need it here too -->
75+
<!-- Alfresco code creates a wrapper around Test NG -->
76+
<dependency>
77+
<groupId>org.alfresco.test</groupId>
78+
<artifactId>alfresco-testng</artifactId>
79+
<version>1.1</version>
80+
<scope>test</scope>
81+
<exclusions>
82+
<exclusion>
83+
<groupId>org.hamcrest</groupId>
84+
<artifactId>hamcrest-core</artifactId>
85+
</exclusion>
86+
</exclusions>
2587
</dependency>
2688
</dependencies>
2789

28-
<properties>
29-
<!-- Defines the target WAR artifactId to run this amp, only used with the -Pamp-to-war switch
30-
. | Allowed values: alfresco | share. Defaults to a repository AMP, but could point to your custom corporate Alfresco WAR -->
31-
<alfresco.client.war>share</alfresco.client.war>
32-
<!-- Defines the target WAR groupId to run this amp, only used with the -Pamp-to-war switch
33-
. | Could be org.alfresco | org.alfresco.enterprise or your corporate groupId -->
34-
<!-- <alfresco.client.war.groupId>org.alfresco</alfresco.client.war.groupId> -->
35-
<!-- Defines the target WAR version to run this amp, only used with the -Pamp-to-war switch -->
36-
<!-- <alfresco.client.war.version>${alfresco.version}</alfresco.client.war.version> -->
37-
</properties>
38-
3990
</project>

0 commit comments

Comments
 (0)