Skip to content

Commit 8ecfde9

Browse files
committed
去掉Apollo配置中心依赖
1 parent ec0377f commit 8ecfde9

File tree

99 files changed

+3495
-176
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+3495
-176
lines changed

jodconverter-core/pom.xml

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<groupId>com.yudianbank</groupId>
7+
<artifactId>jodconverter-core</artifactId>
8+
<version>1.0-SNAPSHOT</version>
9+
<packaging>jar</packaging>
10+
<properties>
11+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
12+
</properties>
13+
<repositories>
14+
<repository>
15+
<!-- required for org.hyperic:sigar -->
16+
<id>jboss-public-repository-group</id>
17+
<url>https://repository.jboss.org/nexus/content/groups/public-jboss/</url>
18+
</repository>
19+
</repositories>
20+
21+
<dependencies>
22+
<dependency>
23+
<groupId>commons-io</groupId>
24+
<artifactId>commons-io</artifactId>
25+
<version>1.4</version>
26+
</dependency>
27+
<dependency>
28+
<groupId>org.openoffice</groupId>
29+
<artifactId>juh</artifactId>
30+
<version>3.2.1</version>
31+
</dependency>
32+
<dependency>
33+
<groupId>org.openoffice</groupId>
34+
<artifactId>ridl</artifactId>
35+
<version>3.2.1</version>
36+
</dependency>
37+
<dependency>
38+
<groupId>org.openoffice</groupId>
39+
<artifactId>unoil</artifactId>
40+
<version>3.2.1</version>
41+
</dependency>
42+
<dependency>
43+
<!-- for the command line tool -->
44+
<groupId>commons-cli</groupId>
45+
<artifactId>commons-cli</artifactId>
46+
<version>1.1</version>
47+
<optional>true</optional>
48+
</dependency>
49+
<dependency>
50+
<groupId>org.hyperic</groupId>
51+
<artifactId>sigar</artifactId>
52+
<version>1.6.5.132</version>
53+
<optional>true</optional>
54+
</dependency>
55+
<dependency>
56+
<groupId>org.json</groupId>
57+
<artifactId>json</artifactId>
58+
<version>20090211</version>
59+
<optional>true</optional>
60+
</dependency>
61+
<dependency>
62+
<groupId>org.testng</groupId>
63+
<artifactId>testng</artifactId>
64+
<version>6.0.1</version>
65+
<scope>test</scope>
66+
</dependency>
67+
</dependencies>
68+
69+
<build>
70+
<plugins>
71+
<!-- 要将源码放上去,需要加入这个插件 -->
72+
<plugin>
73+
<artifactId>maven-source-plugin</artifactId>
74+
<version>2.1</version>
75+
<configuration>
76+
<attach>true</attach>
77+
</configuration>
78+
<executions>
79+
<execution>
80+
<phase>compile</phase>
81+
<goals>
82+
<goal>jar</goal>
83+
</goals>
84+
</execution>
85+
</executions>
86+
</plugin>
87+
<plugin>
88+
<groupId>org.apache.maven.plugins</groupId>
89+
<artifactId>maven-compiler-plugin</artifactId>
90+
<version>2.3.2</version>
91+
<configuration>
92+
<source>1.6</source>
93+
<target>1.6</target>
94+
<encoding>UTF-8</encoding>
95+
</configuration>
96+
</plugin>
97+
<plugin>
98+
<groupId>org.apache.maven.plugins</groupId>
99+
<artifactId>maven-surefire-plugin</artifactId>
100+
<version>2.7.2</version>
101+
<configuration>
102+
<!-- don't run tests in parallel -->
103+
<perCoreThreadCount>false</perCoreThreadCount>
104+
<threadCount>1</threadCount>
105+
</configuration>
106+
</plugin>
107+
<plugin>
108+
<groupId>org.apache.maven.plugins</groupId>
109+
<artifactId>maven-jar-plugin</artifactId>
110+
<version>2.3.1</version>
111+
<configuration>
112+
<archive>
113+
<manifest>
114+
<mainClass>org.artofsolving.jodconverter.cli.Convert</mainClass>
115+
<addClasspath>true</addClasspath>
116+
</manifest>
117+
</archive>
118+
</configuration>
119+
</plugin>
120+
<plugin>
121+
<groupId>org.apache.maven.plugins</groupId>
122+
<artifactId>maven-assembly-plugin</artifactId>
123+
<version>2.2-beta-5</version>
124+
<configuration>
125+
<descriptors>
126+
<descriptor>src/main/assembly/dist.xml</descriptor>
127+
</descriptors>
128+
</configuration>
129+
</plugin>
130+
</plugins>
131+
</build>
132+
133+
<reporting>
134+
<plugins>
135+
<plugin>
136+
<groupId>org.apache.maven.plugins</groupId>
137+
<artifactId>maven-javadoc-plugin</artifactId>
138+
<version>2.7</version>
139+
</plugin>
140+
<plugin>
141+
<groupId>org.codehaus.mojo</groupId>
142+
<artifactId>cobertura-maven-plugin</artifactId>
143+
<version>2.4</version>
144+
</plugin>
145+
</plugins>
146+
</reporting>
147+
<!-- distribute目录 -->
148+
<distributionManagement>
149+
<repository>
150+
<id>repo</id>
151+
<name>User Project Releases</name>
152+
<url>http://192.168.1.204:8081/nexus/content/repositories/releases</url>
153+
</repository>
154+
<snapshotRepository>
155+
<id>repo</id>
156+
<name>User Project SNAPSHOTS</name>
157+
<url>http://192.168.1.204:8081/nexus/content/repositories/snapshots</url>
158+
</snapshotRepository>
159+
</distributionManagement>
160+
</project>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<assembly>
2+
<id>dist</id>
3+
<formats>
4+
<format>zip</format>
5+
</formats>
6+
<dependencySets>
7+
<dependencySet>
8+
<outputDirectory>lib</outputDirectory>
9+
<excludes>
10+
<exclude>org.hyperic:sigar</exclude>
11+
</excludes>
12+
</dependencySet>
13+
</dependencySets>
14+
<fileSets>
15+
<fileSet>
16+
<includes>
17+
<include>LICENSE.txt</include>
18+
<include>README.txt</include>
19+
</includes>
20+
</fileSet>
21+
<fileSet>
22+
<directory>target</directory>
23+
<outputDirectory>/</outputDirectory>
24+
<includes>
25+
<include>${project.artifactId}-${project.version}-javadoc.jar</include>
26+
<include>${project.artifactId}-${project.version}-sources.jar</include>
27+
</includes>
28+
</fileSet>
29+
<fileSet>
30+
<directory>src/main/resources</directory>
31+
<outputDirectory>/conf</outputDirectory>
32+
<includes>
33+
<include>document-formats.js</include>
34+
</includes>
35+
</fileSet>
36+
</fileSets>
37+
</assembly>
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
//
2+
// JODConverter - Java OpenDocument Converter
3+
// Copyright 2004-2012 Mirko Nasato and contributors
4+
//
5+
// JODConverter is Open Source software, you can redistribute it and/or
6+
// modify it under either (at your option) of the following licenses
7+
//
8+
// 1. The GNU Lesser General Public License v3 (or later)
9+
// -> http://www.gnu.org/licenses/lgpl-3.0.txt
10+
// 2. The Apache License, Version 2.0
11+
// -> http://www.apache.org/licenses/LICENSE-2.0.txt
12+
//
13+
package org.artofsolving.jodconverter;
14+
15+
import static org.artofsolving.jodconverter.office.OfficeUtils.SERVICE_DESKTOP;
16+
import static org.artofsolving.jodconverter.office.OfficeUtils.cast;
17+
import static org.artofsolving.jodconverter.office.OfficeUtils.toUnoProperties;
18+
import static org.artofsolving.jodconverter.office.OfficeUtils.toUrl;
19+
20+
import java.io.File;
21+
import java.util.Map;
22+
23+
import org.artofsolving.jodconverter.office.OfficeContext;
24+
import org.artofsolving.jodconverter.office.OfficeException;
25+
import org.artofsolving.jodconverter.office.OfficeTask;
26+
27+
import com.sun.star.frame.XComponentLoader;
28+
import com.sun.star.frame.XStorable;
29+
import com.sun.star.io.IOException;
30+
import com.sun.star.lang.IllegalArgumentException;
31+
import com.sun.star.lang.XComponent;
32+
import com.sun.star.task.ErrorCodeIOException;
33+
import com.sun.star.util.CloseVetoException;
34+
import com.sun.star.util.XCloseable;
35+
36+
public abstract class AbstractConversionTask implements OfficeTask {
37+
38+
private final File inputFile;
39+
private final File outputFile;
40+
41+
public AbstractConversionTask(File inputFile, File outputFile) {
42+
this.inputFile = inputFile;
43+
this.outputFile = outputFile;
44+
}
45+
46+
protected abstract Map<String,?> getLoadProperties(File inputFile);
47+
48+
protected abstract Map<String,?> getStoreProperties(File outputFile, XComponent document);
49+
50+
public void execute(OfficeContext context) throws OfficeException {
51+
XComponent document = null;
52+
try {
53+
document = loadDocument(context, inputFile);
54+
modifyDocument(document);
55+
storeDocument(document, outputFile);
56+
} catch (OfficeException officeException) {
57+
throw officeException;
58+
} catch (Exception exception) {
59+
throw new OfficeException("conversion failed", exception);
60+
} finally {
61+
if (document != null) {
62+
XCloseable closeable = cast(XCloseable.class, document);
63+
if (closeable != null) {
64+
try {
65+
closeable.close(true);
66+
} catch (CloseVetoException closeVetoException) {
67+
// whoever raised the veto should close the document
68+
}
69+
} else {
70+
document.dispose();
71+
}
72+
}
73+
}
74+
}
75+
76+
private XComponent loadDocument(OfficeContext context, File inputFile) throws OfficeException {
77+
if (!inputFile.exists()) {
78+
throw new OfficeException("input document not found");
79+
}
80+
XComponentLoader loader = cast(XComponentLoader.class, context.getService(SERVICE_DESKTOP));
81+
Map<String,?> loadProperties = getLoadProperties(inputFile);
82+
XComponent document = null;
83+
try {
84+
document = loader.loadComponentFromURL(toUrl(inputFile), "_blank", 0, toUnoProperties(loadProperties));
85+
} catch (IllegalArgumentException illegalArgumentException) {
86+
throw new OfficeException("could not load document: " + inputFile.getName(), illegalArgumentException);
87+
} catch (ErrorCodeIOException errorCodeIOException) {
88+
throw new OfficeException("could not load document: " + inputFile.getName() + "; errorCode: " + errorCodeIOException.ErrCode, errorCodeIOException);
89+
} catch (IOException ioException) {
90+
throw new OfficeException("could not load document: " + inputFile.getName(), ioException);
91+
}
92+
if (document == null) {
93+
throw new OfficeException("could not load document: " + inputFile.getName());
94+
}
95+
return document;
96+
}
97+
98+
/**
99+
* Override to modify the document after it has been loaded and before it gets
100+
* saved in the new format.
101+
* <p>
102+
* Does nothing by default.
103+
*
104+
* @param document
105+
* @throws OfficeException
106+
*/
107+
protected void modifyDocument(XComponent document) throws OfficeException {
108+
// noop
109+
}
110+
111+
private void storeDocument(XComponent document, File outputFile) throws OfficeException {
112+
Map<String,?> storeProperties = getStoreProperties(outputFile, document);
113+
if (storeProperties == null) {
114+
throw new OfficeException("unsupported conversion");
115+
}
116+
try {
117+
cast(XStorable.class, document).storeToURL(toUrl(outputFile), toUnoProperties(storeProperties));
118+
} catch (ErrorCodeIOException errorCodeIOException) {
119+
throw new OfficeException("could not store document: " + outputFile.getName() + "; errorCode: " + errorCodeIOException.ErrCode, errorCodeIOException);
120+
} catch (IOException ioException) {
121+
throw new OfficeException("could not store document: " + outputFile.getName(), ioException);
122+
}
123+
}
124+
125+
}

0 commit comments

Comments
 (0)