Skip to content

Commit 420e1f6

Browse files
committed
add dependency checks and some refactoring, version 0.5.3
1 parent 55371b5 commit 420e1f6

18 files changed

+82
-63
lines changed

pom.xml

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>pl.psnc.dl.ege</groupId>
55
<artifactId>ege-framework</artifactId>
6-
<version>0.5.2</version>
6+
<version>0.5.3</version>
77
<name>EGE Framework</name>
88
<properties>
99

@@ -137,6 +137,42 @@
137137
</plugin>
138138
</plugins>
139139
</reporting>-->
140+
<build>
141+
<plugins>
142+
<plugin>
143+
<groupId>org.apache.maven.plugins</groupId>
144+
<artifactId>maven-pmd-plugin</artifactId>
145+
<version>3.13.0</version>
146+
<configuration>
147+
<failOnViolation>false</failOnViolation>
148+
<printFailingErrors>true</printFailingErrors>
149+
<linkXRef>false</linkXRef>
150+
</configuration>
151+
<executions>
152+
<execution>
153+
<phase>compile</phase>
154+
<goals>
155+
<goal>
156+
check</goal>
157+
</goals>
158+
</execution>
159+
</executions>
160+
</plugin>
161+
<plugin>
162+
<groupId>org.owasp</groupId>
163+
<artifactId>dependency-check-maven</artifactId>
164+
<version>8.2.1</version>
165+
<executions>
166+
<execution>
167+
<phase>compile</phase>
168+
<goals>
169+
<goal>check</goal>
170+
</goals>
171+
</execution>
172+
</executions>
173+
</plugin>
174+
</plugins>
175+
</build>
140176
<dependencies>
141177
<dependency>
142178
<groupId>pl.psnc.dl.ege</groupId>

src/main/java/pl/psnc/dl/ege/ExceptionListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ public interface ExceptionListener {
1414
*
1515
* @param ex received exception
1616
*/
17-
public void catchException(Exception ex);
17+
void catchException(Exception ex);
1818

1919
}

src/main/java/pl/psnc/dl/ege/component/ConfigurableConverter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ public interface ConfigurableConverter extends Converter {
2727
* @param params converters parameters
2828
* @throws EGEException
2929
*/
30-
public void configure(Map<String,String> params) throws EGEException;
30+
void configure(Map<String,String> params) throws EGEException;
3131

3232
}

