From a4446afac0dcefe1d63cbd7e063013c7604d0557 Mon Sep 17 00:00:00 2001 From: Brian Rosenberger Date: Thu, 3 May 2018 05:24:04 +0000 Subject: [PATCH] Updating underlying libraries to current, major versions. Also updating source level to Java 8 and runtime to Tomcat 8.5. See ivy.xml for details. git-svn-id: https://brutex.net/svn/xservices/trunk@185 e7e49efb-446e-492e-b9ec-fcafc1997a86 --- build.xml | 34 +- doc/common/installation.xml | 3 +- ivy.xml | 147 +++++---- src/java/log4j2.xml | 16 + .../security/DirectoryPermission.java | 7 +- .../security/PermissionResolver.java | 5 +- .../xservices/security/XServicesRealm.java | 44 ++- .../security/XmlServicePermission.java | 6 +- .../BrutexHSQLQuartzConnectionProvider.java | 8 +- .../util/BrutexQuartzConnectionProvider.java | 8 +- .../net/brutex/xservices/util/CVSClient.java | 18 +- .../net/brutex/xservices/util/FileWalker.java | 6 +- .../util/cache/CacheExecutorService.java | 49 ++- .../xservices/util/cache/CacheServlet.java | 8 +- .../util/cache/FindingsCacheServlet.java | 20 +- .../util/cache/FindingsConfigBean.java | 30 +- .../xservices/ws/impl/XmlServiceImpl.java | 311 ++++++++---------- .../brutex/xservices/ws/rs/CVSInfoImpl.java | 58 ++-- .../net/brutex/xservices/ws/rs/DIMCMInfo.java | 2 +- .../brutex/xservices/ws/rs/DIMCMInfoImpl.java | 27 +- .../brutex/xservices/ws/rs/FileInfoImpl.java | 12 +- test/DateService-soapui-project.xml | 88 ++--- web/META-INF/context.xml | 2 - .../{cxf-beans.xml => applicationContext.xml} | 44 +-- web/WEB-INF/log4j2.xml | 26 ++ {src/java => web/WEB-INF}/shiro.ini | 0 web/WEB-INF/web.xml | 34 +- 27 files changed, 547 insertions(+), 466 deletions(-) create mode 100644 src/java/log4j2.xml delete mode 100644 web/META-INF/context.xml rename web/WEB-INF/{cxf-beans.xml => applicationContext.xml} (71%) create mode 100644 web/WEB-INF/log4j2.xml rename {src/java => web/WEB-INF}/shiro.ini (100%) diff --git a/build.xml b/build.xml index 924056d..38bdfe9 100644 --- a/build.xml +++ b/build.xml @@ -1,14 +1,14 @@ - + - + @@ -17,7 +17,7 @@ - + @@ -29,8 +29,8 @@ - - + + @@ -39,7 +39,8 @@ - + + @@ -162,7 +163,12 @@ - + + + + @@ -170,7 +176,14 @@ - + + + + + @@ -183,5 +196,8 @@ Distribution: ${delivery.dir}\\${name}\\${name}-${build.version} - + + + + diff --git a/doc/common/installation.xml b/doc/common/installation.xml index 87e0359..3fea917 100644 --- a/doc/common/installation.xml +++ b/doc/common/installation.xml @@ -6,7 +6,8 @@ Installation As of February 2013, XServices require Java 7. Older builds run against Java 5. - Apache Tomcat 7 + As of April 2018, XServices require Java 8 and Tomcat 8.5. + tbd. In short: Deploy .WAR file to Apache Tomcat
diff --git a/ivy.xml b/ivy.xml index 2bce7cb..a7bfd30 100644 --- a/ivy.xml +++ b/ivy.xml @@ -15,7 +15,8 @@ - + + @@ -27,16 +28,16 @@ + - + + + + - - - - - + @@ -45,79 +46,95 @@ + + + + - - - - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - - - - + + +--> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - - - - - - - - - - - - - - - - - + diff --git a/src/java/log4j2.xml b/src/java/log4j2.xml new file mode 100644 index 0000000..25130ec --- /dev/null +++ b/src/java/log4j2.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/java/net/brutex/xservices/security/DirectoryPermission.java b/src/java/net/brutex/xservices/security/DirectoryPermission.java index 979cd00..a2421ad 100644 --- a/src/java/net/brutex/xservices/security/DirectoryPermission.java +++ b/src/java/net/brutex/xservices/security/DirectoryPermission.java @@ -16,7 +16,9 @@ package net.brutex.xservices.security; -import org.apache.log4j.Logger; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.apache.shiro.authz.Permission; import org.apache.shiro.util.AntPathMatcher; @@ -26,7 +28,8 @@ import org.apache.shiro.util.AntPathMatcher; */ public class DirectoryPermission implements Permission { - private final Logger logger = Logger.getLogger(DirectoryPermission.class); + private final Logger logger = LogManager.getLogger(); + private final String path; public DirectoryPermission(String antlikepath) { diff --git a/src/java/net/brutex/xservices/security/PermissionResolver.java b/src/java/net/brutex/xservices/security/PermissionResolver.java index 478d58e..aad678a 100644 --- a/src/java/net/brutex/xservices/security/PermissionResolver.java +++ b/src/java/net/brutex/xservices/security/PermissionResolver.java @@ -19,7 +19,8 @@ package net.brutex.xservices.security; import net.brutex.xservices.ws.XmlService; import net.brutex.xservices.ws.rs.FileInfo; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; import org.apache.shiro.authz.Permission; import org.apache.shiro.authz.permission.InvalidPermissionStringException; @@ -29,7 +30,7 @@ import org.apache.shiro.authz.permission.InvalidPermissionStringException; */ public class PermissionResolver implements org.apache.shiro.authz.permission.PermissionResolver { - final Logger logger = Logger.getLogger(PermissionResolver.class); + private final Logger logger = LogManager.getLogger(); private final String DELIMITER = "||"; @Override diff --git a/src/java/net/brutex/xservices/security/XServicesRealm.java b/src/java/net/brutex/xservices/security/XServicesRealm.java index c8758df..41ae528 100644 --- a/src/java/net/brutex/xservices/security/XServicesRealm.java +++ b/src/java/net/brutex/xservices/security/XServicesRealm.java @@ -17,24 +17,30 @@ package net.brutex.xservices.security; -import java.text.ParseException; -import java.util.Collection; -import java.util.Map; +import org.apache.logging.log4j.Logger; -import org.apache.log4j.Logger; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; + +import javax.servlet.ServletContext; + +import org.apache.catalina.core.ApplicationContext; +import org.apache.logging.log4j.LogManager; import org.apache.shiro.authc.AuthenticationException; import org.apache.shiro.authc.AuthenticationInfo; import org.apache.shiro.authc.AuthenticationToken; import org.apache.shiro.authz.AuthorizationInfo; -import org.apache.shiro.authz.Permission; -import org.apache.shiro.authz.permission.PermissionResolver; +import org.apache.shiro.authz.SimpleAuthorizationInfo; import org.apache.shiro.config.Ini; import org.apache.shiro.io.ResourceUtils; import org.apache.shiro.realm.AuthorizingRealm; import org.apache.shiro.realm.text.IniRealm; +import org.apache.shiro.realm.text.TextConfigurationRealm; import org.apache.shiro.subject.PrincipalCollection; import org.apache.shiro.util.Nameable; -import org.apache.shiro.util.PermissionUtils; +import org.apache.shiro.web.env.IniWebEnvironment; +import org.apache.shiro.web.util.WebUtils; // TODO: Auto-generated Javadoc /* @@ -51,7 +57,7 @@ import org.apache.shiro.util.PermissionUtils; public class XServicesRealm extends IniRealm implements Nameable { /** The logger. */ - private static Logger logger = Logger.getLogger(XServicesRealm.class); + private final Logger logger = LogManager.getLogger(); /** The name. */ private String name; @@ -70,11 +76,25 @@ public class XServicesRealm extends IniRealm implements Nameable { * 'shiro.ini' in classpath and {@link net.brutex.xservices.security.PermissionResolver PermissionResolver}. * */ + public XServicesRealm() { super(); - this.setIni(Ini.fromResourcePath(ResourceUtils.CLASSPATH_PREFIX+"shiro.ini")); + /* needs review */ + URI classesRootDir; + try { + classesRootDir = getClass().getProtectionDomain().getCodeSource().getLocation().toURI(); + String dir = classesRootDir.toString().replaceAll("%20", " "); + dir = dir.substring(0, dir.lastIndexOf("WEB-INF")); + this.setIni(Ini.fromResourcePath(dir+"/WEB-INF/shiro.ini")); + } catch (URISyntaxException e) { + logger.error(e.getMessage(), e); + e.printStackTrace(); + } + + this.setPermissionResolver(new net.brutex.xservices.security.PermissionResolver()); - //this.setRolePermissionResolver(new RolePermissionResolver()); - init(); - } + } + + + } diff --git a/src/java/net/brutex/xservices/security/XmlServicePermission.java b/src/java/net/brutex/xservices/security/XmlServicePermission.java index 56343b2..114bb89 100644 --- a/src/java/net/brutex/xservices/security/XmlServicePermission.java +++ b/src/java/net/brutex/xservices/security/XmlServicePermission.java @@ -16,9 +16,9 @@ package net.brutex.xservices.security; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; import org.apache.shiro.authz.Permission; -import org.apache.shiro.util.AntPathMatcher; /** * @author Brian Rosenberger, bru(at)brutex.de @@ -26,7 +26,7 @@ import org.apache.shiro.util.AntPathMatcher; */ public class XmlServicePermission implements Permission { - private final Logger logger = Logger.getLogger(XmlServicePermission.class); + private final Logger logger = LogManager.getLogger(); private final String permissionString; public XmlServicePermission(String permissionString) { diff --git a/src/java/net/brutex/xservices/util/BrutexHSQLQuartzConnectionProvider.java b/src/java/net/brutex/xservices/util/BrutexHSQLQuartzConnectionProvider.java index 281e996..14ce0ae 100644 --- a/src/java/net/brutex/xservices/util/BrutexHSQLQuartzConnectionProvider.java +++ b/src/java/net/brutex/xservices/util/BrutexHSQLQuartzConnectionProvider.java @@ -30,9 +30,9 @@ import java.sql.Statement; import java.util.ArrayList; import java.util.List; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.quartz.utils.ConnectionProvider; /** @@ -42,7 +42,7 @@ import org.quartz.utils.ConnectionProvider; public class BrutexHSQLQuartzConnectionProvider implements ConnectionProvider { private Connection conn = null; - private final Logger logger = Logger.getLogger(this.getClass().getCanonicalName()); + private static final Logger logger = LogManager.getLogger(); public Connection getConnection() throws SQLException { diff --git a/src/java/net/brutex/xservices/util/BrutexQuartzConnectionProvider.java b/src/java/net/brutex/xservices/util/BrutexQuartzConnectionProvider.java index c27cc6b..f67d91b 100644 --- a/src/java/net/brutex/xservices/util/BrutexQuartzConnectionProvider.java +++ b/src/java/net/brutex/xservices/util/BrutexQuartzConnectionProvider.java @@ -30,9 +30,9 @@ import java.sql.Statement; import java.util.ArrayList; import java.util.List; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.quartz.utils.ConnectionProvider; /** @@ -42,7 +42,7 @@ import org.quartz.utils.ConnectionProvider; public class BrutexQuartzConnectionProvider implements ConnectionProvider { private Connection conn = null; - private final Logger logger = Logger.getLogger(this.getClass().getCanonicalName()); + private final Logger logger = LogManager.getLogger(); public Connection getConnection() throws SQLException { diff --git a/src/java/net/brutex/xservices/util/CVSClient.java b/src/java/net/brutex/xservices/util/CVSClient.java index dcf93a0..eebd800 100644 --- a/src/java/net/brutex/xservices/util/CVSClient.java +++ b/src/java/net/brutex/xservices/util/CVSClient.java @@ -2,11 +2,13 @@ /* */ /* */ import java.io.File; /* */ import net.brutex.xservices.types.scm.ItemType; -/* */ import net.brutex.xservices.ws.rs.CVSInfoImpl; -/* */ import org.apache.commons.configuration.Configuration; -/* */ import org.apache.commons.configuration.ConfigurationException; -/* */ import org.apache.commons.configuration.PropertiesConfiguration; -/* */ import org.apache.log4j.Logger; + import net.brutex.xservices.util.CVSRoot; + +import org.apache.commons.configuration2.PropertiesConfiguration; +import org.apache.commons.configuration2.builder.fluent.Configurations; +import org.apache.commons.configuration2.ex.ConfigurationException; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; /* */ import org.netbeans.lib.cvsclient.Client; /* */ import org.netbeans.lib.cvsclient.admin.StandardAdminHandler; /* */ import org.netbeans.lib.cvsclient.command.CommandAbortedException; @@ -20,7 +22,7 @@ /* */ private final PServerConnection connection; /* */ private final CVSRoot root; /* */ private final GlobalOptions globalOptions; -/* 41 */ final Logger logger = Logger.getLogger(CVSInfoImpl.class); +/* 41 */ final Logger logger = LogManager.getLogger(); /* */ public final Client client; /* */ /* */ public Client getClient() @@ -34,7 +36,9 @@ /* 55 */ throw new ConfigurationException("Config file not found"); /* */ } /* 57 */ this.configfile = config; -/* 58 */ Configuration configuration = new PropertiesConfiguration(this.configfile); + Configurations configs = new Configurations(); + +/* 58 */ PropertiesConfiguration configuration = configs.properties(this.configfile); /* */ /* 60 */ String cvsroot = configuration.getString("CVSROOT"); /* 61 */ String workdir = configuration.getString("WORKDIR"); diff --git a/src/java/net/brutex/xservices/util/FileWalker.java b/src/java/net/brutex/xservices/util/FileWalker.java index 4430695..be002fb 100644 --- a/src/java/net/brutex/xservices/util/FileWalker.java +++ b/src/java/net/brutex/xservices/util/FileWalker.java @@ -25,7 +25,9 @@ import java.nio.file.attribute.BasicFileAttributes; import java.util.ArrayList; import java.util.List; -import org.apache.log4j.Logger; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import net.brutex.xservices.types.FileInfoType; @@ -50,7 +52,7 @@ public class FileWalker extends SimpleFileVisitor { private final String pattern; /** The logger. */ - final Logger logger = Logger.getLogger(FileWalker.class); + private static final Logger logger = LogManager.getLogger(); List list; diff --git a/src/java/net/brutex/xservices/util/cache/CacheExecutorService.java b/src/java/net/brutex/xservices/util/cache/CacheExecutorService.java index 0451897..5bff845 100644 --- a/src/java/net/brutex/xservices/util/cache/CacheExecutorService.java +++ b/src/java/net/brutex/xservices/util/cache/CacheExecutorService.java @@ -28,33 +28,28 @@ import javax.servlet.ServletContextListener; * */ +public class CacheExecutorService implements ServletContextListener { + static final String EXECUTOR_NAME = "CACHE_EXECUTOR"; + private ExecutorService executor; + public void contextInitialized(ServletContextEvent arg0) { + ServletContext context = arg0.getServletContext(); + int nr_executors = 5; + ThreadFactory daemonFactory = new DaemonThreadFactory(); + try { + nr_executors = Integer.parseInt(context.getInitParameter("cache:thread-count")); + } catch (NumberFormatException localNumberFormatException) { + } + if (nr_executors <= 1) + this.executor = Executors.newSingleThreadExecutor(daemonFactory); + else { + this.executor = Executors.newFixedThreadPool(nr_executors, daemonFactory); + } + context.setAttribute("CACHE_EXECUTOR", this.executor); + } -public class CacheExecutorService - implements ServletContextListener -{ - static final String EXECUTOR_NAME = "CACHE_EXECUTOR"; - private ExecutorService executor; - - public void contextInitialized(ServletContextEvent arg0) - { - ServletContext context = arg0.getServletContext(); - int nr_executors = 5; - ThreadFactory daemonFactory = new DaemonThreadFactory(); - try { - nr_executors = Integer.parseInt(context.getInitParameter("cache:thread-count")); - } catch (NumberFormatException localNumberFormatException) { - } - if (nr_executors <= 1) - this.executor = Executors.newSingleThreadExecutor(daemonFactory); - else { - this.executor = Executors.newFixedThreadPool(nr_executors, daemonFactory); - } - context.setAttribute("CACHE_EXECUTOR", this.executor); - } - - public void contextDestroyed(ServletContextEvent arg0) { - ServletContext context = arg0.getServletContext(); - this.executor.shutdownNow(); - } + public void contextDestroyed(ServletContextEvent arg0) { + ServletContext context = arg0.getServletContext(); + this.executor.shutdownNow(); + } } \ No newline at end of file diff --git a/src/java/net/brutex/xservices/util/cache/CacheServlet.java b/src/java/net/brutex/xservices/util/cache/CacheServlet.java index 5fe7f38..a223083 100644 --- a/src/java/net/brutex/xservices/util/cache/CacheServlet.java +++ b/src/java/net/brutex/xservices/util/cache/CacheServlet.java @@ -21,11 +21,11 @@ import java.util.ArrayList; import java.util.Enumeration; import java.util.List; import java.util.concurrent.ExecutorService; -import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import net.brutex.xservices.types.scm.ObjectFactory; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; /** * @author Brian Rosenberger, bru(at)brutex.de @@ -35,8 +35,8 @@ import org.apache.log4j.Logger; public class CacheServlet extends HttpServlet { - private final Logger logger = Logger.getLogger(CacheServlet.class); - List configfiles = new ArrayList(); + private static final Logger logger = LogManager.getLogger(); + List configfiles = new ArrayList(); int cacheinterval; private final ObjectFactory FACTORY = new ObjectFactory(); diff --git a/src/java/net/brutex/xservices/util/cache/FindingsCacheServlet.java b/src/java/net/brutex/xservices/util/cache/FindingsCacheServlet.java index 1b99d88..c2a5bf8 100644 --- a/src/java/net/brutex/xservices/util/cache/FindingsCacheServlet.java +++ b/src/java/net/brutex/xservices/util/cache/FindingsCacheServlet.java @@ -38,11 +38,13 @@ import net.brutex.xservices.types.scmfindings.FindingsListType; import net.brutex.xservices.types.scmfindings.GroupMatchListType; import net.brutex.xservices.types.scmfindings.ObjectFactory; import net.brutex.xservices.ws.rs.CVSInfoImpl; -import org.apache.commons.configuration.ConfigurationException; -import org.apache.commons.configuration.PropertiesConfiguration; -import org.apache.jcs.JCS; -import org.apache.jcs.access.exception.CacheException; -import org.apache.log4j.Logger; + +import org.apache.commons.configuration2.PropertiesConfiguration; +import org.apache.commons.configuration2.builder.fluent.Configurations; +import org.apache.commons.configuration2.ex.ConfigurationException; +import org.apache.commons.jcs.access.exception.CacheException; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; /** * @author Brian Rosenberger, bru(at)brutex.de @@ -52,8 +54,7 @@ import org.apache.log4j.Logger; public class FindingsCacheServlet extends HttpServlet { private static final long serialVersionUID = 4041338473949999960L; - private final static Logger logger = Logger - .getLogger(FindingsCacheServlet.class); + private static final Logger logger = LogManager.getLogger(); private final List configfiles = new ArrayList(); private final ObjectFactory FACTORY = new ObjectFactory(); private ExecutorService executor; @@ -70,7 +71,7 @@ public class FindingsCacheServlet extends HttpServlet { int i = 1; for(File f: configfiles) { //Initialise configuration bean using default values - FindingsConfigBean cbean = new FindingsConfigBean(i, Logger.getLogger("worker-"+i+ "." + this.getClass().getName())); + FindingsConfigBean cbean = new FindingsConfigBean(i, LogManager.getLogger("worker-"+i+ "." + this.getClass().getName())); i++; @@ -86,9 +87,10 @@ public class FindingsCacheServlet extends HttpServlet { + cbean.getCacheinterval()+ "' minutes"); } + Configurations configs = new Configurations(); PropertiesConfiguration config = null; try { - config = new PropertiesConfiguration(f); + config = configs.properties(f); } catch (ConfigurationException e) { logger.error("Could not read parameter file at '"+f.getAbsolutePath()+"'"); return; diff --git a/src/java/net/brutex/xservices/util/cache/FindingsConfigBean.java b/src/java/net/brutex/xservices/util/cache/FindingsConfigBean.java index a91d841..e9ed5f1 100644 --- a/src/java/net/brutex/xservices/util/cache/FindingsConfigBean.java +++ b/src/java/net/brutex/xservices/util/cache/FindingsConfigBean.java @@ -19,19 +19,17 @@ package net.brutex.xservices.util.cache; import java.io.File; import java.util.List; -import org.apache.commons.configuration.PropertiesConfiguration; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.Logger; /** * @author Brian Rosenberger, bru(at)brutex.de * */ public class FindingsConfigBean { - - private final Logger logger; - + + private Logger logger; private final int instanceid; - + private File cvsconfig; private int cacheinterval = 15; private List filepatterns; @@ -40,8 +38,8 @@ public class FindingsConfigBean { public FindingsConfigBean(int instanceid, Logger logger) { this.instanceid = instanceid; this.logger = logger; - logger.debug("Initialise FindingsConfigBean instance '"+instanceid+"'"); - + logger.debug("Initialise FindingsConfigBean instance '" + instanceid + "'"); + } /** @@ -52,12 +50,13 @@ public class FindingsConfigBean { } /** - * @param cacheinterval the cache interval to set + * @param cacheinterval + * the cache interval to set */ public void setCacheinterval(int cacheinterval) { this.cacheinterval = cacheinterval; } - + /** * @return the cvsconfig */ @@ -66,7 +65,8 @@ public class FindingsConfigBean { } /** - * @param cvsconfig the cvsconfig to set + * @param cvsconfig + * the cvsconfig to set */ public void setCvsconfig(File cvsconfig) { this.cvsconfig = cvsconfig; @@ -80,7 +80,8 @@ public class FindingsConfigBean { } /** - * @param filepatterns the filepatterns to set + * @param filepatterns + * the filepatterns to set */ public void setFilepatterns(List filepatterns) { this.filepatterns = filepatterns; @@ -94,7 +95,8 @@ public class FindingsConfigBean { } /** - * @param contentpatterns the contentpatterns to set + * @param contentpatterns + * the contentpatterns to set */ public void setContentpatterns(List contentpatterns) { this.contentpatterns = contentpatterns; @@ -103,5 +105,5 @@ public class FindingsConfigBean { /** * @param instanceid */ - + } diff --git a/src/java/net/brutex/xservices/ws/impl/XmlServiceImpl.java b/src/java/net/brutex/xservices/ws/impl/XmlServiceImpl.java index 6f3005f..932a2fe 100644 --- a/src/java/net/brutex/xservices/ws/impl/XmlServiceImpl.java +++ b/src/java/net/brutex/xservices/ws/impl/XmlServiceImpl.java @@ -26,17 +26,12 @@ import java.nio.charset.Charset; import java.nio.charset.IllegalCharsetNameException; import java.util.Iterator; import java.util.List; -import java.util.StringTokenizer; - import javax.jws.WebService; -import javax.ws.rs.NotAuthorizedException; import javax.xml.namespace.QName; import javax.xml.stream.XMLOutputFactory; import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; import javax.xml.stream.XMLStreamWriter; -import net.brutex.xservices.security.DirectoryPermission; import net.brutex.xservices.types.AttributeType; import net.brutex.xservices.types.NamespaceListType; import net.brutex.xservices.types.NamespaceType; @@ -58,9 +53,9 @@ import org.apache.axiom.om.OMProcessingInstruction; import org.apache.axiom.om.OMText; import org.apache.axiom.om.OMXMLBuilderFactory; import org.apache.axiom.om.xpath.AXIOMXPath; -import org.apache.log4j.Logger; -import org.apache.shiro.SecurityUtils; -import org.apache.shiro.authz.UnauthorizedException; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.jaxen.JaxenException; import org.jaxen.SimpleNamespaceContext; @@ -71,18 +66,17 @@ import org.jaxen.SimpleNamespaceContext; */ @WebService(targetNamespace = "http://ws.xservices.brutex.net", endpointInterface = "net.brutex.xservices.ws.XmlService", serviceName = "XmlService") public class XmlServiceImpl implements XmlService { - final Logger logger = Logger.getLogger(XmlServiceImpl.class); + private static final Logger logger = LogManager.getLogger(); - public String insertNodesFromFile(FileResource res, NamespaceListType nsList, String xpath, String xmlFragment) throws XServicesFault { + public String insertNodesFromFile(FileResource res, NamespaceListType nsList, String xpath, String xmlFragment) + throws XServicesFault { try { AXIOMXPath axp = new AXIOMXPath(xpath); InputStream is = res.getAntResource(null).getInputStream(); - OMDocument sourcedoc = OMXMLBuilderFactory.createOMBuilder(is) - .getDocument(); + OMDocument sourcedoc = OMXMLBuilderFactory.createOMBuilder(is).getDocument(); OMDocument fragdoc = null; if ((xmlFragment != null) && (new String(xmlFragment).length() > 0)) { - fragdoc = OMXMLBuilderFactory.createOMBuilder( - new StringReader("" + xmlFragment + "")) + fragdoc = OMXMLBuilderFactory.createOMBuilder(new StringReader("" + xmlFragment + "")) .getDocument(); } else { throw new XServicesFault("No xmldata to insert."); @@ -114,57 +108,56 @@ public class XmlServiceImpl implements XmlService { } } - public String replaceNodesFromFile(FileResource res, NamespaceListType nsList, String xpath, String xmlFragment) throws XServicesFault { + public String replaceNodesFromFile(FileResource res, NamespaceListType nsList, String xpath, String xmlFragment) + throws XServicesFault { try { - AXIOMXPath axp = new AXIOMXPath(xpath); - InputStream is = res.getAntResource(null).getInputStream(); - OMDocument sourcedoc = OMXMLBuilderFactory.createOMBuilder(is).getDocument(); - OMDocument fragdoc = null; - if ((xmlFragment != null) && (new String(xmlFragment).length() > 0)) { - fragdoc = OMXMLBuilderFactory.createOMBuilder( - new StringReader("" + xmlFragment + "")) - .getDocument(); - } else { - throw new XServicesFault("No xmldata to insert."); - } - - // Initialize XPath context - SimpleNamespaceContext context = createContext(nsList); - axp.setNamespaceContext(context); - axp.addNamespaces(fragdoc.getOMDocumentElement()); - - OMDocument document = replaceNodes(sourcedoc, axp, fragdoc); - - StringWriter sw = new StringWriter(); - XMLOutputFactory xof = XMLOutputFactory.newInstance(); - XMLStreamWriter writer = xof.createXMLStreamWriter(sw); - document.serialize(writer); - - this.logger.trace(sw.getBuffer().toString()); - return sw.getBuffer().toString(); - } catch (JaxenException e) { - e.printStackTrace(); - throw new XServicesFault(e); - } catch (XMLStreamException e) { - e.printStackTrace(); - throw new XServicesFault(e); - } catch (IOException e) { - e.printStackTrace(); - throw new XServicesFault(e); + AXIOMXPath axp = new AXIOMXPath(xpath); + InputStream is = res.getAntResource(null).getInputStream(); + OMDocument sourcedoc = OMXMLBuilderFactory.createOMBuilder(is).getDocument(); + OMDocument fragdoc = null; + if ((xmlFragment != null) && (new String(xmlFragment).length() > 0)) { + fragdoc = OMXMLBuilderFactory.createOMBuilder(new StringReader("" + xmlFragment + "")) + .getDocument(); + } else { + throw new XServicesFault("No xmldata to insert."); } + + // Initialize XPath context + SimpleNamespaceContext context = createContext(nsList); + axp.setNamespaceContext(context); + axp.addNamespaces(fragdoc.getOMDocumentElement()); + + OMDocument document = replaceNodes(sourcedoc, axp, fragdoc); + + StringWriter sw = new StringWriter(); + XMLOutputFactory xof = XMLOutputFactory.newInstance(); + XMLStreamWriter writer = xof.createXMLStreamWriter(sw); + document.serialize(writer); + + this.logger.trace(sw.getBuffer().toString()); + return sw.getBuffer().toString(); + } catch (JaxenException e) { + e.printStackTrace(); + throw new XServicesFault(e); + } catch (XMLStreamException e) { + e.printStackTrace(); + throw new XServicesFault(e); + } catch (IOException e) { + e.printStackTrace(); + throw new XServicesFault(e); + } } - public String replaceNodes(String source, String encoding, NamespaceListType nsList, String xpath, String xmlFragment) throws XServicesFault { + public String replaceNodes(String source, String encoding, NamespaceListType nsList, String xpath, + String xmlFragment) throws XServicesFault { encoding = validateEncoding(encoding); try { AXIOMXPath axp = new AXIOMXPath(xpath); InputStream is = new ByteArrayInputStream(source.getBytes(encoding)); - OMDocument sourcedoc = OMXMLBuilderFactory.createOMBuilder(is) - .getDocument(); + OMDocument sourcedoc = OMXMLBuilderFactory.createOMBuilder(is).getDocument(); OMDocument fragdoc = null; if ((xmlFragment != null) && (new String(xmlFragment).length() > 0)) { - fragdoc = OMXMLBuilderFactory.createOMBuilder( - new StringReader("" + xmlFragment + "")) + fragdoc = OMXMLBuilderFactory.createOMBuilder(new StringReader("" + xmlFragment + "")) .getDocument(); } else { throw new XServicesFault("No xmldata to insert."); @@ -194,19 +187,18 @@ public class XmlServiceImpl implements XmlService { throw new XServicesFault(e); } } - + @RequiresPermissions("insertNodes") - public String insertNodes(String source, String encoding, NamespaceListType nsList, String xpath, String xmlFragment) throws XServicesFault { + public String insertNodes(String source, String encoding, NamespaceListType nsList, String xpath, + String xmlFragment) throws XServicesFault { encoding = validateEncoding(encoding); try { AXIOMXPath axp = new AXIOMXPath(xpath); InputStream is = new ByteArrayInputStream(source.getBytes(encoding)); - OMDocument sourcedoc = OMXMLBuilderFactory.createOMBuilder(is) - .getDocument(); + OMDocument sourcedoc = OMXMLBuilderFactory.createOMBuilder(is).getDocument(); OMDocument fragdoc = null; if ((xmlFragment != null) && (new String(xmlFragment).length() > 0)) { - fragdoc = OMXMLBuilderFactory.createOMBuilder( - new StringReader("" + xmlFragment + "")) + fragdoc = OMXMLBuilderFactory.createOMBuilder(new StringReader("" + xmlFragment + "")) .getDocument(); } else { throw new XServicesFault("No xmldata to insert."); @@ -238,75 +230,77 @@ public class XmlServiceImpl implements XmlService { } public String wrapInCDATA(String data) throws XServicesFault { - String result =""; + String result = ""; String[] tokens = data.split("\\]\\]>", -1); - - for(int i=0; i"; return result; } - public StringSplitType selectXPath(String source, String encoding, NamespaceListType nsList, String xpath) throws XServicesFault { + public StringSplitType selectXPath(String source, String encoding, NamespaceListType nsList, String xpath) + throws XServicesFault { encoding = validateEncoding(encoding); try { StringSplitType rarray = new StringSplitType(); AXIOMXPath axp = new AXIOMXPath(xpath); InputStream is = new ByteArrayInputStream(source.getBytes(encoding)); OMDocument sourcedoc = OMXMLBuilderFactory.createOMBuilder(is).getDocument(); - + // Initialize XPath context SimpleNamespaceContext context = createContext(nsList); - + axp.setNamespaceContext(context); List results = axp.selectNodes(sourcedoc); - for(Object o : results) { + for (Object o : results) { String text = null; - - if(o instanceof OMNode) { - switch (((OMNode)o).getType()) { - case OMNode.TEXT_NODE: - text = ((OMText)o).getText(); - break; - case OMNode.COMMENT_NODE: - text = ((OMComment)o).getValue(); - break; - case OMNode.PI_NODE: - text = ((OMProcessingInstruction)o).getValue(); - break; - default: - StringWriter sw = new StringWriter(); - XMLOutputFactory xof = XMLOutputFactory.newInstance(); - XMLStreamWriter writer = xof.createXMLStreamWriter(sw); - ((OMNode)o).serialize(writer); - writer.flush(); - text = sw.toString(); - } - } else if(o instanceof OMAttribute) { - text = ((OMAttribute)o).getAttributeValue(); + + if (o instanceof OMNode) { + switch (((OMNode) o).getType()) { + case OMNode.TEXT_NODE: + text = ((OMText) o).getText(); + break; + case OMNode.COMMENT_NODE: + text = ((OMComment) o).getValue(); + break; + case OMNode.PI_NODE: + text = ((OMProcessingInstruction) o).getValue(); + break; + default: + StringWriter sw = new StringWriter(); + XMLOutputFactory xof = XMLOutputFactory.newInstance(); + XMLStreamWriter writer = xof.createXMLStreamWriter(sw); + ((OMNode) o).serialize(writer); + writer.flush(); + text = sw.toString(); + } + } else if (o instanceof OMAttribute) { + text = ((OMAttribute) o).getAttributeValue(); } else { text = String.valueOf(o); } rarray.addStringMatch(text); } - return rarray; - } catch (JaxenException e) { + } catch (JaxenException e) { e.printStackTrace(); throw new XServicesFault(e); } catch (XMLStreamException e) { - // TODO Auto-generated catch block + // TODO Auto-generated catch block throw new XServicesFault(e.getMessage()); - } catch (UnsupportedEncodingException e) { - throw new XServicesFault(e); + } catch (UnsupportedEncodingException e) { + throw new XServicesFault(e); } } - - public String setAttribute(String source, String encoding, NamespaceListType nsList, String xpath, AttributeType attr) throws XServicesFault { + + public String setAttribute(String source, String encoding, NamespaceListType nsList, String xpath, + AttributeType attr) throws XServicesFault { encoding = validateEncoding(encoding); try { StringSplitType rarray = new StringSplitType(); @@ -314,64 +308,62 @@ public class XmlServiceImpl implements XmlService { InputStream is = new ByteArrayInputStream(source.getBytes(encoding)); OMDocument sourcedoc = OMXMLBuilderFactory.createOMBuilder(is).getDocument(); OMFactory fac = OMAbstractFactory.getOMFactory(); - + // Initialize XPath context SimpleNamespaceContext context = createContext(nsList); - + axp.setNamespaceContext(context); List results = axp.selectNodes(sourcedoc); - for(Object o : results) { + for (Object o : results) { String text = null; - - if(o instanceof OMNode) { - switch (((OMNode)o).getType()) { - case OMNode.ELEMENT_NODE: - OMElement node = ((OMElement)o); - if(attr.value == null) { - node.removeAttribute( node.getAttribute(new QName(attr.name))); - } else { - node.addAttribute(attr.name, attr.value, node.getNamespace()); - } - break; - default: - throw new XServicesFault("XPath expression did not match an element node."); + + if (o instanceof OMNode) { + switch (((OMNode) o).getType()) { + case OMNode.ELEMENT_NODE: + OMElement node = ((OMElement) o); + if (attr.value == null) { + node.removeAttribute(node.getAttribute(new QName(attr.name))); + } else { + node.addAttribute(attr.name, attr.value, node.getNamespace()); + } + break; + default: + throw new XServicesFault("XPath expression did not match an element node."); } } else { throw new XServicesFault("XPath expression did not match a node."); } } - + StringWriter sw = new StringWriter(); XMLOutputFactory xof = XMLOutputFactory.newInstance(); XMLStreamWriter writer = xof.createXMLStreamWriter(sw); sourcedoc.serialize(writer); writer.flush(); - return sw.toString(); - } catch (JaxenException e) { + return sw.toString(); + } catch (JaxenException e) { e.printStackTrace(); throw new XServicesFault(e); } catch (XMLStreamException e) { - // TODO Auto-generated catch block + // TODO Auto-generated catch block throw new XServicesFault(e.getMessage()); - } catch (UnsupportedEncodingException e) { - throw new XServicesFault(e); + } catch (UnsupportedEncodingException e) { + throw new XServicesFault(e); } } - - private OMDocument insertNodes(OMDocument xmldocument, AXIOMXPath axp,OMDocument xmlfragment) throws XServicesFault { + + private OMDocument insertNodes(OMDocument xmldocument, AXIOMXPath axp, OMDocument xmlfragment) + throws XServicesFault { List olist = null; try { olist = axp.selectNodes(xmldocument.getOMDocumentElement()); - this.logger.debug("XPath '" + axp.toString() + "' has " - + olist.size() + " matches."); - this.logger.trace("XPath root expression is: '" + axp.debug() - + "'."); + this.logger.debug("XPath '" + axp.toString() + "' has " + olist.size() + " matches."); + this.logger.trace("XPath root expression is: '" + axp.debug() + "'."); } catch (JaxenException e) { throw new XServicesFault(e.getMessage(), e); } if (olist.size() == 0) - throw new XServicesFault(Messages.getString("XmlService.no_match", - new Object[] { axp.toString() })); + throw new XServicesFault(Messages.getString("XmlService.no_match", new Object[] { axp.toString() })); // Prepare children to insert xmlfragment.build(); @@ -379,8 +371,7 @@ public class XmlServiceImpl implements XmlService { // Determine what has been matched OMContainer match = null; for (Object o : olist) { - Iterator children = xmlfragment.getOMDocumentElement() - .getChildren(); + Iterator children = xmlfragment.getOMDocumentElement().getChildren(); if ((o instanceof OMNode)) { OMNode node = (OMNode) o; switch (node.getType()) { @@ -401,16 +392,13 @@ public class XmlServiceImpl implements XmlService { this.logger.debug(Messages.getString("XmlService.10")); break; default: - this.logger.error("XPath matched " - + o.getClass().getCanonicalName() + " Node Type:" - + node.getType()); + this.logger + .error("XPath matched " + o.getClass().getCanonicalName() + " Node Type:" + node.getType()); this.logger.error(Messages.getString("XmlService.11")); - throw new XServicesFault( - Messages.getString("XmlService.12")); + throw new XServicesFault(Messages.getString("XmlService.12")); } } else { - this.logger.error("XPath matched " - + o.getClass().getCanonicalName()); + this.logger.error("XPath matched " + o.getClass().getCanonicalName()); this.logger.error(Messages.getString("XmlService.11")); throw new XServicesFault(Messages.getString("XmlService.12")); } @@ -425,22 +413,19 @@ public class XmlServiceImpl implements XmlService { return xmldocument; } + private OMDocument replaceNodes(OMDocument xmldocument, AXIOMXPath axp, OMDocument xmlfragment) + throws XServicesFault { - private OMDocument replaceNodes(OMDocument xmldocument, AXIOMXPath axp, OMDocument xmlfragment) throws XServicesFault { - List olist = null; try { olist = axp.selectNodes(xmldocument.getOMDocumentElement()); - this.logger.debug("XPath '" + axp.toString() + "' has " - + olist.size() + " matches."); - this.logger.trace("XPath root expression is: '" + axp.debug() - + "'."); + this.logger.debug("XPath '" + axp.toString() + "' has " + olist.size() + " matches."); + this.logger.trace("XPath root expression is: '" + axp.debug() + "'."); } catch (JaxenException e) { throw new XServicesFault(e.getMessage(), e); } if (olist.size() == 0) - throw new XServicesFault(Messages.getString("XmlService.no_match", - new Object[] { axp.toString() })); + throw new XServicesFault(Messages.getString("XmlService.no_match", new Object[] { axp.toString() })); // Prepare children to insert xmlfragment.build(); @@ -448,8 +433,7 @@ public class XmlServiceImpl implements XmlService { // Determine what has been matched OMNode match = null; for (Object o : olist) { - Iterator children = xmlfragment.getOMDocumentElement() - .getChildren(); + Iterator children = xmlfragment.getOMDocumentElement().getChildren(); if ((o instanceof OMNode)) { OMNode node = (OMNode) o; switch (node.getType()) { @@ -461,16 +445,13 @@ public class XmlServiceImpl implements XmlService { this.logger.debug(Messages.getString("XmlService.8")); break; default: - this.logger.error("XPath matched " - + o.getClass().getCanonicalName() + " Node Type:" - + node.getType()); + this.logger + .error("XPath matched " + o.getClass().getCanonicalName() + " Node Type:" + node.getType()); this.logger.error(Messages.getString("XmlService.11")); - throw new XServicesFault( - Messages.getString("XmlService.12")); + throw new XServicesFault(Messages.getString("XmlService.12")); } } else { - this.logger.error("XPath matched " - + o.getClass().getCanonicalName()); + this.logger.error("XPath matched " + o.getClass().getCanonicalName()); this.logger.error(Messages.getString("XmlService.11")); throw new XServicesFault(Messages.getString("XmlService.12")); } @@ -488,12 +469,11 @@ public class XmlServiceImpl implements XmlService { private SimpleNamespaceContext createContext(NamespaceListType nsList) { // Initialize XPath context SimpleNamespaceContext context = new SimpleNamespaceContext(); - if(nsList != null) { + if (nsList != null) { for (NamespaceType ns : nsList.getNamespaces()) { context.addNamespace(ns.getPrefix(), ns.getUri().toString()); - this.logger.debug(Messages.getString("XmlService.0") - + ns.getPrefix() + "=\"" + ns.getUri().toString() - + "\"'"); + this.logger.debug( + Messages.getString("XmlService.0") + ns.getPrefix() + "=\"" + ns.getUri().toString() + "\"'"); } } else { logger.debug("No namespaces defined."); @@ -502,15 +482,16 @@ public class XmlServiceImpl implements XmlService { } private String validateEncoding(String encoding) throws XServicesFault { - if(encoding == null || encoding.equals("")) { encoding=Charset.defaultCharset().displayName(); } - try { + if (encoding == null || encoding.equals("")) { + encoding = Charset.defaultCharset().displayName(); + } + try { Charset.isSupported(encoding); } catch (IllegalCharsetNameException e) { - throw new XServicesFault("Endcoding '"+encoding+"' is not supported by this JRE."); + throw new XServicesFault("Endcoding '" + encoding + "' is not supported by this JRE."); } - logger.debug("Setting source xml string encoding to '"+encoding+"'"); + logger.debug("Setting source xml string encoding to '" + encoding + "'"); return encoding; } - } diff --git a/src/java/net/brutex/xservices/ws/rs/CVSInfoImpl.java b/src/java/net/brutex/xservices/ws/rs/CVSInfoImpl.java index a4fc6dd..f88a141 100644 --- a/src/java/net/brutex/xservices/ws/rs/CVSInfoImpl.java +++ b/src/java/net/brutex/xservices/ws/rs/CVSInfoImpl.java @@ -8,9 +8,10 @@ import java.io.PrintStream; import java.net.URI; import java.util.List; import java.util.StringTokenizer; + import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.ResponseBuilder; + import net.brutex.xservices.types.scm.AttributeType; import net.brutex.xservices.types.scm.ItemListType; import net.brutex.xservices.types.scm.ItemType; @@ -23,10 +24,13 @@ import net.brutex.xservices.types.scmfindings.FindingsListType; import net.brutex.xservices.util.BasicCVSListener; import net.brutex.xservices.util.CVSClient; import net.brutex.xservices.util.CVSRoot; -import org.apache.commons.configuration.ConfigurationException; -import org.apache.jcs.JCS; -import org.apache.jcs.access.exception.CacheException; -import org.apache.log4j.Logger; + +import org.apache.commons.configuration2.ex.ConfigurationException; +import org.apache.commons.jcs.JCS; +import org.apache.commons.jcs.access.CacheAccess; +import org.apache.commons.jcs.access.exception.CacheException; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.netbeans.lib.cvsclient.Client; import org.netbeans.lib.cvsclient.command.CommandAbortedException; import org.netbeans.lib.cvsclient.command.CommandException; @@ -42,14 +46,14 @@ import org.netbeans.lib.cvsclient.event.EventManager; import org.netbeans.lib.cvsclient.event.FileInfoEvent; public class CVSInfoImpl implements CVSInfo { - final Logger logger = Logger.getLogger(CVSInfoImpl.class); + private static final Logger logger = LogManager.getLogger(); final ObjectFactory FACTORY = new ObjectFactory(); final ItemListType list = this.FACTORY.createItemListType(); public Response getRepositoryFiles(HttpHeaders h, File f, String modules, boolean isRecursive, boolean showRevisions, boolean forceNoCache) { String cachekey = "getFiles" + f.toURI().toString(); - this.logger.debug("forceNoCache=" + forceNoCache); + CVSInfoImpl.logger.debug("forceNoCache=" + forceNoCache); ItemListType cacheresult = (ItemListType) getCacheInstance().get( cachekey); @@ -117,7 +121,7 @@ public class CVSInfoImpl implements CVSInfo { try { CVSInfoImpl.this.getCacheInstance().put(key, cvsfile); } catch (CacheException e) { - CVSInfoImpl.this.logger.error("Could not cache item '" + CVSInfoImpl.logger.error("Could not cache item '" + key + "'", e); } } @@ -138,14 +142,14 @@ public class CVSInfoImpl implements CVSInfo { rlog.setRecursive(isRecursive); - this.logger.info("Executing CVS command '" + rlog.getCVSCommand() + CVSInfoImpl.logger.info("Executing CVS command '" + rlog.getCVSCommand() + "' against '" + cvsclient.getRoot().host + "@" + cvsclient.getRoot().repository + "'"); client.executeCommand(rlog, cvsclient.getGlobalOptions()); getCacheInstance().put(cachekey, this.list); } catch (ConfigurationException e) { - this.logger.error("CVS Configuration File '" + f.getAbsolutePath() + CVSInfoImpl.logger.error("CVS Configuration File '" + f.getAbsolutePath() + f.getName() + "'not found.", e); } catch (CommandAbortedException e) { e.printStackTrace(); @@ -168,7 +172,7 @@ public class CVSInfoImpl implements CVSInfo { public Response getModules(HttpHeaders h, File f, boolean forceNoCache) { String cachekey = "Modules" + f.toURI().toString(); - this.logger.debug("forceNoCache=" + forceNoCache); + CVSInfoImpl.logger.debug("forceNoCache=" + forceNoCache); ModuleListType response = (ModuleListType) getCacheInstance().get( cachekey); @@ -196,12 +200,12 @@ public class CVSInfoImpl implements CVSInfo { CheckoutCommand co = new CheckoutCommand(); co.setShowModulesWithStatus(true); - this.logger.info("Executing CVS command '" + co.getCVSCommand() + CVSInfoImpl.logger.info("Executing CVS command '" + co.getCVSCommand() + "' against '" + cvsclient.getRoot().host + "@" + cvsclient.getRoot().repository + "'"); client.executeCommand(co, cvsclient.getGlobalOptions()); if (list.getModules().size() == 0) { - this.logger.warn("Repository '" + CVSInfoImpl.logger.warn("Repository '" + cvsclient.getRoot().repository + "' does not have modules"); } @@ -216,14 +220,14 @@ public class CVSInfoImpl implements CVSInfo { public Response getTags(HttpHeaders h, File f, boolean withFiles) { String cachekey = f.toURI().toString() + ":taglist"; - this.logger.debug("Retrieving Tags from cache using key '" + cachekey + CVSInfoImpl.logger.debug("Retrieving Tags from cache using key '" + cachekey + "'"); TagListType tags = (TagListType) getCacheInstance().get(cachekey); if (tags != null) { - this.logger.debug("Delivering Tags from cache."); + CVSInfoImpl.logger.debug("Delivering Tags from cache."); return Response.ok(tags).build(); } - this.logger.warn("Taglist not found in cache."); + CVSInfoImpl.logger.warn("Taglist not found in cache."); return Response.noContent().build(); } @@ -235,17 +239,17 @@ public class CVSInfoImpl implements CVSInfo { ItemListType list = null; if (!forceNoCache) { - this.logger.debug("Retrieving file content from cache using key '" + CVSInfoImpl.logger.debug("Retrieving file content from cache using key '" + cachekey + "'"); list = (ItemListType) getCacheInstance().get(cachekey); } if (list != null) { - this.logger.debug("Delivering file content from cache."); + CVSInfoImpl.logger.debug("Delivering file content from cache."); return Response.ok(list).build(); } - this.logger.warn("File content not found in cache."); + CVSInfoImpl.logger.warn("File content not found in cache."); list = this.FACTORY.createItemListType(); try { CVSClient cvsclient = new CVSClient(f); @@ -302,7 +306,7 @@ public class CVSInfoImpl implements CVSInfo { checkout.setModule(filestring); checkout.setPipeToOutput(true); - this.logger.info("Execute CVS command '" + checkout.getCVSCommand() + CVSInfoImpl.logger.info("Execute CVS command '" + checkout.getCVSCommand() + "' against '" + cvsclient.getRoot().host + "@" + cvsclient.getRoot().repository + "'"); client.executeCommand(checkout, cvsclient.getGlobalOptions()); @@ -322,14 +326,14 @@ public class CVSInfoImpl implements CVSInfo { return Response.noContent().build(); } - public JCS getCacheInstance() { - JCS jcs = null; + public CacheAccess getCacheInstance() { + CacheAccess jcs = null; String cacheinstance = "CVSCache"; try { - this.logger.trace("Getting cache instance named 'CVSCache'"); + CVSInfoImpl.logger.trace("Getting cache instance named 'CVSCache'"); jcs = JCS.getInstance("CVSCache"); } catch (CacheException e) { - this.logger.error("Failed to get cache instance", e); + CVSInfoImpl.logger.error("Failed to get cache instance", e); e.printStackTrace(); } return jcs; @@ -343,16 +347,16 @@ public class CVSInfoImpl implements CVSInfo { + client.getRoot().repository; String cachestring = "FINDINGS-" + cvsroot; - this.logger + CVSInfoImpl.logger .debug("Fetch searchFileContent response from cache using cachekey '" + cachestring + "'"); FindingsListType result = (FindingsListType) getCacheInstance() .get(cachestring); if (result != null) - this.logger.debug("Found object for key '" + cachestring + CVSInfoImpl.logger.debug("Found object for key '" + cachestring + "' in cache."); else { - this.logger.debug("Found no object for key '" + cachestring + CVSInfoImpl.logger.debug("Found no object for key '" + cachestring + "' in cache."); } diff --git a/src/java/net/brutex/xservices/ws/rs/DIMCMInfo.java b/src/java/net/brutex/xservices/ws/rs/DIMCMInfo.java index a0a24fc..0fd6034 100644 --- a/src/java/net/brutex/xservices/ws/rs/DIMCMInfo.java +++ b/src/java/net/brutex/xservices/ws/rs/DIMCMInfo.java @@ -28,7 +28,7 @@ import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; -import org.apache.jcs.access.exception.CacheException; +import org.apache.commons.jcs.access.exception.CacheException; import net.brutex.xservices.ws.XServicesFault; diff --git a/src/java/net/brutex/xservices/ws/rs/DIMCMInfoImpl.java b/src/java/net/brutex/xservices/ws/rs/DIMCMInfoImpl.java index b48aa2a..80aea0d 100644 --- a/src/java/net/brutex/xservices/ws/rs/DIMCMInfoImpl.java +++ b/src/java/net/brutex/xservices/ws/rs/DIMCMInfoImpl.java @@ -33,16 +33,20 @@ import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; +import org.apache.commons.configuration2.PropertiesConfiguration; +import org.apache.commons.configuration2.builder.fluent.Configurations; +import org.apache.commons.configuration2.ex.ConfigurationException; +import org.apache.commons.jcs.JCS; +import org.apache.commons.jcs.access.CacheAccess; +import org.apache.commons.jcs.access.exception.CacheException; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import net.brutex.xservices.cmtypes.ItemType; import net.brutex.xservices.cmtypes.ItemTypeList; import net.brutex.xservices.types.FileInfoType; import net.brutex.xservices.util.FileWalker; -import org.apache.commons.configuration.ConfigurationException; -import org.apache.commons.configuration.PropertiesConfiguration; -import org.apache.jcs.JCS; -import org.apache.jcs.access.exception.CacheException; -import org.apache.log4j.Logger; /* @@ -76,7 +80,7 @@ import com.serena.dmclient.api.SystemAttributes; */ public class DIMCMInfoImpl implements DIMCMInfo { - Logger logger = Logger.getLogger(DIMCMInfoImpl.class); + Logger logger = LogManager.getLogger(); /* * (non-Javadoc) @@ -93,7 +97,7 @@ public class DIMCMInfoImpl implements DIMCMInfo { /* * try to hit cache first */ - JCS cache = JCS.getInstance("DIMCM"); + CacheAccess cache = JCS.getInstance("DIMCM"); String cachekey = projSpec + directory + String.valueOf(recursive); if(useCache) { ItemTypeList cacheresult = (ItemTypeList) cache.get(cachekey); @@ -328,7 +332,8 @@ public class DIMCMInfoImpl implements DIMCMInfo { */ PropertiesConfiguration props; try { - props = new PropertiesConfiguration(this.getClass() + + props = new Configurations().properties(this.getClass() .getClassLoader().getResource("/../dimcm.properties")); } catch (ConfigurationException e) { e.printStackTrace(); @@ -349,11 +354,13 @@ public class DIMCMInfoImpl implements DIMCMInfo { private String getBaseURL() { final String CACHE_BASEURL = "DIMCM.conf.baseurl"; try { - JCS cache = JCS.getInstance("DIMCM"); + CacheAccess cache = JCS.getInstance("DIMCM"); String baseurl = (String) cache.get(CACHE_BASEURL); if(baseurl != null) return baseurl; - PropertiesConfiguration props = new PropertiesConfiguration(this.getClass().getClassLoader().getResource("/../dimcm.properties")); + Configurations configs = new Configurations(); + + PropertiesConfiguration props = configs.properties((this.getClass().getClassLoader().getResource("/../dimcm.properties"))); baseurl = props.getString("baseurl"); cache.put(CACHE_BASEURL, baseurl); return baseurl; diff --git a/src/java/net/brutex/xservices/ws/rs/FileInfoImpl.java b/src/java/net/brutex/xservices/ws/rs/FileInfoImpl.java index 9670c12..a1ea200 100644 --- a/src/java/net/brutex/xservices/ws/rs/FileInfoImpl.java +++ b/src/java/net/brutex/xservices/ws/rs/FileInfoImpl.java @@ -51,9 +51,11 @@ import net.brutex.xservices.security.DirectoryPermission; import net.brutex.xservices.types.FileInfoType; import net.brutex.xservices.util.FileWalker; -import org.apache.jcs.JCS; -import org.apache.jcs.access.exception.CacheException; -import org.apache.log4j.Logger; +import org.apache.commons.jcs.JCS; +import org.apache.commons.jcs.access.CacheAccess; +import org.apache.commons.jcs.access.exception.CacheException; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.apache.shiro.SecurityUtils; import org.apache.shiro.authz.UnauthorizedException; @@ -65,7 +67,7 @@ import org.apache.shiro.authz.UnauthorizedException; public class FileInfoImpl implements FileInfo { - Logger logger = Logger.getLogger(FileInfoImpl.class); + Logger logger = LogManager.getLogger(); /* (non-Javadoc) @@ -88,7 +90,7 @@ public class FileInfoImpl implements FileInfo { String cachekey = level + "||" + withFiles + "||" + withDir + "||" + search + "||" + dir; try { logger.debug(String.format("Hitting cache with cachekey '%s'", cachekey)); - JCS jcs = JCS.getInstance("FileCache"); + CacheAccess jcs = JCS.getInstance("FileCache"); /*Try to retrieve the file list from the cache*/ List list = (List)jcs.get(cachekey); diff --git a/test/DateService-soapui-project.xml b/test/DateService-soapui-project.xml index 1749ecb..4512b4b 100644 --- a/test/DateService-soapui-project.xml +++ b/test/DateService-soapui-project.xml @@ -1,5 +1,5 @@ - + @@ -28,7 +28,7 @@ -]]>http://localhost:8080/XServices/DateService?wsdl +]]>http://localhost:8080/XServices/DateService?wsdl /* * Copyright 2010 Brian Rosenberger (Brutex Network) * @@ -571,17 +571,17 @@ -]]>http://schemas.xmlsoap.org/wsdl/http://localhost:8080/XServices/DateService<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService +]]>http://schemas.xmlsoap.org/wsdl/http://localhost:8080/XServices/DateService<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService -]]><xml-fragment/>UTF-8http://localhost:8080/XServices/DateService +]]><xml-fragment/>UTF-8http://localhost:8080/XServices/DateService -]]><xml-fragment/>UTF-8http://localhost:8080/XServices/DateService +]]><xml-fragment/>UTF-8http://localhost:8080/XServices/DateService @@ -589,7 +589,7 @@ Pacific/Honolulu -]]><xml-fragment/>UTF-8http://localhost:8080/XServices/DateService +]]><xml-fragment/>UTF-8http://localhost:8080/XServices/DateService @@ -597,7 +597,7 @@ UTC -]]><xml-fragment/>UTF-8http://localhost:8080/XServices/DateService +]]><xml-fragment/>UTF-8http://localhost:8080/XServices/DateService @@ -605,7 +605,7 @@ ISO8601 -]]><xml-fragment/>UTF-8http://localhost:8080/XServices/DateService +]]><xml-fragment/>UTF-8http://localhost:8080/XServices/DateService @@ -613,7 +613,7 @@ mmddyyyy-WW -]]><xml-fragment/>UTF-8http://localhost:8080/XServices/DateService +]]><xml-fragment/>UTF-8http://localhost:8080/XServices/DateService @@ -623,7 +623,7 @@ -]]><xml-fragment/>UTF-8http://localhost:8080/XServices/DateService +]]><xml-fragment/>UTF-8http://localhost:8080/XServices/DateService @@ -633,7 +633,7 @@ Europe/Berlin -]]><xml-fragment/>UTF-8http://localhost:8080/XServices/DateService +]]><xml-fragment/>UTF-8http://localhost:8080/XServices/DateService @@ -641,7 +641,7 @@ 2012-06-06T08:23:00+01:00 -]]>Global HTTP Settings<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService +]]>Global HTTP Settings<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService @@ -649,7 +649,7 @@ 2012-06-06T08:45:00+01:00 -]]>Global HTTP Settings<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService +]]>Global HTTP Settings<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService @@ -659,7 +659,7 @@ years -]]>Global HTTP Settings<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService +]]>Global HTTP Settings<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService @@ -668,54 +668,54 @@ hours -]]>UTF-8http://localhost:8080/XServices/DateService +]]>UTF-8http://localhost:8080/XServices/DateService -]]><xml-fragment/>UTF-8http://localhost:8080/XServices/DateService +]]><xml-fragment/>UTF-8http://localhost:8080/XServices/DateService -]]><xml-fragment/>UTF-8http://localhost:8080/XServices/DateService +]]><xml-fragment/>UTF-8http://localhost:8080/XServices/DateService -]]>PARALLELL<xml-fragment/>http://localhost:8080/XServices/DateServices?wsdl +]]>PARALLELL<xml-fragment/>http://localhost:8080/XServices/DateServices?wsdl -]]>http://localhost:8080/XServices/DateServiceswsdlQUERYxs:stringDateServiceSoapBindinggetDate<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService +]]>http://localhost:8080/XServices/DateServiceswsdlQUERYxs:stringDateServiceSoapBindinggetDate<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService -]]>Global HTTP SettingsDateServiceSoapBindinggetDateExtended<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService +]]>adminBasicBasicGlobal HTTP SettingsDateServiceSoapBindinggetDateExtended<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService -]]>Global HTTP SettingsDateServiceSoapBindinggetTimestamp<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService +]]>BasicBasicGlobal HTTP SettingsDateServiceSoapBindinggetTimestamp<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService -]]>Global HTTP SettingsDateServiceSoapBindinggetTimezones<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService +]]>BasicBasicGlobal HTTP SettingsDateServiceSoapBindinggetTimezones<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService -]]>50Global HTTP SettingsDateServiceSoapBindinggetTimestamp2<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService +]]>50BasicBasicGlobal HTTP SettingsDateServiceSoapBindinggetTimestamp2<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService -]]>Global HTTP Settingsfalse50250truetrue-160TIMESimple100true500Loops0DateServiceSoapBindingformatDate<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService +]]>BasicBasicGlobal HTTP Settingsfalse50250truetrue-160TIMESimple100true500Loops0DateServiceSoapBindingformatDate<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService @@ -723,7 +723,7 @@ ISO 8601 -]]>Global HTTP SettingsDateServiceSoapBindingformatDate<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService +]]>Global HTTP SettingsDateServiceSoapBindingformatDate<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService @@ -731,7 +731,7 @@ RFC 822 -]]>Global HTTP SettingsDateServiceSoapBindingformatDate<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService +]]>Global HTTP SettingsDateServiceSoapBindingformatDate<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService @@ -739,7 +739,7 @@ DateOnly-dashed -]]>Global HTTP SettingsDateServiceSoapBindingformatDate<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService +]]>Global HTTP SettingsDateServiceSoapBindingformatDate<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService @@ -747,7 +747,7 @@ DateOnly-dotted -]]>Global HTTP SettingsDateServiceSoapBindingformatDateAdvanced<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService +]]>BasicBasicGlobal HTTP SettingsDateServiceSoapBindingformatDateAdvanced<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService @@ -756,7 +756,7 @@ 'Year:' yyyy 'Week:' WW 'in Month:' MMMM -]]>Global HTTP SettingsDateServiceSoapBindingformatDate<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService +]]>Global HTTP SettingsDateServiceSoapBindingformatDate<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService @@ -764,7 +764,7 @@ DateOnly-slashed -]]>Global HTTP SettingsDateServiceSoapBindingparseDate<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService +]]>Global HTTP SettingsDateServiceSoapBindingparseDate<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService @@ -774,7 +774,7 @@ Europe/Helsinki -]]>Global HTTP SettingsDateServiceSoapBindingparseDateAdvanced<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService +]]>Global HTTP SettingsDateServiceSoapBindingparseDateAdvanced<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService @@ -784,17 +784,17 @@ Europe/Berlin -]]>Global HTTP SettingsDateServiceSoapBindingparseDateAdvanced<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService +]]>BasicBasicGlobal HTTP SettingsDateServiceSoapBindingparseDateAdvanced<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService - Im Juni am 4. Tag im Jahr 2014 ist ein Fest - 'Im' MMMM 'am' d. 'Tag im Jahr' yyyy 'ist ein Fest' + Im June am 4. Tag im Jahr 2014 ist ein Fest + 'Im 'MMMM' am 'd.' Tag im Jahr 'yyyy' ist ein Fest' Europe/Berlin -]]>Global HTTP Settingsfalse200250truetrue-1180TIMEVariance600000.5100true500DateServiceSoapBindingdateTimeDiff<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService +]]>BasicBasicGlobal HTTP Settingsfalse200250truetrue-1180TIMEVariance600000.5100true500DateServiceSoapBindingdateTimeDiff<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService @@ -802,7 +802,7 @@ 2012-06-06T08:45:00+01:00 -]]>Global HTTP SettingsDateServiceSoapBindingdateTimeDiff<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService +]]>Global HTTP SettingsDateServiceSoapBindingdateTimeDiff<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService @@ -810,7 +810,7 @@ 2012-01-23 -]]>Global HTTP SettingsDateServiceSoapBindingdateTimeDiff2<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService +]]>Global HTTP SettingsDateServiceSoapBindingdateTimeDiff2<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService @@ -820,7 +820,7 @@ days -]]>Global HTTP SettingsDateServiceSoapBindingdateTimeDiff2<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService +]]>Global HTTP SettingsDateServiceSoapBindingdateTimeDiff2<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService @@ -830,7 +830,7 @@ years -]]>Global HTTP SettingsDateServiceSoapBindingdateTimeDiff2<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService +]]>Global HTTP SettingsDateServiceSoapBindingdateTimeDiff2<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService @@ -840,7 +840,7 @@ minutes -]]>Global HTTP SettingsDateServiceSoapBindingdateTimeDiff2<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService +]]>Global HTTP SettingsDateServiceSoapBindingdateTimeDiff2<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService @@ -850,7 +850,7 @@ milliseconds -]]>Global HTTP SettingsDateServiceSoapBindingdateTimeDiff2<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService +]]>Global HTTP SettingsDateServiceSoapBindingdateTimeDiff2<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService @@ -860,7 +860,7 @@ seconds -]]>Global HTTP SettingsDateServiceSoapBindingdateTimeDiff2<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService +]]>Global HTTP SettingsDateServiceSoapBindingdateTimeDiff2<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService @@ -870,7 +870,7 @@ milliseconds -]]>Global HTTP SettingsDateServiceSoapBindingdateAdd<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService +]]>Global HTTP SettingsDateServiceSoapBindingdateAdd<xml-fragment/>UTF-8http://localhost:8080/XServices/DateService @@ -879,4 +879,4 @@ seconds -]]>Global HTTP Settingsfalse300250truetrue-1180TIMEBurst6000010000100true500 \ No newline at end of file +]]>Global HTTP Settingsfalse300250truetrue-1180TIMEBurst6000010000100true500 \ No newline at end of file diff --git a/web/META-INF/context.xml b/web/META-INF/context.xml deleted file mode 100644 index bac053d..0000000 --- a/web/META-INF/context.xml +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/web/WEB-INF/cxf-beans.xml b/web/WEB-INF/applicationContext.xml similarity index 71% rename from web/WEB-INF/cxf-beans.xml rename to web/WEB-INF/applicationContext.xml index 1ed7311..61b0bab 100644 --- a/web/WEB-INF/cxf-beans.xml +++ b/web/WEB-INF/applicationContext.xml @@ -1,18 +1,15 @@ - - - - - + + + @@ -84,29 +81,7 @@ - - - - - - - - - - - - - - - - - - - - - - - + @@ -117,12 +92,13 @@ + diff --git a/web/WEB-INF/log4j2.xml b/web/WEB-INF/log4j2.xml new file mode 100644 index 0000000..0b67727 --- /dev/null +++ b/web/WEB-INF/log4j2.xml @@ -0,0 +1,26 @@ + + + + + + + %d %p %c{1.} [%t] %m%n + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/java/shiro.ini b/web/WEB-INF/shiro.ini similarity index 100% rename from src/java/shiro.ini rename to web/WEB-INF/shiro.ini diff --git a/web/WEB-INF/web.xml b/web/WEB-INF/web.xml index a8ab9fc..5e2b14d 100644 --- a/web/WEB-INF/web.xml +++ b/web/WEB-INF/web.xml @@ -3,9 +3,15 @@ xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"> + + - contextConfigLocation - /WEB-INF/cxf-beans.xml + log4jConfiguration + /WEB-INF/log4j2.xml + + + shiroConfigLocations + /WEB-INF/shiro.ini quartz:config-file @@ -44,8 +50,8 @@ c:/temp/cvs-findings.txt --> - org.springframework.web.context.ContextLoaderListener - + org.springframework.web.context.ContextLoaderListener + org.quartz.ee.servlet.QuartzInitializerListener @@ -57,8 +63,18 @@ XServices org.apache.cxf.transport.servlet.CXFServlet + + + hide-service-list-page + false + 1 + QuartzInitializer org.quartz.ee.servlet.QuartzInitializerServlet @@ -83,6 +99,7 @@ XServices /* + 30 @@ -91,22 +108,13 @@ - - - org.apache.shiro.web.env.EnvironmentLoaderListener - - ShiroFilter org.apache.shiro.web.servlet.ShiroFilter - - configPath - /WEB-INF/shiro.ini -