Skip to content

Commit b9deb7e

Browse files
Updated Spring version
Added sample for setting license from URL
1 parent 9f9b263 commit b9deb7e

6 files changed

Lines changed: 89 additions & 17 deletions

File tree

Demos/Spring/pom.xml

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.groupdocs.ui</groupId>
88
<artifactId>comparison-spring</artifactId>
9-
<version>1.9.22</version>
9+
<version>22.3</version>
1010
<packaging>${packaging.type}</packaging>
1111

1212
<name>GroupDocs.Comparison for Java Spring Sample</name>
@@ -93,7 +93,7 @@
9393
<dependency>
9494
<groupId>org.springframework.boot</groupId>
9595
<artifactId>spring-boot-starter-web</artifactId>
96-
<version>2.0.4.RELEASE</version>
96+
<version>2.6.4</version>
9797
<!-- For using tomcat please remove this exclusion-->
9898
<exclusions>
9999
<exclusion>
@@ -113,20 +113,20 @@
113113
<dependency>
114114
<groupId>org.springframework.boot</groupId>
115115
<artifactId>spring-boot-starter-jetty</artifactId>
116-
<version>2.0.4.RELEASE</version>
116+
<version>2.6.4</version>
117117
<scope>${scope}</scope>
118118
</dependency>
119119
<!-- the end of jetty dependency -->
120120
<dependency>
121121
<groupId>org.springframework.boot</groupId>
122122
<artifactId>spring-boot-starter-test</artifactId>
123-
<version>2.0.4.RELEASE</version>
123+
<version>2.6.4</version>
124124
<scope>test</scope>
125125
</dependency>
126126
<dependency>
127127
<groupId>org.springframework.boot</groupId>
128128
<artifactId>spring-boot-starter-thymeleaf</artifactId>
129-
<version>2.0.4.RELEASE</version>
129+
<version>2.6.4</version>
130130
</dependency>
131131
<dependency>
132132
<groupId>javax.xml.bind</groupId>
@@ -146,31 +146,46 @@
146146
<dependency>
147147
<groupId>commons-io</groupId>
148148
<artifactId>commons-io</artifactId>
149-
<version>2.7</version>
149+
<version>2.11.0</version>
150150
</dependency>
151151
<dependency>
152152
<groupId>org.apache.commons</groupId>
153153
<artifactId>commons-lang3</artifactId>
154-
<version>3.4</version>
154+
<version>3.12.0</version>
155155
</dependency>
156156
<dependency>
157157
<groupId>com.groupdocs</groupId>
158158
<artifactId>groupdocs-comparison</artifactId>
159-
<version>21.6</version>
159+
<version>${project.version}</version>
160160
<type>jar</type>
161161
</dependency>
162162
<dependency>
163163
<groupId>com.google.guava</groupId>
164164
<artifactId>guava</artifactId>
165-
<version>11.0.2</version>
165+
<version>23.0</version>
166+
</dependency>
167+
<dependency>
168+
<groupId>junit</groupId>
169+
<artifactId>junit</artifactId>
170+
<version>4.12</version>
171+
<scope>test</scope>
166172
</dependency>
167173
</dependencies>
168174

169175
<repositories>
170176
<repository>
171-
<id>GroupDocsJavaAPI</id>
172-
<name>GroupDocs Java API</name>
173-
<url>http://artifact.groupdocs.com/repo/</url>
177+
<id>com.springsource.repository.bundles.external</id>
178+
<name>SpringSource Enterprise Bundle Repository - External Bundle Releases</name>
179+
<url>http://repository.springsource.com/maven/bundles/external</url>
180+
</repository>
181+
<repository>
182+
<id>maven.groupdocs.com</id>
183+
<name>artifact.groupdocs.com-releases</name>
184+
<url>https://repository.groupdocs.com/repo/</url>
185+
</repository>
186+
<repository>
187+
<id>maven-central</id>
188+
<url>https://repo1.maven.org/maven2</url>
174189
</repository>
175190
</repositories>
176191

Examples/GroupDocs.Comparison.Examples.Java/pom.xml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>GroupDocs.Comparison.Examples.Java</groupId>
55
<artifactId>GroupDocs.Comparison.Examples.Java</artifactId>
6-
<version>21.6</version>
6+
<version>22.3</version>
77
<properties>
88
<maven.compiler.source>7</maven.compiler.source>
99
<maven.compiler.target>7</maven.compiler.target>
@@ -19,9 +19,13 @@
1919
</dependencies>
2020
<repositories>
2121
<repository>
22-
<id>GroupDocsArtifactRepository</id>
23-
<name>GroupDocs Artifact Repository</name>
24-
<url>http://repository.groupdocs.com/repo/</url>
22+
<id>maven.groupdocs.com</id>
23+
<name>artifact.groupdocs.com-releases</name>
24+
<url>https://repository.groupdocs.com/repo/</url>
25+
</repository>
26+
<repository>
27+
<id>maven-central</id>
28+
<url>https://repo1.maven.org/maven2</url>
2529
</repository>
2630
</repositories>
2731
<build>