src/main/java/pl/psnc/dl/ege/configuration/EGEConfigurationManager.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import java.util.Collection;
1212
import java.util.Enumeration;
1313
import java.util.LinkedHashMap;
14-
import java.util.Iterator;
1514
import java.util.List;
1615
import java.util.Map;
1716
import java.util.regex.Matcher;
@@ -60,7 +59,7 @@
6059
*
6160
* @author mariuszs
6261
*/
63-
public class EGEConfigurationManager
62+
public final class EGEConfigurationManager
6463
{
6564

6665
private final static String EXTENSION_POINT_ID = "pl.psnc.dl.ege.root";
@@ -121,7 +120,7 @@ private List<PluginLocation> getLocationsList(String dirRegex)
121120
int counter = 0;
122121
while (locs.hasMoreElements()) {
123122
final URL location = locs.nextElement();
124-
String matchString = "^(jar:[a-zA-Z][a-zA-Z0-9\\+\\-\\.]*:.*\\!/).*plugin.xml.*{1}$";
123+
String matchString = "^(jar:[a-zA-Z][a-zA-Z0-9\\+\\-\\.]*:.*\\!/).*plugin.xml.*\\{1\\}$";
125124
Pattern pattern = Pattern.compile(matchString);
126125
Matcher matcher = pattern.matcher(location.toExternalForm());
127126
LOGGER.debug("Found : " + location.toExternalForm());
@@ -132,7 +131,7 @@ private List<PluginLocation> getLocationsList(String dirRegex)
132131
try {
133132
String pluginDirectory = getDirectoryName(location,
134133
"plugin" + counter);
135-
System.out.println("Location and PluginDirectory " + location + " " + pluginDirectory);
134+
LOGGER.debug("Location and PluginDirectory " + location + " " + pluginDirectory);
136135
File directory = unpackZIP(location, pluginDirectory);
137136
if (directory == null) {
138137
continue;
@@ -389,13 +388,11 @@ private List<PluginWrapper> getAllComponents(ExtensionPoint ep)
389388
{
390389
List<PluginWrapper> plugins = new ArrayList();
391390
List<Extension> extensions = new ArrayList(ep.getConnectedExtensions());
392-
if(ep.getId().equals("XslConverter")) {
391+
if(ep.getId().equals("XslConverter") && extensions.size() > 0) {
393392
// search for all plugin.xml files in stylesheets and add the extensions
394-
if(extensions.size() > 0)
395393
getXslExtensions(extensions, ep);
396394
}
397-
for (Iterator iter = extensions.iterator(); iter.hasNext();) {
398-
Extension element = (Extension) iter.next();
395+
for (Extension element : extensions) {
399396
try {
400397
pluginManager.activatePlugin(element
401398
.getDeclaringPluginDescriptor().getId());
@@ -465,7 +462,6 @@ private void getXslExtensions(List<Extension> extensions, ExtensionPoint ep) {
465462
List<Properties> props = handler.getProperties();
466463
List<String> ids = handler.getIds();
467464
Properties params = null;
468-
469465
for(int i = 0; i<props.size(); i++) {
470466
MockExtension mockExtension = new MockExtension(ids.get(i),
471467
extensions.get(0).getDeclaringPluginDescriptor());

src/main/java/pl/psnc/dl/ege/configuration/EGEConstants.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package pl.psnc.dl.ege.configuration;
22

33
import java.io.File;
4-
import java.io.InputStream;
5-
import java.net.URL;
64
import java.util.Properties;
75
import java.io.FileInputStream;
86
import org.apache.logging.log4j.Logger;
@@ -23,8 +21,8 @@ public final class EGEConstants {
2321

2422
static {
2523
try {
26-
System.out.println(PATH);
27-
oxgProps.load(new FileInputStream(PATH + File.separator + "oxgarage.properties"));
24+
LOGGER.debug(PATH);
25+
oxgProps.load(new FileInputStream(PATH + File.separator + "oxgarage.properties"));
2826
} catch (java.io.IOException e) {
2927
try {
3028
oxgProps.load(new FileInputStream(PATH + File.separator + "oxgarage.properties"));
@@ -69,13 +67,13 @@ public final class EGEConstants {
6967
public static final String BUFFER_TEMP_PATH = TEMP_PATH + File.separator + "buff";
7068

7169
static {
72-
boolean success = (new File(BUFFER_TEMP_PATH)).mkdirs();
70+
boolean success = new File(BUFFER_TEMP_PATH).mkdirs();
7371
if (!success) {
7472
LOGGER.error("Could not create dir " + BUFFER_TEMP_PATH);
7573
}
7674
}
7775
static {
78-
boolean success = (new File(EGE_EXT_DIRECTORY)).mkdirs();
76+
boolean success = new File(EGE_EXT_DIRECTORY).mkdirs();
7977
if (!success) {
8078
LOGGER.error("Could not create dir " + EGE_EXT_DIRECTORY);
8179
}

src/main/java/pl/psnc/dl/ege/utils/DataBuffer.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,11 +325,9 @@ public InputStream getStream()
325325
*/
326326
public void deleteFile()
327327
{
328-
if (!os.isInMemory()) {
329-
if (os.getFile().exists()) {
328+
if (!os.isInMemory() && os.getFile().exists()) {
330329
LOGGER.debug("Removing tmp file : " + os.getFile());
331330
os.getFile().delete();
332-
}
333331
}
334332
}
335333

src/main/java/pl/psnc/dl/ege/utils/EGEIOUtils.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,19 @@ public static void constructZip(File file, ZipOutputStream out, String dir)
5757

5858
File[] files = file.listFiles();
5959

60-
for (int i = 0; i < files.length; i++) {
61-
if (files[i].isDirectory()) {
62-
constructZip(files[i], out, dir + files[i].getName() + "/");
60+
for (File f : files) {
61+
if (f.isDirectory()) {
62+
constructZip(f, out, dir + f.getName() + "/");
6363
continue;
6464
}
6565

6666
// read file
6767
try {
68-
fi = new FileInputStream(files[i]);
68+
fi = new FileInputStream(f);
6969
origin = new BufferedInputStream(fi, BUFFER);
7070

7171
// create zip entry
72-
ZipEntry entry = new ZipEntry(dir + files[i].getName());
72+
ZipEntry entry = new ZipEntry(dir + f.getName());
7373

7474
// add entries to ZIP file
7575
out.putNextEntry(entry);
@@ -275,6 +275,7 @@ public static void unzipStream(InputStream in, File outputDir)
275275
finally {
276276
dest.flush();
277277
dest.close();
278+
fos.close();
278279
}
279280
}
280281

src/main/java/pl/psnc/dl/ege/utils/IOResolver.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public interface IOResolver {
2424
* @param dir
2525
* @throws IOException
2626
*/
27-
public void decompressStream(InputStream is, File dir) throws IOException;
27+
void decompressStream(InputStream is, File dir) throws IOException;
2828

2929
/**
3030
* Method should be responsible for compressing output data received from any of
@@ -34,6 +34,6 @@ public interface IOResolver {
3434
* @return
3535
* @throws IOException
3636
*/
37-
public void compressData(File dir, OutputStream os) throws IOException;
37+
void compressData(File dir, OutputStream os) throws IOException;
3838

3939
}

src/main/java/pl/psnc/dl/ege/webapp/request/ConversionRequestResolver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ else if (queries.length == 1) {
9595
private String[] resolveQueries()
9696
{
9797
String params = request.getRequestURL().toString();
98-
params = (params.endsWith(SLASH) ? params : params + SLASH);
98+
params = params.endsWith(SLASH) ? params : params + SLASH;
9999
params = params.substring(params.indexOf(CONVERSIONS_SLICE_BASE),
100100
params.length());
101101
String[] queries = params.split(SLASH);

src/main/java/pl/psnc/dl/ege/webapp/request/ConversionsPropertiesHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public void startElement(String uri, String localName, String name,
6969
throws SAXException
7070
{
7171
if (localName.equals("conversion")) {
72-
currentIndex = Integer.parseInt((attributes.getValue("index")));
72+
currentIndex = Integer.parseInt(attributes.getValue("index"));
7373
Map<String,String> props = properties.get(currentIndex);
7474
if(props!=null){
7575
throw new SAXException("Error reading properties: vertices with same index ("+currentIndex+") found!");

0 commit comments

Comments
 (0)