Examples/GroupDocs.Comparison.Examples.Java/src/main/java/com/groupdocs/comparison/examples/RunExamples.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public static void main(String[] args) throws Exception {
2828
//NOTE: Please uncomment the example you want to try out
2929
// region Quick Start
3030
SetLicenseFromFile.run();
31+
// SetLicenseFromUrl.run();
3132
//SetLicenseFromStream.run();
3233
//SetMeteredLicense.run();
3334
HelloWorld.run();

Examples/GroupDocs.Comparison.Examples.Java/src/main/java/com/groupdocs/comparison/examples/Utils.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@
66
import java.net.URI;
77
import java.net.URISyntaxException;
88
import java.net.URL;
9+
import java.nio.file.Files;
10+
import java.nio.file.Path;
11+
import java.nio.file.Paths;
912
import java.util.Objects;
1013

1114
public class Utils {
1215

1316
public static final String LICENSE_PATH;
17+
public static final String LICENSE_URL;
1418
public static final String SAMPLES_PATH;
1519
public static final String OUTPUT_PATH;
1620

@@ -24,6 +28,7 @@ public class Utils {
2428
SAMPLES_PATH = baseFile.getAbsolutePath() + "/resources/sample_files";
2529
LICENSE_PATH = baseFile.getAbsolutePath() + "/resources/GroupDocs.Viewer.Java.lic";
2630
OUTPUT_PATH = baseFile.getAbsolutePath() + "/output";
31+
LICENSE_URL = System.getenv("GROUPDOCS_LIC_PATH");
2732
} catch (URISyntaxException e) {
2833
e.printStackTrace();
2934
throw new RuntimeException(e);

Examples/GroupDocs.Comparison.Examples.Java/src/main/java/com/groupdocs/comparison/examples/quick_start/SetLicenseFromFile.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class SetLicenseFromFile {
1818
* This example demonstrates how to set license from file.
1919
* <p>
2020
* The SetLicense method attempts to set a license from several locations
21-
* relative to the executable and GroupDocs.Viewer.dll. You can also use the
21+
* relative to the executable. You can also use the
2222
* additional overload to load a license from a stream, this is useful for
2323
* instance when the License is stored as an embedded resource.
2424
*/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package com.groupdocs.comparison.examples.quick_start;
2+
3+
import com.groupdocs.comparison.examples.Utils;
4+
import com.groupdocs.comparison.license.License;
5+
6+
import java.io.InputStream;
7+
import java.net.URL;
8+
9+
/**
10+
* This example demonstrates how to set license from url.
11+
* <p>
12+
* The SetLicense method attempts to set a license from several locations relative to the executable.
13+
* You can also use the additional overload to load a license from a stream, this is useful for instance when the
14+
* License is stored as an embedded resource.
15+
*/
16+
public class SetLicenseFromUrl {
17+
18+
/**
19+
* This example demonstrates how to set license from url.
20+
* <p>
21+
* The setLicense method attempts to set a license from several locations
22+
* relative to the executable. You can also use the
23+
* additional overload to load a license from a stream, this is useful for
24+
* instance when the License is stored as an embedded resource.
25+
*/
26+
public static void run() {
27+
if (Utils.LICENSE_URL != null) {
28+
try {
29+
URL website = new URL(Utils.LICENSE_URL);
30+
License license = new License();
31+
try (final InputStream inputStream = website.openStream()) {
32+
license.setLicense(inputStream);
33+
}
34+
System.out.println("License set successfully.");
35+
} catch (Exception e) {
36+
System.err.println("Can't load remote license from '" + Utils.LICENSE_URL + "'");
37+
e.printStackTrace();
38+
}
39+
} else {
40+
System.out.println("\nWe do not ship any license with this example. " +
41+
"\nEnvironment variable GROUPDOCS_LIC_PATH is null. " +
42+
"\nVisit the GroupDocs site to obtain either a temporary or permanent license. " +
43+
"\nLearn more about licensing at https://purchase.groupdocs.com/faqs/licensing. " +
44+
"\nLear how to request temporary license at https://purchase.groupdocs.com/temporary-license.");
45+
}
46+
}
47+
}

0 commit comments

Comments
 (0)