Use SLF4J instead of log4j/ log4j2. Introduce lombok.
git-svn-id: https://brutex.net/svn/xservices/trunk@199 e7e49efb-446e-492e-b9ec-fcafc1997a86master
parent
3395c35ad0
commit
f7c18a86fe
35
build.gradle
35
build.gradle
|
@ -12,6 +12,8 @@ dependencies {
|
|||
implementation "org.apache.commons:commons-lang3:3.12.0"
|
||||
implementation "commons-net:commons-net:3.9.0"
|
||||
implementation "commons-beanutils:commons-beanutils:1.9.4"
|
||||
implementation "org.apache.httpcomponents:httpclient:4.5.14"
|
||||
implementation "commons-io:commons-io:2.11.0"
|
||||
|
||||
implementation "org.apache.ant:ant:1.10.13"
|
||||
implementation "org.apache.ant:ant-nodeps:1.8.1"
|
||||
|
@ -24,10 +26,13 @@ dependencies {
|
|||
|
||||
implementation "org.quartz-scheduler:quartz:2.3.2"
|
||||
|
||||
implementation "org.apache.logging.log4j:log4j-core:2.20.0"
|
||||
implementation "org.apache.logging.log4j:log4j-web:2.20.0"
|
||||
implementation "org.apache.logging.log4j:log4j-1.2-api:2.20.0"
|
||||
implementation "org.apache.logging.log4j:log4j-slf4j18-impl:2.18.0"
|
||||
//implementation "org.apache.logging.log4j:log4j-core:2.20.0"
|
||||
//implementation "org.apache.logging.log4j:log4j-web:2.20.0"
|
||||
//implementation "org.apache.logging.log4j:log4j-1.2-api:2.20.0"
|
||||
//implementation "org.apache.logging.log4j:log4j-slf4j18-impl:2.18.0"
|
||||
implementation "org.slf4j:slf4j-api:2.0.7"
|
||||
|
||||
runtimeOnly "org.slf4j:slf4j-simple:2.0.7"
|
||||
|
||||
implementation "org.apache.ws.commons.axiom:axiom:1.2.22"
|
||||
implementation "org.apache.ws.commons.axiom:axiom-impl:1.2.22"
|
||||
|
@ -36,12 +41,13 @@ dependencies {
|
|||
implementation "org.apache.shiro:shiro-root:1.12.0"
|
||||
implementation "org.apache.shiro:shiro-web:1.12.0"
|
||||
|
||||
implementation "org.apache.cxf:cxf:3.6.1"
|
||||
implementation "org.apache.cxf:cxf-rt-databinding-aegis:3.6.1"
|
||||
runtimeOnly "org.apache.cxf:cxf-rt-transports-http:3.6.1"
|
||||
runtimeOnly "org.apache.cxf:cxf-rt-frontend-jaxrs:3.6.1"
|
||||
runtimeOnly "org.apache.cxf:cxf-rt-frontend-jaxws:3.6.1"
|
||||
runtimeOnly "org.apache.cxf:cxf-rt-security:3.6.1"
|
||||
implementation "org.apache.cxf:cxf:3.2.14"
|
||||
implementation "org.apache.cxf:cxf-rt-databinding-aegis:3.2.14"
|
||||
|
||||
runtimeOnly "org.apache.cxf:cxf-rt-transports-http:3.2.14"
|
||||
runtimeOnly "org.apache.cxf:cxf-rt-frontend-jaxrs:3.2.14"
|
||||
runtimeOnly "org.apache.cxf:cxf-rt-frontend-jaxws:3.2.14"
|
||||
runtimeOnly "org.apache.cxf:cxf-rt-security:3.2.14"
|
||||
|
||||
|
||||
implementation "rhino:js:1.7R2"
|
||||
|
@ -50,5 +56,14 @@ dependencies {
|
|||
implementation "org.springframework:spring-context:5.3.29"
|
||||
implementation "org.springframework:spring-web:5.3.29"
|
||||
|
||||
implementation "com.h2database:h2:2.2.222"
|
||||
|
||||
implementation "com.sun.xml.bind:jaxb-impl:2.3.0.1"
|
||||
implementation "com.sun.xml.bind:jaxb-core:2.3.0.1"
|
||||
|
||||
implementation fileTree(dir: "lib/", includes: ["*.jar"])
|
||||
|
||||
annotationProcessor "org.projectlombok:lombok:1.18.28"
|
||||
compileOnly "org.projectlombok:lombok:1.18.28"
|
||||
|
||||
}
|
|
@ -17,8 +17,7 @@
|
|||
package net.brutex.xservices.security;
|
||||
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.shiro.authz.Permission;
|
||||
import org.apache.shiro.util.AntPathMatcher;
|
||||
|
||||
|
@ -26,14 +25,13 @@ import org.apache.shiro.util.AntPathMatcher;
|
|||
* @author Brian Rosenberger, bru(at)brutex.de
|
||||
*
|
||||
*/
|
||||
@Slf4j
|
||||
public class DirectoryPermission implements Permission {
|
||||
|
||||
private final Logger logger = LogManager.getLogger();
|
||||
|
||||
private final String path;
|
||||
|
||||
public DirectoryPermission(String antlikepath) {
|
||||
logger.debug(String.format("Creating permission for path '%s'", antlikepath));
|
||||
log.debug(String.format("Creating permission for path '{}'", antlikepath));
|
||||
path = antlikepath;
|
||||
}
|
||||
|
||||
|
@ -43,13 +41,13 @@ public class DirectoryPermission implements Permission {
|
|||
|
||||
/* is of same type */
|
||||
if(! (p instanceof DirectoryPermission)) {
|
||||
logger.debug(String.format("Testing if permission of type '%s' implies permission of type '%s'. Result was '%s'" , this.getClass(), p.getClass(), result));
|
||||
log.debug(String.format("Testing if permission of type '{}' implies permission of type '{}'. Result was '{}'" , this.getClass(), p.getClass(), result));
|
||||
return result;
|
||||
}
|
||||
|
||||
/* comparing to non null directory */
|
||||
if( ((DirectoryPermission)p).getPath() == null) {
|
||||
logger.debug(String.format("Testing if DirectoryPermission '%s' implies permission to 'null'. Result was '%s'" , this.getPath(), result));
|
||||
log.debug(String.format("Testing if DirectoryPermission '{}' implies permission to 'null'. Result was '{}'" , this.getPath(), result));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -57,7 +55,7 @@ public class DirectoryPermission implements Permission {
|
|||
if( (new AntPathMatcher()).matches(path, ((DirectoryPermission)p).getPath()) ) {
|
||||
result = true;
|
||||
}
|
||||
logger.debug(String.format("Testing if DirectoryPermission '%s' implies permission to '%s'. Result was '%s'" , this.getPath(), ((DirectoryPermission) p).getPath(), result));
|
||||
log.debug(String.format("Testing if DirectoryPermission '{}' implies permission to '{}'. Result was '{}'" , this.getPath(), ((DirectoryPermission) p).getPath(), result));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
|
||||
package net.brutex.xservices.security;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.brutex.xservices.ws.XmlService;
|
||||
import net.brutex.xservices.ws.rs.FileInfo;
|
||||
|
||||
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;
|
||||
|
||||
|
@ -28,33 +28,33 @@ import org.apache.shiro.authz.permission.InvalidPermissionStringException;
|
|||
* @author Brian Rosenberger, bru(at)brutex.de
|
||||
*
|
||||
*/
|
||||
@Slf4j
|
||||
public class PermissionResolver implements org.apache.shiro.authz.permission.PermissionResolver {
|
||||
|
||||
private final Logger logger = LogManager.getLogger();
|
||||
|
||||
private final String DELIMITER = "||";
|
||||
|
||||
@Override
|
||||
public Permission resolvePermission(String permissionString) {
|
||||
logger.debug(String.format("Trying to examine new Permission '%s'", permissionString));
|
||||
log.debug(String.format("Trying to examine new Permission '{}'", permissionString));
|
||||
if(! permissionString.contains(DELIMITER)) {
|
||||
logger.error(String.format("Permission '%s' is missing permission class.", permissionString));
|
||||
throw new InvalidPermissionStringException(String.format("Permission '%s' is missing permission class.", permissionString), permissionString);
|
||||
log.error(String.format("Permission '{}' is missing permission class.", permissionString));
|
||||
throw new InvalidPermissionStringException(String.format("Permission '{}' is missing permission class.", permissionString), permissionString);
|
||||
}
|
||||
int delimiterIndex = permissionString.indexOf(DELIMITER);
|
||||
String value = permissionString.substring(0, delimiterIndex);
|
||||
delimiterIndex = delimiterIndex + DELIMITER.length();
|
||||
switch (value) {
|
||||
case XmlService.SERVICE_NAME:
|
||||
logger.debug(String.format("Found '%s' as permission class.", value));
|
||||
log.debug(String.format("Found '{}' as permission class.", value));
|
||||
return new XmlServicePermission(permissionString.substring( delimiterIndex ));
|
||||
|
||||
case FileInfo.SERVICE_NAME:
|
||||
logger.debug(String.format("Found '%s' as permission class.", value));
|
||||
log.debug(String.format("Found '{}' as permission class.", value));
|
||||
return new DirectoryPermission(permissionString.substring( delimiterIndex ));
|
||||
|
||||
|
||||
default:
|
||||
logger.warn(String.format("Permission class '%s' is not defined.", value));
|
||||
log.warn(String.format("Permission class '{}' is not defined.", value));
|
||||
throw new InvalidPermissionStringException(String.format("Permission class '%s' is not defined.", value), permissionString);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
|
||||
package net.brutex.xservices.security;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.shiro.config.Ini;
|
||||
import org.apache.shiro.realm.text.IniRealm;
|
||||
import org.apache.shiro.util.Nameable;
|
||||
|
@ -38,10 +38,9 @@ import java.net.URISyntaxException;
|
|||
/**
|
||||
* The Class XServicesRealm.
|
||||
*/
|
||||
@Slf4j
|
||||
public class XServicesRealm extends IniRealm implements Nameable {
|
||||
|
||||
/** The logger. */
|
||||
private final Logger logger = LogManager.getLogger();
|
||||
|
||||
/** The name. */
|
||||
private String name;
|
||||
|
@ -71,7 +70,7 @@ public class XServicesRealm extends IniRealm implements Nameable {
|
|||
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);
|
||||
log.error(e.getMessage(), e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
|
|
@ -16,21 +16,20 @@
|
|||
|
||||
package net.brutex.xservices.security;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.shiro.authz.Permission;
|
||||
|
||||
/**
|
||||
* @author Brian Rosenberger, bru(at)brutex.de
|
||||
*
|
||||
*/
|
||||
@Slf4j
|
||||
public class XmlServicePermission implements Permission {
|
||||
|
||||
private final Logger logger = LogManager.getLogger();
|
||||
private final String permissionString;
|
||||
|
||||
public XmlServicePermission(String permissionString) {
|
||||
logger.debug(String.format("Creating permission for '%s'", permissionString));
|
||||
log.debug(String.format("Creating permission for '{}'", permissionString));
|
||||
this.permissionString = permissionString;
|
||||
}
|
||||
|
||||
|
@ -40,13 +39,13 @@ public class XmlServicePermission implements Permission {
|
|||
|
||||
/* is of same type */
|
||||
if(! (p instanceof XmlServicePermission)) {
|
||||
logger.debug(String.format("Testing if permission of type '%s' implies permission of type '%s'. Result was '%s'" , this.getClass(), p.getClass(), result));
|
||||
log.debug(String.format("Testing if permission of type '{}' implies permission of type '{}'. Result was '{}'" , this.getClass(), p.getClass(), result));
|
||||
return result;
|
||||
}
|
||||
|
||||
/* comparing to non null directory */
|
||||
if( ((XmlServicePermission)p).getPermissionString() == null) {
|
||||
logger.debug(String.format("Testing if DirectoryPermission '%s' implies permission to 'null'. Result was '%s'" , permissionString, result));
|
||||
log.debug(String.format("Testing if DirectoryPermission '{}' implies permission to 'null'. Result was '{}'" , permissionString, result));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,24 +30,24 @@ import java.sql.Statement;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.quartz.utils.ConnectionProvider;
|
||||
|
||||
/**
|
||||
* @author Brian Rosenberger
|
||||
*
|
||||
*/
|
||||
@Slf4j
|
||||
public class BrutexHSQLQuartzConnectionProvider implements ConnectionProvider {
|
||||
|
||||
private Connection conn = null;
|
||||
private static final Logger logger = LogManager.getLogger();
|
||||
|
||||
|
||||
|
||||
public Connection getConnection() throws SQLException {
|
||||
if( conn!= null ) { // Todo: && conn.conn.isValid(5)) {
|
||||
logger.debug("Checking tables on pre-exisiting database connection.");
|
||||
log.debug("Checking tables on pre-exisiting database connection.");
|
||||
checkTables();
|
||||
return conn;
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public class BrutexHSQLQuartzConnectionProvider implements ConnectionProvider {
|
|||
// Class.forName("org.hsqldb.jdbc.JDBCDriver" );
|
||||
Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
|
||||
} catch (Exception e) {
|
||||
logger.fatal("Failed to load Derby JDBC driver.");
|
||||
log.error("Failed to load Derby JDBC driver.");
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
@ -106,9 +106,9 @@ public class BrutexHSQLQuartzConnectionProvider implements ConnectionProvider {
|
|||
}
|
||||
|
||||
private synchronized void checkTables() throws SQLException {
|
||||
logger.debug("Checking QUARTZ database schema.");
|
||||
log.debug("Checking QUARTZ database schema.");
|
||||
if(!isConnected(false)) {
|
||||
logger.error("Failed to validate QUARTZ database schema.");
|
||||
log.error("Failed to validate QUARTZ database schema.");
|
||||
return;
|
||||
}
|
||||
List<String> ddl_list = new ArrayList<String>(11);
|
||||
|
@ -131,7 +131,7 @@ public class BrutexHSQLQuartzConnectionProvider implements ConnectionProvider {
|
|||
for (String tbl : ddl_list) {
|
||||
ResultSet rs = dmd.getTables(null, "APP", tbl, null);
|
||||
if (!rs.next()) {
|
||||
logger.log(Level.INFO, "Adding DDL for table "+ tbl);
|
||||
log.debug("Adding DDL for table {}", tbl);
|
||||
Statement st = conn.createStatement();
|
||||
File ddlFile = new File(ddl + tbl + ".ddl");
|
||||
String create = "";
|
||||
|
@ -142,18 +142,15 @@ public class BrutexHSQLQuartzConnectionProvider implements ConnectionProvider {
|
|||
}
|
||||
create.trim();
|
||||
if( st.execute(create)) {
|
||||
logger.log(Level.INFO, "Table " + tbl + " created.");
|
||||
log.debug("Table {} created.", tbl);
|
||||
}
|
||||
} catch (FileNotFoundException ex) {
|
||||
ex.printStackTrace();
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
} catch (SQLException ex) {
|
||||
logger.log(Level.ERROR, "Error executing statement "+ create );
|
||||
System.out.println(ex.getMessage());
|
||||
log.error("Error executing statement {}.",create, ex );
|
||||
}
|
||||
} else {
|
||||
logger.trace("Table "+tbl+" exists.");
|
||||
log.trace("Table {} exists.", tbl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -164,15 +161,15 @@ public class BrutexHSQLQuartzConnectionProvider implements ConnectionProvider {
|
|||
} else {
|
||||
String t = this.getClass().getClassLoader().getResource("/").toString().substring(6); // WEB-INF/classes
|
||||
t += "../data/db";
|
||||
logger.debug("Database directory is set to '" + t + "'");
|
||||
log.debug("Database directory is set to '{}", t);
|
||||
try {
|
||||
this.conn = DriverManager.getConnection("jdbc:derby:" + t + ";create=true;");
|
||||
} catch (SQLException ex) {
|
||||
logger.error(ex.getMessage(), ex);
|
||||
log.error(ex.getMessage(), ex);
|
||||
if(!fail) {
|
||||
logger.warn("Deleting database directory.");
|
||||
log.warn("Deleting database directory.");
|
||||
recursiveDelete(new File(t));
|
||||
logger.warn("Retrying to connect to database.");
|
||||
log.warn("Retrying to connect to database.");
|
||||
return isConnected(true);
|
||||
} else {
|
||||
return false;
|
||||
|
|
|
@ -30,24 +30,23 @@ import java.sql.Statement;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.quartz.utils.ConnectionProvider;
|
||||
|
||||
/**
|
||||
* @author Brian Rosenberger
|
||||
*
|
||||
*/
|
||||
@Slf4j
|
||||
public class BrutexQuartzConnectionProvider implements ConnectionProvider {
|
||||
|
||||
private Connection conn = null;
|
||||
private final Logger logger = LogManager.getLogger();
|
||||
|
||||
|
||||
|
||||
public Connection getConnection() throws SQLException {
|
||||
if( conn!= null) { // Todo: && conn.conn.isValid(5)) {) {
|
||||
logger.debug("Checking tables on pre-exisiting database connection.");
|
||||
log.debug("Checking tables on pre-exisiting database connection.");
|
||||
checkTables();
|
||||
return conn;
|
||||
}
|
||||
|
@ -55,7 +54,7 @@ public class BrutexQuartzConnectionProvider implements ConnectionProvider {
|
|||
// Class.forName("org.hsqldb.jdbc.JDBCDriver" );
|
||||
Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
|
||||
} catch (Exception e) {
|
||||
logger.fatal("Failed to load Derby JDBC driver.");
|
||||
log.error("Failed to load Derby JDBC driver.");
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
@ -106,9 +105,9 @@ public class BrutexQuartzConnectionProvider implements ConnectionProvider {
|
|||
}
|
||||
|
||||
private synchronized void checkTables() throws SQLException {
|
||||
logger.debug("Checking QUARTZ database schema.");
|
||||
log.debug("Checking QUARTZ database schema.");
|
||||
if(!isConnected(false)) {
|
||||
logger.error("Failed to validate QUARTZ database schema.");
|
||||
log.error("Failed to validate QUARTZ database schema.");
|
||||
return;
|
||||
}
|
||||
List<String> ddl_list = new ArrayList<String>(11);
|
||||
|
@ -131,7 +130,7 @@ public class BrutexQuartzConnectionProvider implements ConnectionProvider {
|
|||
for (String tbl : ddl_list) {
|
||||
ResultSet rs = dmd.getTables(null, "APP", tbl, null);
|
||||
if (!rs.next()) {
|
||||
logger.log(Level.INFO, "Adding DDL for table "+ tbl);
|
||||
log.debug("Adding DDL for table {}.", tbl);
|
||||
Statement st = conn.createStatement();
|
||||
File ddlFile = new File(ddl + tbl + ".ddl");
|
||||
String create = "";
|
||||
|
@ -142,18 +141,16 @@ public class BrutexQuartzConnectionProvider implements ConnectionProvider {
|
|||
}
|
||||
create.trim();
|
||||
if( st.execute(create)) {
|
||||
logger.log(Level.INFO, "Table " + tbl + " created.");
|
||||
log.debug("Table {} created.", tbl);
|
||||
}
|
||||
} catch (FileNotFoundException ex) {
|
||||
ex.printStackTrace();
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
} catch (SQLException ex) {
|
||||
logger.log(Level.ERROR, "Error executing statement "+ create );
|
||||
log.error("Error executing statement {}", create, ex );
|
||||
System.out.println(ex.getMessage());
|
||||
}
|
||||
} else {
|
||||
logger.trace("Table "+tbl+" exists.");
|
||||
log.trace("Table {} exists.", tbl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -164,15 +161,15 @@ public class BrutexQuartzConnectionProvider implements ConnectionProvider {
|
|||
} else {
|
||||
String t = this.getClass().getClassLoader().getResource("/").toString().substring(6); // WEB-INF/classes
|
||||
t += "../data/db";
|
||||
logger.debug("Database directory is set to '" + t + "'");
|
||||
log.debug("Database directory is set to '{}'", t);
|
||||
try {
|
||||
this.conn = DriverManager.getConnection("jdbc:derby:" + t + ";create=true;");
|
||||
} catch (SQLException ex) {
|
||||
logger.error(ex.getMessage(), ex);
|
||||
log.error(ex.getMessage(), ex);
|
||||
if(!fail) {
|
||||
logger.warn("Deleting database directory.");
|
||||
log.warn("Deleting database directory.");
|
||||
recursiveDelete(new File(t));
|
||||
logger.warn("Retrying to connect to database.");
|
||||
log.warn("Retrying to connect to database.");
|
||||
return isConnected(true);
|
||||
} else {
|
||||
return false;
|
||||
|
@ -181,7 +178,6 @@ public class BrutexQuartzConnectionProvider implements ConnectionProvider {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
/* */ package net.brutex.xservices.util;
|
||||
/* */
|
||||
/* */ import java.io.File;
|
||||
/* */ import net.brutex.xservices.types.scm.ItemType;
|
||||
/* */ import lombok.extern.slf4j.Slf4j;
|
||||
import net.brutex.xservices.types.scm.ItemType;
|
||||
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;
|
||||
/* */ import org.netbeans.lib.cvsclient.command.GlobalOptions;
|
||||
/* */ import org.netbeans.lib.cvsclient.connection.AuthenticationException;
|
||||
/* */ import org.netbeans.lib.cvsclient.connection.PServerConnection;
|
||||
/* */
|
||||
/* */
|
||||
@Slf4j
|
||||
/* */ public class CVSClient
|
||||
/* */ {
|
||||
/* */ private final File configfile;
|
||||
/* */ private final PServerConnection connection;
|
||||
/* */ private final CVSRoot root;
|
||||
/* */ private final GlobalOptions globalOptions;
|
||||
/* 41 */ final Logger logger = LogManager.getLogger();
|
||||
/* */ public final Client client;
|
||||
/* */
|
||||
/* */ public Client getClient()
|
||||
|
@ -61,7 +61,7 @@ import org.apache.logging.log4j.Logger;
|
|||
/* */ try {
|
||||
/* 79 */ this.connection.open();
|
||||
/* */ } catch (AuthenticationException ex) {
|
||||
/* 81 */ this.logger.error(ex.getMessage());
|
||||
/* 81 */ log.error(ex.getMessage());
|
||||
/* */ }
|
||||
/* */
|
||||
/* 84 */ this.client = new Client(this.connection, new StandardAdminHandler());
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
*/
|
||||
package net.brutex.xservices.util;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.FileSystems;
|
||||
import java.nio.file.FileVisitResult;
|
||||
|
@ -26,10 +28,6 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import net.brutex.xservices.types.FileInfoType;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
|
@ -37,6 +35,7 @@ import net.brutex.xservices.types.FileInfoType;
|
|||
*
|
||||
* @author Brian Rosenberger, bru(at)brutex.de
|
||||
*/
|
||||
@Slf4j
|
||||
public class FileWalker extends SimpleFileVisitor<Path> {
|
||||
|
||||
/** The matcher. */
|
||||
|
@ -51,9 +50,6 @@ public class FileWalker extends SimpleFileVisitor<Path> {
|
|||
/** The pattern. */
|
||||
private final String pattern;
|
||||
|
||||
/** The logger. */
|
||||
private static final Logger logger = LogManager.getLogger();
|
||||
|
||||
List<Path> list;
|
||||
|
||||
/**
|
||||
|
@ -78,11 +74,11 @@ public class FileWalker extends SimpleFileVisitor<Path> {
|
|||
*/
|
||||
void find(Path file) {
|
||||
Path name = file.getFileName();
|
||||
logger.trace("Compare file " + file.toString() + " against pattern '"+pattern+"'.");
|
||||
log.debug("Compare file '{}' against pattern '{}'.", file, pattern);
|
||||
total++;
|
||||
if (name != null && matcher.matches(name)) {
|
||||
list.add(file);
|
||||
logger.debug("Added file " + file.toString() + " to the result set.");
|
||||
log.debug("Added file '{}' to the result set.", file);
|
||||
num++;
|
||||
}
|
||||
}
|
||||
|
@ -118,7 +114,7 @@ public class FileWalker extends SimpleFileVisitor<Path> {
|
|||
@Override
|
||||
public FileVisitResult visitFileFailed(Path file,
|
||||
IOException exc) {
|
||||
logger.warn(String.format("Failed to include file '%s'.", file.toString()));
|
||||
log.warn("Failed to include file '{}'.", file);
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,12 +9,12 @@ import java.io.IOException;
|
|||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.configuration2.ex.ConfigurationException;
|
||||
import org.apache.commons.configuration2.PropertiesConfiguration;
|
||||
import org.apache.commons.jcs.JCS;
|
||||
import org.apache.commons.jcs.access.exception.CacheException;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
|
||||
import net.brutex.mgmt.openair.OpenAirRestConnection;
|
||||
|
||||
|
@ -22,16 +22,17 @@ import net.brutex.mgmt.openair.OpenAirRestConnection;
|
|||
* @author brosenberger
|
||||
*
|
||||
*/
|
||||
@Slf4j
|
||||
public final class OpenAirConnection {
|
||||
private final static Logger logger = LogManager.getLogger();
|
||||
|
||||
|
||||
public static OpenAirRestConnection getOpenAirConnection() {
|
||||
final PropertiesConfiguration props;
|
||||
try {
|
||||
final String config = "../openair.properties";
|
||||
logger.info("Loading Open Air connection details from {}", config.toString());
|
||||
log.info("Loading Open Air connection details from {}", config.toString());
|
||||
final URL configloc = OpenAirConnection.class.getClassLoader().getResource(config);
|
||||
logger.debug("Loading Open Air connection details from {}", configloc.toString());
|
||||
log.debug("Loading Open Air connection details from {}", configloc.toString());
|
||||
|
||||
props = new PropertiesConfiguration();
|
||||
props.read( new InputStreamReader( new BufferedInputStream(configloc.openStream())) );
|
||||
|
@ -46,11 +47,8 @@ public final class OpenAirConnection {
|
|||
|
||||
con = new OpenAirRestConnection(JCS.getInstance("OACache"), company, user, password);
|
||||
return con;
|
||||
} catch (CacheException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
e.printStackTrace();
|
||||
} catch (ConfigurationException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
} catch (CacheException | ConfigurationException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -23,19 +23,19 @@ import java.util.List;
|
|||
import java.util.concurrent.ExecutorService;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.brutex.xservices.types.scm.ObjectFactory;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
|
||||
/**
|
||||
* @author Brian Rosenberger, bru(at)brutex.de
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class CacheServlet extends HttpServlet
|
||||
{
|
||||
private static final Logger logger = LogManager.getLogger();
|
||||
List<File> configfiles = new ArrayList<File>();
|
||||
int cacheinterval;
|
||||
private final ObjectFactory FACTORY = new ObjectFactory();
|
||||
|
@ -54,7 +54,7 @@ public class CacheServlet extends HttpServlet
|
|||
if (name.startsWith("cvs-config-")) {
|
||||
String configfile = getServletContext()
|
||||
.getInitParameter(name);
|
||||
this.logger.info("CVS configuration file: " + configfile);
|
||||
log.info("CVS configuration file: {}", configfile);
|
||||
this.configfiles.add(new File(configfile));
|
||||
}
|
||||
}
|
||||
|
@ -63,8 +63,8 @@ public class CacheServlet extends HttpServlet
|
|||
this.cacheinterval = Integer.parseInt(getServletContext()
|
||||
.getInitParameter("cvs-cache-interval"));
|
||||
} catch (NumberFormatException e) {
|
||||
this.logger.debug("Could not read parameter 'cvs-cache-interval' from web.xml. Using default value '" + this.cacheinterval + "' minutes");
|
||||
log.debug("Could not read parameter 'cvs-cache-interval' from web.xml. Using default value '{}' minutes", this.cacheinterval );
|
||||
}
|
||||
this.logger.info("CacheServlet set to " + this.cacheinterval + " minutes interval.");
|
||||
log.info("CacheServlet set to '{}' minutes interval.", this.cacheinterval);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,8 @@ import javax.servlet.ServletContext;
|
|||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.brutex.xservices.types.scm.ItemListType;
|
||||
import net.brutex.xservices.types.scm.ItemType;
|
||||
import net.brutex.xservices.types.scmfindings.FindingDetailsType;
|
||||
|
@ -43,18 +45,16 @@ 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
|
||||
*
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
public class FindingsCacheServlet extends HttpServlet {
|
||||
|
||||
private static final long serialVersionUID = 4041338473949999960L;
|
||||
private static final Logger logger = LogManager.getLogger();
|
||||
private final List<File> configfiles = new ArrayList<File>();
|
||||
private final ObjectFactory FACTORY = new ObjectFactory();
|
||||
private ExecutorService executor;
|
||||
|
@ -71,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, LogManager.getLogger("worker-"+i+ "." + this.getClass().getName()));
|
||||
FindingsConfigBean cbean = new FindingsConfigBean(i);
|
||||
i++;
|
||||
|
||||
|
||||
|
@ -81,9 +81,9 @@ public class FindingsCacheServlet extends HttpServlet {
|
|||
int cacheinterval = Integer.parseInt(getServletContext()
|
||||
.getInitParameter("cvs-cache-interval"));
|
||||
cbean.setCacheinterval(cacheinterval);
|
||||
logger.info("FindingsCacheServlet set to "+ cacheinterval + " minutes interval.");
|
||||
log.info("FindingsCacheServlet set to "+ cacheinterval + " minutes interval.");
|
||||
} catch (NumberFormatException e) {
|
||||
logger.warn("Could not read parameter 'cvs-cache-interval' from web.xml. Using default value '"
|
||||
log.warn("Could not read parameter 'cvs-cache-interval' from web.xml. Using default value '"
|
||||
+ cbean.getCacheinterval()+ "' minutes");
|
||||
}
|
||||
|
||||
|
@ -92,27 +92,27 @@ public class FindingsCacheServlet extends HttpServlet {
|
|||
try {
|
||||
config = configs.properties(f);
|
||||
} catch (ConfigurationException e) {
|
||||
logger.error("Could not read parameter file at '"+f.getAbsolutePath()+"'");
|
||||
log.error("Could not read parameter file at '"+f.getAbsolutePath()+"'");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
File cvsconfig = new File(config.getString("CVSROOTCONFIGFILE"));
|
||||
cbean.setCvsconfig(cvsconfig);
|
||||
FindingsCacheServlet.logger.debug("Fetching list of files using '"
|
||||
FindingsCacheServlet.log.debug("Fetching list of files using '"
|
||||
+ cvsconfig.getAbsolutePath() + "' config file");
|
||||
|
||||
|
||||
List<Object> filepatterns = config.getList("FILESEARCH");
|
||||
cbean.setFilepatterns(filepatterns);
|
||||
FindingsCacheServlet.logger.debug("Checking '"
|
||||
FindingsCacheServlet.log.debug("Checking '"
|
||||
+ filepatterns.size()
|
||||
+ "' patterns for file name and path matching.");
|
||||
|
||||
|
||||
List<Object> contentpatterns = config.getList("CONTENTSEARCH");
|
||||
cbean.setContentpatterns(contentpatterns);
|
||||
FindingsCacheServlet.logger.debug("Checking '"
|
||||
FindingsCacheServlet.log.debug("Checking '"
|
||||
+ contentpatterns.size()
|
||||
+ "' patterns for content matching");
|
||||
|
||||
|
@ -122,7 +122,7 @@ public class FindingsCacheServlet extends HttpServlet {
|
|||
executor.submit(new ThisRunnable(cbean));
|
||||
|
||||
}
|
||||
logger.info("FindingsCacheServlet has been initialized.");
|
||||
log.info("FindingsCacheServlet has been initialized.");
|
||||
|
||||
}
|
||||
|
||||
|
@ -133,14 +133,14 @@ public class FindingsCacheServlet extends HttpServlet {
|
|||
String filename = getServletContext().getInitParameter(
|
||||
"cvs-findings-configuration");
|
||||
if (filename == null) {
|
||||
logger.warn("'cvs-findings-configuration' init parameter is not specified.");
|
||||
log.warn("'cvs-findings-configuration' init parameter is not specified.");
|
||||
return false;
|
||||
}
|
||||
final File findingsconfig = new File(filename);
|
||||
logger.info("CVS findings configuration file found at '"
|
||||
log.info("CVS findings configuration file found at '"
|
||||
+ findingsconfig.getAbsolutePath() + "'");
|
||||
if ((!findingsconfig.canRead()) || (findingsconfig.isDirectory())) {
|
||||
logger.info("CVS findings configuration file '"
|
||||
log.info("CVS findings configuration file '"
|
||||
+ findingsconfig.getAbsolutePath() + "' does not exist.");
|
||||
return false;
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ public class FindingsCacheServlet extends HttpServlet {
|
|||
String name = (String) attributes.nextElement();
|
||||
if (name.startsWith("cvs-config-")) {
|
||||
String configfile = getServletContext().getInitParameter(name);
|
||||
logger.info("Adding CVS configuration file: " + configfile);
|
||||
log.info("Adding CVS configuration file: " + configfile);
|
||||
this.configfiles.add(new File(configfile));
|
||||
}
|
||||
}
|
||||
|
@ -168,12 +168,12 @@ public class FindingsCacheServlet extends HttpServlet {
|
|||
List<File> removelist = new ArrayList<File>();
|
||||
for (File f : configfiles) {
|
||||
if (!f.exists()) {
|
||||
logger.warn("CVS configuration file '"
|
||||
log.warn("CVS configuration file '"
|
||||
+ f.getAbsolutePath()
|
||||
+ "' is specified, but does not exist. Removing from list.");
|
||||
removelist.add(f);
|
||||
} else if (!f.canRead()) {
|
||||
logger.warn("CVS configuration file '"
|
||||
log.warn("CVS configuration file '"
|
||||
+ f.getAbsolutePath()
|
||||
+ "' does exist, but is not readable. Removing from list.");
|
||||
removelist.add(f);
|
||||
|
@ -203,7 +203,7 @@ public class FindingsCacheServlet extends HttpServlet {
|
|||
ObjectFactory FACTORY = new ObjectFactory();
|
||||
FindingsListType findingsList = FACTORY.createFindingsListType();
|
||||
|
||||
FindingsCacheServlet.logger.info("Processing '"
|
||||
FindingsCacheServlet.log.info("Processing '"
|
||||
+ fileslist.getItems().size() + "' files and directories.");
|
||||
|
||||
while (!this.isInterrupted) {
|
||||
|
@ -216,7 +216,7 @@ public class FindingsCacheServlet extends HttpServlet {
|
|||
Object o = iterF.next();
|
||||
if (this.isInterrupted)
|
||||
break;
|
||||
FindingsCacheServlet.logger.debug("Scanning filename '"
|
||||
FindingsCacheServlet.log.debug("Scanning filename '"
|
||||
+ i.getFullname() + "' for pattern '"
|
||||
+ (String) o + "'");
|
||||
p = Pattern.compile((String) o);
|
||||
|
@ -231,17 +231,17 @@ public class FindingsCacheServlet extends HttpServlet {
|
|||
finding.setData(it.getData());
|
||||
finding = copyDetails(finding, i);
|
||||
findingsList.getFindings().add(finding);
|
||||
FindingsCacheServlet.logger
|
||||
FindingsCacheServlet.log
|
||||
.debug("Match found for '"
|
||||
+ i.getFullname() + "'");
|
||||
break;
|
||||
}
|
||||
FindingsCacheServlet.logger
|
||||
FindingsCacheServlet.log
|
||||
.debug("No match found for '" + i.getFullname()
|
||||
+ "'");
|
||||
}
|
||||
}
|
||||
FindingsCacheServlet.logger
|
||||
FindingsCacheServlet.log
|
||||
.debug("Processing file content for '"
|
||||
+ findingsList.getFindings().size()
|
||||
+ "' entries in the list.");
|
||||
|
@ -257,7 +257,7 @@ public class FindingsCacheServlet extends HttpServlet {
|
|||
Object o = iter.next();
|
||||
if (this.isInterrupted)
|
||||
break;
|
||||
FindingsCacheServlet.logger
|
||||
FindingsCacheServlet.log
|
||||
.debug("Scanning file content for file '"
|
||||
+ t.getFullname() + "' for pattern '"
|
||||
+ (String) o + "'");
|
||||
|
@ -293,7 +293,7 @@ public class FindingsCacheServlet extends HttpServlet {
|
|||
fd.getMatchLists().add(gmg);
|
||||
}
|
||||
t.getFindingLists().add(fd);
|
||||
FindingsCacheServlet.logger
|
||||
FindingsCacheServlet.log
|
||||
.debug("Found matching content at index '" + s
|
||||
+ "' in file '" + t.getFullname()
|
||||
+ "' with pattern '" + p1.toString()
|
||||
|
@ -302,7 +302,7 @@ public class FindingsCacheServlet extends HttpServlet {
|
|||
|
||||
if (!isFound) {
|
||||
findingsList.getFindings().remove(t);
|
||||
FindingsCacheServlet.logger
|
||||
FindingsCacheServlet.log
|
||||
.debug("Found matching filename for '"
|
||||
+ t.getFullname()
|
||||
+ "' but content didn't match. Removing.");
|
||||
|
@ -311,24 +311,24 @@ public class FindingsCacheServlet extends HttpServlet {
|
|||
try {
|
||||
instance.getCacheInstance().put(
|
||||
"FINDINGS-" + t.getROOT(), findingsList);
|
||||
FindingsCacheServlet.logger
|
||||
FindingsCacheServlet.log
|
||||
.info("FINDINGS for CVSROOT '" + t.getROOT()
|
||||
+ "' have been updated in cache.");
|
||||
} catch (CacheException e) {
|
||||
FindingsCacheServlet.logger.error(e.getMessage(), e);
|
||||
FindingsCacheServlet.log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
try {
|
||||
int cacheinterval = configuration.getCacheinterval();
|
||||
FindingsCacheServlet.logger.debug("Now sleeping for '"
|
||||
FindingsCacheServlet.log.debug("Now sleeping for '"
|
||||
+ cacheinterval + "' minutes");
|
||||
Thread.currentThread();
|
||||
Thread.sleep(cacheinterval * 60000);
|
||||
FindingsCacheServlet.logger.debug("Waking up after '"
|
||||
FindingsCacheServlet.log.debug("Waking up after '"
|
||||
+ cacheinterval + "' minutes of sleep");
|
||||
} catch (InterruptedException e) {
|
||||
this.isInterrupted = true;
|
||||
FindingsCacheServlet.logger
|
||||
FindingsCacheServlet.log
|
||||
.warn("FindingsCacheServlet cache was interrupted. Shutting down.");
|
||||
}
|
||||
}
|
||||
|
@ -361,9 +361,9 @@ public class FindingsCacheServlet extends HttpServlet {
|
|||
executor.shutdown();
|
||||
try {
|
||||
executor.awaitTermination(3, TimeUnit.SECONDS);
|
||||
logger.info("Cache Worker Threads have shut down.");
|
||||
log.info("Cache Worker Threads have shut down.");
|
||||
} catch (InterruptedException e) {
|
||||
logger.error("Cache Worker Threads did not terminate within timeout.", e);
|
||||
log.error("Cache Worker Threads did not terminate within timeout.", e);
|
||||
}
|
||||
super.destroy();
|
||||
}
|
||||
|
|
|
@ -16,18 +16,22 @@
|
|||
|
||||
package net.brutex.xservices.util.cache;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
|
||||
/**
|
||||
* @author Brian Rosenberger, bru(at)brutex.de
|
||||
*
|
||||
*/
|
||||
@Slf4j
|
||||
public class FindingsConfigBean {
|
||||
|
||||
private Logger logger;
|
||||
|
||||
private final int instanceid;
|
||||
|
||||
private File cvsconfig;
|
||||
|
@ -35,10 +39,10 @@ public class FindingsConfigBean {
|
|||
private List<Object> filepatterns;
|
||||
private List<Object> contentpatterns;
|
||||
|
||||
public FindingsConfigBean(int instanceid, Logger logger) {
|
||||
public FindingsConfigBean(int instanceid) {
|
||||
this.instanceid = instanceid;
|
||||
this.logger = logger;
|
||||
logger.debug("Initialise FindingsConfigBean instance '" + instanceid + "'");
|
||||
|
||||
log.debug("Initialise FindingsConfigBean instance '" + instanceid + "'");
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -18,16 +18,23 @@ package net.brutex.xservices.ws;
|
|||
import javax.jws.WebMethod;
|
||||
import javax.jws.WebParam;
|
||||
import javax.jws.WebService;
|
||||
import javax.jws.soap.SOAPBinding;
|
||||
|
||||
import net.brutex.xservices.types.HostConnection;
|
||||
import net.brutex.xservices.types.HostinfoType;
|
||||
import net.brutex.xservices.types.MailMimeType;
|
||||
import net.brutex.xservices.types.ReturnCode;
|
||||
import net.brutex.xservices.types.RuntimeInfoType;
|
||||
import net.brutex.xservices.types.alfevent.ALFEventResponseType;
|
||||
import net.brutex.xservices.types.alfevent.ALFEventType;
|
||||
import net.brutex.xservices.types.ant.FileSetResource;
|
||||
|
||||
import org.apache.cxf.aegis.type.java5.XmlElement;
|
||||
import org.apache.cxf.aegis.type.java5.XmlReturnType;
|
||||
import org.apache.cxf.annotations.WSDLDocumentation;
|
||||
import org.h2.jdbcx.JdbcConnectionPool;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
/**
|
||||
* Bundles various methods
|
||||
|
@ -36,12 +43,13 @@ import org.apache.cxf.annotations.WSDLDocumentation;
|
|||
* @since 0.4.0
|
||||
*/
|
||||
@WebService(targetNamespace = net.brutex.xservices.util.BrutexNamespaces.WS_XSERVICES)
|
||||
//@SOAPBinding(style = SOAPBinding.Style.RPC)
|
||||
@WSDLDocumentation("Various service operations.")
|
||||
public interface MiscService {
|
||||
|
||||
public static final String OPERATION_GETMEMORY = "getMemory";
|
||||
|
||||
@WebMethod(operationName="getHostinfo")
|
||||
@WebMethod(operationName="getHostinfo")
|
||||
@WSDLDocumentation("Get information about a host.")
|
||||
public abstract HostinfoType getHostinfo(@WebParam(name="hostname") @XmlElement(minOccurs="1", nillable=false) String paramString);
|
||||
|
||||
|
@ -60,4 +68,12 @@ public interface MiscService {
|
|||
@WebMethod(operationName="getMemory")
|
||||
@WSDLDocumentation("Get memory and processor information")
|
||||
public abstract RuntimeInfoType getMemory();
|
||||
|
||||
@WebMethod(operationName="lock")
|
||||
@WSDLDocumentation("Get a lock.")
|
||||
public abstract BigInteger lock(@WebParam(name="id") @XmlElement(nillable = false) String id,
|
||||
@WebParam(name="objectId") @XmlElement(nillable = false) String objectId) throws XServicesFault;
|
||||
|
||||
@WebMethod(operationName="EventNotice")
|
||||
public abstract ALFEventResponseType mergeALFEvent(@WebParam(name="EventNotice", targetNamespace = "http://www.eclipse.org/alf/schema/EventBase/1") ALFEventType event) throws XServicesFault;
|
||||
}
|
||||
|
|
|
@ -26,15 +26,7 @@ import java.util.UUID;
|
|||
|
||||
import javax.jws.WebService;
|
||||
|
||||
import org.quartz.JobBuilder;
|
||||
import org.quartz.JobDataMap;
|
||||
import org.quartz.JobDetail;
|
||||
import org.quartz.JobKey;
|
||||
import org.quartz.Scheduler;
|
||||
import org.quartz.SchedulerException;
|
||||
import org.quartz.SimpleTrigger;
|
||||
import org.quartz.Trigger;
|
||||
import org.quartz.TriggerKey;
|
||||
import org.quartz.*;
|
||||
import org.quartz.impl.StdSchedulerFactory;
|
||||
import org.quartz.impl.matchers.GroupMatcher;
|
||||
|
||||
|
@ -148,4 +140,5 @@ public class JobServiceImpl implements JobService {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -16,26 +16,44 @@
|
|||
|
||||
package net.brutex.xservices.ws.impl;
|
||||
|
||||
import net.brutex.xservices.types.*;
|
||||
import net.brutex.xservices.types.alfevent.ALFEventResponseType;
|
||||
import net.brutex.xservices.types.alfevent.ALFEventType;
|
||||
import net.brutex.xservices.types.alfevent.ObjectFactory;
|
||||
import net.brutex.xservices.types.ant.FileSetResource;
|
||||
import net.brutex.xservices.util.EventEmitter;
|
||||
import net.brutex.xservices.util.RunTask;
|
||||
import net.brutex.xservices.ws.MiscService;
|
||||
import net.brutex.xservices.ws.XServicesFault;
|
||||
import org.apache.tools.ant.taskdefs.HostInfo;
|
||||
import org.apache.tools.ant.taskdefs.Sleep;
|
||||
import org.apache.tools.ant.taskdefs.email.EmailTask;
|
||||
import org.h2.jdbcx.JdbcConnectionPool;
|
||||
import org.quartz.*;
|
||||
import org.quartz.impl.StdSchedulerFactory;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.jws.WebService;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBElement;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Marshaller;
|
||||
import javax.xml.ws.WebServiceContext;
|
||||
import javax.xml.ws.handler.MessageContext;
|
||||
import java.io.StringReader;
|
||||
import java.io.StringWriter;
|
||||
import java.math.BigInteger;
|
||||
import java.sql.*;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Date;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Properties;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.jws.WebService;
|
||||
import net.brutex.xservices.types.HostConnection;
|
||||
import net.brutex.xservices.types.HostinfoType;
|
||||
import net.brutex.xservices.types.MailMimeType;
|
||||
import net.brutex.xservices.types.ReturnCode;
|
||||
import net.brutex.xservices.types.RuntimeInfoType;
|
||||
import net.brutex.xservices.types.ant.FileSetResource;
|
||||
import net.brutex.xservices.util.BrutexNamespaces;
|
||||
import net.brutex.xservices.util.RunTask;
|
||||
import net.brutex.xservices.ws.MiscService;
|
||||
import static org.quartz.TriggerBuilder.newTrigger;
|
||||
|
||||
import org.apache.cxf.annotations.WSDLDocumentation;
|
||||
import org.apache.cxf.annotations.WSDLDocumentationCollection;
|
||||
import org.apache.tools.ant.taskdefs.HostInfo;
|
||||
import org.apache.tools.ant.taskdefs.Sleep;
|
||||
import org.apache.tools.ant.taskdefs.email.EmailTask;
|
||||
|
||||
/**
|
||||
* Implements the web service
|
||||
|
@ -44,10 +62,32 @@ import org.apache.tools.ant.taskdefs.email.EmailTask;
|
|||
*/
|
||||
@WebService(targetNamespace="http://ws.xservices.brutex.net", endpointInterface="net.brutex.xservices.ws.MiscService", serviceName="MiscService")
|
||||
public class MiscServiceImpl
|
||||
implements MiscService
|
||||
{
|
||||
public HostinfoType getHostinfo(String hostname)
|
||||
{
|
||||
implements MiscService {
|
||||
|
||||
@Resource
|
||||
private WebServiceContext context;
|
||||
|
||||
// Grab the Scheduler instance from the Factory
|
||||
private final Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
|
||||
private final static String conStr = "jdbc:h2:mem:lockdb;DB_CLOSE_DELAY=-1;";
|
||||
|
||||
private final static String dbinit = "" +
|
||||
"CREATE SCHEMA IF NOT EXISTS brutex;" +
|
||||
"CREATE TABLE IF NOT EXISTS brutex.tbl_events (" +
|
||||
"btx_event_type VARCHAR(128) NOT NULL," +
|
||||
"btx_id VARCHAR(32) NOT NULL, " +
|
||||
"btx_obj_type VARCHAR(32) NOT NULL, " +
|
||||
"btx_obj_id VARCHAR(32) NOT NULL, " +
|
||||
"btx_timestamp BIGINT NOT NULL," +
|
||||
"btx_event CLOB" +
|
||||
");" +
|
||||
"CREATE INDEX IF NOT EXISTS brutex.btx_idx ON brutex.tbl_events (btx_obj_id, btx_obj_type, btx_event_type);" +
|
||||
"CREATE INDEX IF NOT EXISTS brutex.IDX_TO_DESC ON brutex.tbl_events (btx_timestamp ASC);";
|
||||
|
||||
public MiscServiceImpl() throws SchedulerException {
|
||||
}
|
||||
|
||||
public HostinfoType getHostinfo(String hostname) {
|
||||
HostInfo info = new HostInfo();
|
||||
info.setTaskName("HostInfo");
|
||||
RunTask runner = new RunTask(info);
|
||||
|
@ -55,10 +95,10 @@ public class MiscServiceImpl
|
|||
|
||||
ReturnCode ret = runner.postTask();
|
||||
HostinfoType infotype = new HostinfoType(
|
||||
ret.getProperty("NAME"),
|
||||
ret.getProperty("DOMAIN"),
|
||||
ret.getProperty("ADDR4"),
|
||||
ret.getProperty("ADDR6"));
|
||||
ret.getProperty("NAME"),
|
||||
ret.getProperty("DOMAIN"),
|
||||
ret.getProperty("ADDR4"),
|
||||
ret.getProperty("ADDR6"));
|
||||
return infotype;
|
||||
}
|
||||
|
||||
|
@ -69,36 +109,32 @@ public class MiscServiceImpl
|
|||
Properties props = System.getProperties();
|
||||
|
||||
Enumeration e = props.propertyNames();
|
||||
while (e.hasMoreElements())
|
||||
{
|
||||
String propName = (String)e.nextElement();
|
||||
while (e.hasMoreElements()) {
|
||||
String propName = (String) e.nextElement();
|
||||
|
||||
String propValue = (String)props.get(propName);
|
||||
String propValue = (String) props.get(propName);
|
||||
r.stdOut = (r.stdOut + propName + ": " + propValue + "\n");
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
public ReturnCode sendMailSimple(HostConnection mailhost, String from, String tolist, String subject, String message)
|
||||
{
|
||||
return sendMail(from, from, tolist, "", "", subject, message,
|
||||
"text/plain", null, mailhost.hostname, mailhost.port,
|
||||
mailhost.user, mailhost.password, "utf-8", false, false);
|
||||
public ReturnCode sendMailSimple(HostConnection mailhost, String from, String tolist, String subject, String message) {
|
||||
return sendMail(from, from, tolist, "", "", subject, message,
|
||||
"text/plain", null, mailhost.hostname, mailhost.port,
|
||||
mailhost.user, mailhost.password, "utf-8", false, false);
|
||||
}
|
||||
|
||||
public ReturnCode sendMailSimpleWithAttachment(HostConnection mailhost, String from, String tolist, String subject, String message, FileSetResource res)
|
||||
{
|
||||
return sendMail(from, from, tolist, "", "", subject, message,
|
||||
"text/plain", res, mailhost.hostname, mailhost.port,
|
||||
mailhost.user, mailhost.password, "utf-8", false, false);
|
||||
public ReturnCode sendMailSimpleWithAttachment(HostConnection mailhost, String from, String tolist, String subject, String message, FileSetResource res) {
|
||||
return sendMail(from, from, tolist, "", "", subject, message,
|
||||
"text/plain", res, mailhost.hostname, mailhost.port,
|
||||
mailhost.user, mailhost.password, "utf-8", false, false);
|
||||
}
|
||||
|
||||
public ReturnCode sendMail(HostConnection mailhost, String from, String tolist, String cclist, String bcclist, String subject, MailMimeType mimetype, String charset, String message, FileSetResource res, boolean ssl, boolean tls)
|
||||
{
|
||||
return sendMail(from, from, tolist, cclist, bcclist, subject, message,
|
||||
mimetype.value(), res, mailhost.hostname, mailhost.port,
|
||||
mailhost.user, mailhost.password, charset, tls, ssl);
|
||||
public ReturnCode sendMail(HostConnection mailhost, String from, String tolist, String cclist, String bcclist, String subject, MailMimeType mimetype, String charset, String message, FileSetResource res, boolean ssl, boolean tls) {
|
||||
return sendMail(from, from, tolist, cclist, bcclist, subject, message,
|
||||
mimetype.value(), res, mailhost.hostname, mailhost.port,
|
||||
mailhost.user, mailhost.password, charset, tls, ssl);
|
||||
}
|
||||
|
||||
public ReturnCode sleep(int minutes, int seconds) {
|
||||
|
@ -109,8 +145,7 @@ public class MiscServiceImpl
|
|||
return UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
private ReturnCode sendMail(String from, String replyto, String tolist, String cclist, String bcclist, String subject, String message, String messagemimetype, FileSetResource attachments, String mailhost, int mailport, String user, String password, String charset, boolean tls, boolean ssl)
|
||||
{
|
||||
private ReturnCode sendMail(String from, String replyto, String tolist, String cclist, String bcclist, String subject, String message, String messagemimetype, FileSetResource attachments, String mailhost, int mailport, String user, String password, String charset, boolean tls, boolean ssl) {
|
||||
EmailTask mail = new EmailTask();
|
||||
mail.setTaskName("Mail");
|
||||
RunTask runner = new RunTask(mail);
|
||||
|
@ -135,8 +170,7 @@ public class MiscServiceImpl
|
|||
return runner.postTask();
|
||||
}
|
||||
|
||||
private ReturnCode sleep(int hours, int minutes, int seconds, int milliseconds)
|
||||
{
|
||||
private ReturnCode sleep(int hours, int minutes, int seconds, int milliseconds) {
|
||||
Sleep sleep = new Sleep();
|
||||
sleep.setTaskName("Sleep");
|
||||
RunTask runner = new RunTask(sleep);
|
||||
|
@ -150,4 +184,145 @@ public class MiscServiceImpl
|
|||
public RuntimeInfoType getMemory() {
|
||||
return new RuntimeInfoType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigInteger lock(String id, String objectId) throws XServicesFault {
|
||||
|
||||
|
||||
|
||||
final String conString = "jdbc:h2:mem:lockdb;DB_CLOSE_DELAY=10;" +
|
||||
"INIT=CREATE SCHEMA IF NOT EXISTS brutex\\;" +
|
||||
// "SET SCHEMA brutex\\;" +
|
||||
"CREATE SEQUENCE IF NOT EXISTS brutex.btx_sequence1\\;" +
|
||||
"CREATE TABLE IF NOT EXISTS brutex.tbl_lock (btx_seq BIGINT NOT NULL, btx_id VARCHAR(100) NOT NULL, btx_obj_id VARCHAR(100) NOT NULL, btx_timestamp BIGINT NOT NULL);";
|
||||
|
||||
//JdbcConnectionPool cp = JdbcConnectionPool.create(conString, "sa", "");
|
||||
//cp.setMaxConnections(1);
|
||||
|
||||
Connection con = null;
|
||||
long rows = 0L;
|
||||
final long ts = new Date().getTime();
|
||||
try {
|
||||
Class.forName("org.h2.Driver"); //Java 1.8
|
||||
con = DriverManager.getConnection(conString);
|
||||
PreparedStatement prep = con.prepareStatement(
|
||||
"SELECT btx_id from brutex.tbl_lock where btx_obj_id=? ORDER BY btx_seq DESC");
|
||||
prep.setString(1, objectId);
|
||||
|
||||
ResultSet rs = prep.executeQuery();
|
||||
StringBuffer bf = new StringBuffer();
|
||||
while (rs.next()) {
|
||||
//bf.append(rs.getString(1));
|
||||
rows++;
|
||||
}
|
||||
rs.close();
|
||||
|
||||
prep = con.prepareStatement("INSERT INTO brutex.tbl_lock values (NEXT VALUE FOR brutex.btx_sequence1, ?, ?, ?)");
|
||||
prep.setString(1, id);
|
||||
prep.setString(2, objectId);
|
||||
prep.setLong(3, ts);
|
||||
prep.execute();
|
||||
|
||||
prep = con.prepareStatement("DELETE from brutex.tbl_lock WHERE btx_timestamp < ?");
|
||||
prep.setLong(1, ts - 10000);
|
||||
prep.execute();
|
||||
prep.close();
|
||||
|
||||
con.close();
|
||||
//System.out.println(bf);
|
||||
} catch (SQLException | ClassNotFoundException e) {
|
||||
throw new XServicesFault(e);
|
||||
}
|
||||
|
||||
return BigInteger.valueOf(rows);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ALFEventResponseType mergeALFEvent(ALFEventType event) throws XServicesFault {
|
||||
final Instant d = Instant.now();
|
||||
final long ts = d.toEpochMilli();
|
||||
//System.out.println("Step 1: " + ChronoUnit.MILLIS.between(Instant.now(), d));
|
||||
|
||||
final ServletContext servletContext =
|
||||
(ServletContext) context.getMessageContext().get(MessageContext.SERVLET_CONTEXT);
|
||||
final JdbcConnectionPool pool = (JdbcConnectionPool) servletContext.getAttribute("dbConnection");
|
||||
//System.out.println("Step 2: " + ChronoUnit.MILLIS.between(Instant.now(), d));
|
||||
final ObjectFactory of = new ObjectFactory();
|
||||
|
||||
final String objectId = event.getBase().getObjectId();
|
||||
final String eventId = event.getBase().getEventId();
|
||||
final String objectType = event.getBase().getObjectType();
|
||||
final String eventType = event.getBase().getEventType();
|
||||
|
||||
final String mergeStatememt = "MERGE INTO brutex.tbl_events " +
|
||||
"KEY (btx_event_type, btx_obj_type, btx_obj_id) " +
|
||||
"VALUES (?,?,?,?,?,?) " +
|
||||
"";
|
||||
|
||||
long rows = 0L;
|
||||
//System.out.println("Step 3: " + ChronoUnit.MILLIS.between(Instant.now(), d));
|
||||
try {
|
||||
//System.out.println("Step 4: " + ChronoUnit.MILLIS.between(Instant.now(), d));
|
||||
Marshaller m = JAXBContext.newInstance(ALFEventType.class).createMarshaller();
|
||||
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
|
||||
m.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
|
||||
JAXBElement<ALFEventType> e = of.createEventNotice(event);
|
||||
StringWriter sw = new StringWriter();
|
||||
m.marshal(e, sw);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(" <soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ns=\"http://www.eclipse.org/alf/schema/EventBase/1\">\n");
|
||||
sb.append("<soapenv:Body>\n");
|
||||
sb.append("<ns:EventNotice>\n");
|
||||
sb.append(sw);
|
||||
sb.append("</ns:EventNotice>\n");
|
||||
sb.append("</soapenv:Body>");
|
||||
sb.append("</soapenv:Envelope>");
|
||||
//System.out.println("Step 5: " + ChronoUnit.MILLIS.between(Instant.now(), d));
|
||||
Connection con = pool.getConnection();
|
||||
//System.out.println("Step 6: " + ChronoUnit.MILLIS.between(Instant.now(), d));
|
||||
PreparedStatement prep = con.prepareStatement(mergeStatememt);
|
||||
prep.setString(1, eventType);
|
||||
prep.setString(2, eventId);
|
||||
prep.setString(3, objectType);
|
||||
prep.setString(4, objectId);
|
||||
prep.setLong(5, ts);
|
||||
prep.setClob(6, new StringReader(sb.toString()));
|
||||
//prep.setLong(7, ts-20000);
|
||||
//System.out.println("Step 7 SQL START: " + ChronoUnit.MILLIS.between(Instant.now(), d));
|
||||
prep.execute();
|
||||
con.commit();
|
||||
con.close();
|
||||
//System.out.println("Step 8 SQL END: " + ChronoUnit.MILLIS.between(Instant.now(), d));
|
||||
//SimpleSoap ss = new SimpleSoap("http://localhost:8099/ALFEventManager/services/ALFEventManagerSOAP", sb.toString());
|
||||
//ss.sendSoap(false);
|
||||
|
||||
|
||||
// and start it off
|
||||
|
||||
if (!scheduler.isStarted())
|
||||
scheduler.start();
|
||||
if (scheduler.isInStandbyMode())
|
||||
scheduler.resumeAll();
|
||||
//System.out.println("Step 9: " + ChronoUnit.MILLIS.between(Instant.now(), d));
|
||||
synchronized (scheduler) {
|
||||
if (!scheduler.checkExists(JobKey.jobKey("ALFEmitter"))) {
|
||||
JobDetail job2 = JobBuilder.newJob(EventEmitter.class)
|
||||
.withIdentity("ALFEmitter").build();
|
||||
//job2.getJobDataMap().put("script", job.getScript());
|
||||
//job2.getJobDataMap().put("description", job.getDescription());
|
||||
//job2.getJobDataMap().put("date", job.getDate());
|
||||
|
||||
SimpleTrigger t = (SimpleTrigger) newTrigger()
|
||||
.withIdentity("ALFEmitter").startAt(Date.from(d.plusSeconds(20)))
|
||||
.build();
|
||||
|
||||
scheduler.scheduleJob(job2, t);
|
||||
}
|
||||
}
|
||||
//System.out.println("Step 10: " + ChronoUnit.MILLIS.between(Instant.now(), d));
|
||||
} catch (JAXBException | SQLException | SchedulerException e) {
|
||||
throw new XServicesFault(e);
|
||||
}
|
||||
return of.createALFEventResponseType();
|
||||
}
|
||||
}
|
|
@ -30,12 +30,12 @@ import javax.activation.DataHandler;
|
|||
import javax.jws.WebParam;
|
||||
import javax.jws.WebService;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.configuration2.ex.ConfigurationException;
|
||||
import org.apache.commons.configuration2.PropertiesConfiguration;
|
||||
import org.apache.commons.jcs.JCS;
|
||||
import org.apache.commons.jcs.access.exception.CacheException;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
|
||||
import net.brutex.DocBuilder.DocBuilder;
|
||||
import net.brutex.mgmt.api.generator.JITCompiler;
|
||||
|
@ -60,13 +60,10 @@ import net.brutex.xservices.ws.XServicesFault;
|
|||
* @author Brian Rosenberger
|
||||
*
|
||||
*/
|
||||
@Slf4j
|
||||
@WebService(targetNamespace = BrutexNamespaces.WS_XSERVICES, endpointInterface = "net.brutex.xservices.ws.OpenAirProxyService", serviceName = OpenAirProxyService.SERVICE_NAME)
|
||||
public class OpenAirProxyServiceImpl implements OpenAirProxyService {
|
||||
|
||||
/*
|
||||
* Log4j2 Set Up
|
||||
*/
|
||||
private final Logger logger = LogManager.getLogger(OpenAirProxyServiceImpl.class);
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
|
@ -462,7 +459,7 @@ public class OpenAirProxyServiceImpl implements OpenAirProxyService {
|
|||
final PropertiesConfiguration props;
|
||||
try {
|
||||
final String config = "../openair.properties";
|
||||
logger.debug("Loading Open Air connection details from " + this.getClass().getClassLoader().getResource("/")
|
||||
log.debug("Loading Open Air connection details from " + this.getClass().getClassLoader().getResource("/")
|
||||
+ config);
|
||||
|
||||
final URL configloc = this.getClass().getClassLoader().getResource(config);
|
||||
|
@ -479,14 +476,8 @@ public class OpenAirProxyServiceImpl implements OpenAirProxyService {
|
|||
|
||||
con = new OpenAirRestConnection(JCS.getInstance("OACache"), company, user, password);
|
||||
return con;
|
||||
} catch (CacheException e) {
|
||||
logger.error(e);
|
||||
e.printStackTrace();
|
||||
} catch (ConfigurationException e) {
|
||||
logger.error(e);
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
logger.error(e);
|
||||
} catch (CacheException | ConfigurationException | IOException e) {
|
||||
log.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ import javax.xml.stream.XMLOutputFactory;
|
|||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamWriter;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.brutex.xservices.types.AttributeType;
|
||||
import net.brutex.xservices.types.NamespaceListType;
|
||||
import net.brutex.xservices.types.NamespaceType;
|
||||
|
@ -54,8 +55,7 @@ import org.apache.axiom.om.OMText;
|
|||
import org.apache.axiom.om.OMXMLBuilderFactory;
|
||||
import org.apache.axiom.om.xpath.AXIOMXPath;
|
||||
|
||||
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;
|
||||
|
@ -64,9 +64,10 @@ import org.jaxen.SimpleNamespaceContext;
|
|||
* @author Brian Rosenberger, bru(at)brutex.de
|
||||
*
|
||||
*/
|
||||
@Slf4j
|
||||
@WebService(targetNamespace = "http://ws.xservices.brutex.net", endpointInterface = "net.brutex.xservices.ws.XmlService", serviceName = "XmlService")
|
||||
public class XmlServiceImpl implements XmlService {
|
||||
private static final Logger logger = LogManager.getLogger();
|
||||
|
||||
|
||||
public String insertNodesFromFile(FileResource res, NamespaceListType nsList, String xpath, String xmlFragment)
|
||||
throws XServicesFault {
|
||||
|
@ -94,7 +95,7 @@ public class XmlServiceImpl implements XmlService {
|
|||
XMLStreamWriter writer = xof.createXMLStreamWriter(sw);
|
||||
document.serialize(writer);
|
||||
|
||||
this.logger.trace(sw.getBuffer().toString());
|
||||
log.debug(sw.getBuffer().toString());
|
||||
return sw.getBuffer().toString();
|
||||
} catch (JaxenException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -134,7 +135,7 @@ public class XmlServiceImpl implements XmlService {
|
|||
XMLStreamWriter writer = xof.createXMLStreamWriter(sw);
|
||||
document.serialize(writer);
|
||||
|
||||
this.logger.trace(sw.getBuffer().toString());
|
||||
log.debug(sw.getBuffer().toString());
|
||||
return sw.getBuffer().toString();
|
||||
} catch (JaxenException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -175,7 +176,7 @@ public class XmlServiceImpl implements XmlService {
|
|||
XMLStreamWriter writer = xof.createXMLStreamWriter(sw);
|
||||
document.serialize(writer);
|
||||
|
||||
this.logger.trace(sw.getBuffer().toString());
|
||||
log.debug(sw.getBuffer().toString());
|
||||
return sw.getBuffer().toString();
|
||||
} catch (JaxenException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -216,7 +217,7 @@ public class XmlServiceImpl implements XmlService {
|
|||
XMLStreamWriter writer = xof.createXMLStreamWriter(sw);
|
||||
document.serialize(writer);
|
||||
|
||||
this.logger.trace(sw.getBuffer().toString());
|
||||
log.debug(sw.getBuffer().toString());
|
||||
return sw.getBuffer().toString();
|
||||
} catch (JaxenException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -357,8 +358,8 @@ public class XmlServiceImpl implements XmlService {
|
|||
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() + "'.");
|
||||
log.debug("XPath '" + axp.toString() + "' has " + olist.size() + " matches.");
|
||||
log.debug("XPath root expression is: '" + axp.debug() + "'.");
|
||||
} catch (JaxenException e) {
|
||||
throw new XServicesFault(e.getMessage(), e);
|
||||
}
|
||||
|
@ -380,26 +381,25 @@ public class XmlServiceImpl implements XmlService {
|
|||
match = (OMElement) o;
|
||||
if ((o instanceof OMDocument))
|
||||
match = ((OMDocument) o).getOMDocumentElement();
|
||||
this.logger.debug(Messages.getString("XmlService.8"));
|
||||
log.debug(Messages.getString("XmlService.8"));
|
||||
break;
|
||||
case OMNode.TEXT_NODE:
|
||||
match = ((OMText) o).getParent();
|
||||
this.logger.debug(Messages.getString("XmlService.9"));
|
||||
log.debug(Messages.getString("XmlService.9"));
|
||||
break;
|
||||
case OMNode.COMMENT_NODE:
|
||||
// match = node.getParent();
|
||||
match = (OMContainer) node;
|
||||
this.logger.debug(Messages.getString("XmlService.10"));
|
||||
log.debug(Messages.getString("XmlService.10"));
|
||||
break;
|
||||
default:
|
||||
this.logger
|
||||
.error("XPath matched " + o.getClass().getCanonicalName() + " Node Type:" + node.getType());
|
||||
this.logger.error(Messages.getString("XmlService.11"));
|
||||
log.error("XPath matched " + o.getClass().getCanonicalName() + " Node Type:" + node.getType());
|
||||
log.error(Messages.getString("XmlService.11"));
|
||||
throw new XServicesFault(Messages.getString("XmlService.12"));
|
||||
}
|
||||
} else {
|
||||
this.logger.error("XPath matched " + o.getClass().getCanonicalName());
|
||||
this.logger.error(Messages.getString("XmlService.11"));
|
||||
log.error("XPath matched " + o.getClass().getCanonicalName());
|
||||
log.error(Messages.getString("XmlService.11"));
|
||||
throw new XServicesFault(Messages.getString("XmlService.12"));
|
||||
}
|
||||
|
||||
|
@ -419,8 +419,8 @@ public class XmlServiceImpl implements XmlService {
|
|||
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() + "'.");
|
||||
log.debug("XPath '" + axp.toString() + "' has " + olist.size() + " matches.");
|
||||
log.debug("XPath root expression is: '" + axp.debug() + "'.");
|
||||
} catch (JaxenException e) {
|
||||
throw new XServicesFault(e.getMessage(), e);
|
||||
}
|
||||
|
@ -442,17 +442,16 @@ public class XmlServiceImpl implements XmlService {
|
|||
match = (OMElement) o;
|
||||
if ((o instanceof OMDocument))
|
||||
match = ((OMDocument) o).getOMDocumentElement();
|
||||
this.logger.debug(Messages.getString("XmlService.8"));
|
||||
log.debug(Messages.getString("XmlService.8"));
|
||||
break;
|
||||
default:
|
||||
this.logger
|
||||
.error("XPath matched " + o.getClass().getCanonicalName() + " Node Type:" + node.getType());
|
||||
this.logger.error(Messages.getString("XmlService.11"));
|
||||
log.error("XPath matched " + o.getClass().getCanonicalName() + " Node Type:" + node.getType());
|
||||
log.error(Messages.getString("XmlService.11"));
|
||||
throw new XServicesFault(Messages.getString("XmlService.12"));
|
||||
}
|
||||
} else {
|
||||
this.logger.error("XPath matched " + o.getClass().getCanonicalName());
|
||||
this.logger.error(Messages.getString("XmlService.11"));
|
||||
log.error("XPath matched " + o.getClass().getCanonicalName());
|
||||
log.error(Messages.getString("XmlService.11"));
|
||||
throw new XServicesFault(Messages.getString("XmlService.12"));
|
||||
}
|
||||
|
||||
|
@ -472,11 +471,11 @@ public class XmlServiceImpl implements XmlService {
|
|||
if (nsList != null) {
|
||||
for (NamespaceType ns : nsList.getNamespaces()) {
|
||||
context.addNamespace(ns.getPrefix(), ns.getUri().toString());
|
||||
this.logger.debug(
|
||||
log.debug(
|
||||
Messages.getString("XmlService.0") + ns.getPrefix() + "=\"" + ns.getUri().toString() + "\"'");
|
||||
}
|
||||
} else {
|
||||
logger.debug("No namespaces defined.");
|
||||
log.debug("No namespaces defined.");
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
@ -490,7 +489,7 @@ public class XmlServiceImpl implements XmlService {
|
|||
} catch (IllegalCharsetNameException e) {
|
||||
throw new XServicesFault("Endcoding '" + encoding + "' is not supported by this JRE.");
|
||||
}
|
||||
logger.debug("Setting source xml string encoding to '" + encoding + "'");
|
||||
log.debug("Setting source xml string encoding to '" + encoding + "'");
|
||||
return encoding;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ import java.util.StringTokenizer;
|
|||
import javax.ws.rs.core.HttpHeaders;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.brutex.xservices.types.scm.AttributeType;
|
||||
import net.brutex.xservices.types.scm.ItemListType;
|
||||
import net.brutex.xservices.types.scm.ItemType;
|
||||
|
@ -29,8 +30,6 @@ 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;
|
||||
|
@ -45,15 +44,16 @@ import org.netbeans.lib.cvsclient.connection.AuthenticationException;
|
|||
import org.netbeans.lib.cvsclient.event.EventManager;
|
||||
import org.netbeans.lib.cvsclient.event.FileInfoEvent;
|
||||
|
||||
@Slf4j
|
||||
public class CVSInfoImpl implements CVSInfo {
|
||||
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();
|
||||
CVSInfoImpl.logger.debug("forceNoCache=" + forceNoCache);
|
||||
log.debug("forceNoCache=" + forceNoCache);
|
||||
ItemListType cacheresult = (ItemListType) getCacheInstance().get(
|
||||
cachekey);
|
||||
|
||||
|
@ -121,7 +121,7 @@ public class CVSInfoImpl implements CVSInfo {
|
|||
try {
|
||||
CVSInfoImpl.this.getCacheInstance().put(key, cvsfile);
|
||||
} catch (CacheException e) {
|
||||
CVSInfoImpl.logger.error("Could not cache item '"
|
||||
log.error("Could not cache item '"
|
||||
+ key + "'", e);
|
||||
}
|
||||
}
|
||||
|
@ -142,14 +142,14 @@ public class CVSInfoImpl implements CVSInfo {
|
|||
|
||||
rlog.setRecursive(isRecursive);
|
||||
|
||||
CVSInfoImpl.logger.info("Executing CVS command '" + rlog.getCVSCommand()
|
||||
log.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) {
|
||||
CVSInfoImpl.logger.error("CVS Configuration File '" + f.getAbsolutePath()
|
||||
log.error("CVS Configuration File '" + f.getAbsolutePath()
|
||||
+ f.getName() + "'not found.", e);
|
||||
} catch (CommandAbortedException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -172,7 +172,7 @@ public class CVSInfoImpl implements CVSInfo {
|
|||
|
||||
public Response getModules(HttpHeaders h, File f, boolean forceNoCache) {
|
||||
String cachekey = "Modules" + f.toURI().toString();
|
||||
CVSInfoImpl.logger.debug("forceNoCache=" + forceNoCache);
|
||||
log.debug("forceNoCache=" + forceNoCache);
|
||||
|
||||
ModuleListType response = (ModuleListType) getCacheInstance().get(
|
||||
cachekey);
|
||||
|
@ -200,12 +200,12 @@ public class CVSInfoImpl implements CVSInfo {
|
|||
CheckoutCommand co = new CheckoutCommand();
|
||||
co.setShowModulesWithStatus(true);
|
||||
|
||||
CVSInfoImpl.logger.info("Executing CVS command '" + co.getCVSCommand()
|
||||
log.info("Executing CVS command '" + co.getCVSCommand()
|
||||
+ "' against '" + cvsclient.getRoot().host + "@"
|
||||
+ cvsclient.getRoot().repository + "'");
|
||||
client.executeCommand(co, cvsclient.getGlobalOptions());
|
||||
if (list.getModules().size() == 0) {
|
||||
CVSInfoImpl.logger.warn("Repository '"
|
||||
log.warn("Repository '"
|
||||
+ cvsclient.getRoot().repository
|
||||
+ "' does not have modules");
|
||||
}
|
||||
|
@ -220,14 +220,14 @@ public class CVSInfoImpl implements CVSInfo {
|
|||
|
||||
public Response getTags(HttpHeaders h, File f, boolean withFiles) {
|
||||
String cachekey = f.toURI().toString() + ":taglist";
|
||||
CVSInfoImpl.logger.debug("Retrieving Tags from cache using key '" + cachekey
|
||||
log.debug("Retrieving Tags from cache using key '" + cachekey
|
||||
+ "'");
|
||||
TagListType tags = (TagListType) getCacheInstance().get(cachekey);
|
||||
if (tags != null) {
|
||||
CVSInfoImpl.logger.debug("Delivering Tags from cache.");
|
||||
log.debug("Delivering Tags from cache.");
|
||||
return Response.ok(tags).build();
|
||||
}
|
||||
CVSInfoImpl.logger.warn("Taglist not found in cache.");
|
||||
log.warn("Taglist not found in cache.");
|
||||
return Response.noContent().build();
|
||||
}
|
||||
|
||||
|
@ -239,17 +239,17 @@ public class CVSInfoImpl implements CVSInfo {
|
|||
ItemListType list = null;
|
||||
|
||||
if (!forceNoCache) {
|
||||
CVSInfoImpl.logger.debug("Retrieving file content from cache using key '"
|
||||
log.debug("Retrieving file content from cache using key '"
|
||||
+ cachekey + "'");
|
||||
list = (ItemListType) getCacheInstance().get(cachekey);
|
||||
}
|
||||
|
||||
if (list != null) {
|
||||
CVSInfoImpl.logger.debug("Delivering file content from cache.");
|
||||
log.debug("Delivering file content from cache.");
|
||||
return Response.ok(list).build();
|
||||
}
|
||||
|
||||
CVSInfoImpl.logger.warn("File content not found in cache.");
|
||||
log.warn("File content not found in cache.");
|
||||
list = this.FACTORY.createItemListType();
|
||||
try {
|
||||
CVSClient cvsclient = new CVSClient(f);
|
||||
|
@ -306,7 +306,7 @@ public class CVSInfoImpl implements CVSInfo {
|
|||
checkout.setModule(filestring);
|
||||
checkout.setPipeToOutput(true);
|
||||
|
||||
CVSInfoImpl.logger.info("Execute CVS command '" + checkout.getCVSCommand()
|
||||
log.info("Execute CVS command '" + checkout.getCVSCommand()
|
||||
+ "' against '" + cvsclient.getRoot().host + "@"
|
||||
+ cvsclient.getRoot().repository + "'");
|
||||
client.executeCommand(checkout, cvsclient.getGlobalOptions());
|
||||
|
@ -330,10 +330,10 @@ public class CVSInfoImpl implements CVSInfo {
|
|||
CacheAccess<Object, Object> jcs = null;
|
||||
String cacheinstance = "CVSCache";
|
||||
try {
|
||||
CVSInfoImpl.logger.trace("Getting cache instance named 'CVSCache'");
|
||||
log.trace("Getting cache instance named 'CVSCache'");
|
||||
jcs = JCS.getInstance("CVSCache");
|
||||
} catch (CacheException e) {
|
||||
CVSInfoImpl.logger.error("Failed to get cache instance", e);
|
||||
log.error("Failed to get cache instance", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
return jcs;
|
||||
|
@ -347,29 +347,24 @@ public class CVSInfoImpl implements CVSInfo {
|
|||
+ client.getRoot().repository;
|
||||
|
||||
String cachestring = "FINDINGS-" + cvsroot;
|
||||
CVSInfoImpl.logger
|
||||
.debug("Fetch searchFileContent response from cache using cachekey '"
|
||||
log.debug("Fetch searchFileContent response from cache using cachekey '"
|
||||
+ cachestring + "'");
|
||||
FindingsListType result = (FindingsListType) getCacheInstance()
|
||||
.get(cachestring);
|
||||
if (result != null)
|
||||
CVSInfoImpl.logger.debug("Found object for key '" + cachestring
|
||||
log.debug("Found object for key '" + cachestring
|
||||
+ "' in cache.");
|
||||
else {
|
||||
CVSInfoImpl.logger.debug("Found no object for key '" + cachestring
|
||||
log.debug("Found no object for key '" + cachestring
|
||||
+ "' in cache.");
|
||||
}
|
||||
|
||||
if (result != null)
|
||||
return Response.ok(result).build();
|
||||
} catch (CommandAbortedException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
} catch (AuthenticationException e) {
|
||||
} catch (CommandAbortedException | AuthenticationException | ConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return Response.noContent().build();
|
||||
return Response.noContent().build();
|
||||
}
|
||||
|
||||
private AttributeType getAttribute(String name, String value) {
|
||||
|
|
|
@ -33,14 +33,14 @@ import javax.ws.rs.core.HttpHeaders;
|
|||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
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;
|
||||
|
@ -78,9 +78,9 @@ import com.serena.dmclient.api.SystemAttributes;
|
|||
*
|
||||
* @author Brian Rosenberger, bru(at)brutex.de
|
||||
*/
|
||||
@Slf4j
|
||||
public class DIMCMInfoImpl implements DIMCMInfo {
|
||||
|
||||
Logger logger = LogManager.getLogger();
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
|
@ -238,14 +238,14 @@ public class DIMCMInfoImpl implements DIMCMInfo {
|
|||
|
||||
if (search == null || search.equals("")) {
|
||||
search = "*";
|
||||
logger.info("No search pattern supplied, using default '*'.");
|
||||
log.info("No search pattern supplied, using default '*'.");
|
||||
}
|
||||
|
||||
FileWalker finder = new FileWalker(search);
|
||||
try {
|
||||
Files.walkFileTree(dir.toPath(),
|
||||
EnumSet.of(FileVisitOption.FOLLOW_LINKS), depth, finder);
|
||||
logger.info("FileWalker returned '" + finder.getCount()
|
||||
log.info("FileWalker returned '" + finder.getCount()
|
||||
+ "' hits. '" + finder.getTotal()
|
||||
+ "' files have been scanned.");
|
||||
List<Path> result = finder.getResult();
|
||||
|
@ -261,7 +261,7 @@ public class DIMCMInfoImpl implements DIMCMInfo {
|
|||
list.add(new FileInfoType(f, baseuri));
|
||||
}
|
||||
} catch (IOException e2) {
|
||||
logger.error(e2.getMessage(), e2);
|
||||
log.error(e2.getMessage(), e2);
|
||||
;
|
||||
}
|
||||
}
|
||||
|
@ -324,7 +324,7 @@ public class DIMCMInfoImpl implements DIMCMInfo {
|
|||
if (conn != null)
|
||||
return conn;
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -47,6 +47,7 @@ import javax.ws.rs.core.Response;
|
|||
import javax.ws.rs.core.StreamingOutput;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.brutex.xservices.security.DirectoryPermission;
|
||||
import net.brutex.xservices.types.FileInfoType;
|
||||
import net.brutex.xservices.util.FileWalker;
|
||||
|
@ -54,8 +55,6 @@ import net.brutex.xservices.util.FileWalker;
|
|||
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;
|
||||
|
||||
|
@ -64,10 +63,10 @@ import org.apache.shiro.authz.UnauthorizedException;
|
|||
*
|
||||
* @author Brian Rosenberger, bru(at)brutex.de
|
||||
*/
|
||||
@Slf4j
|
||||
public class FileInfoImpl implements FileInfo {
|
||||
|
||||
|
||||
Logger logger = LogManager.getLogger();
|
||||
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -77,19 +76,19 @@ public class FileInfoImpl implements FileInfo {
|
|||
{
|
||||
if(dir==null) {
|
||||
dir = "c:/";
|
||||
logger.warn("No directory specified. Default is 'c:/'.");
|
||||
log.warn("No directory specified. Default is 'c:/'.");
|
||||
}
|
||||
isPermitted(dir);
|
||||
|
||||
URI baseuri = URI.create(uriInfo.getBaseUri()+FileInfo.BASE_PATH+"getFile?file=");
|
||||
|
||||
logger.info(String.format("Listing directory '%s'.", dir));
|
||||
log.info(String.format("Listing directory '%s'.", dir));
|
||||
if (level <= 0) level = 1;
|
||||
|
||||
if ((!withDir) && (!withFiles)) withFiles = true;
|
||||
String cachekey = level + "||" + withFiles + "||" + withDir + "||" + search + "||" + dir;
|
||||
try {
|
||||
logger.debug(String.format("Hitting cache with cachekey '%s'", cachekey));
|
||||
log.debug(String.format("Hitting cache with cachekey '%s'", cachekey));
|
||||
CacheAccess<Object, Object> jcs = JCS.getInstance("FileCache");
|
||||
|
||||
/*Try to retrieve the file list from the cache*/
|
||||
|
@ -98,9 +97,9 @@ public class FileInfoImpl implements FileInfo {
|
|||
if (list == null || !useCache) {
|
||||
list = setDirectory(baseuri, dir, withDir, withFiles, level, search);
|
||||
jcs.put(cachekey, list);
|
||||
logger.debug("Stored in Cache: " + list.toString());
|
||||
log.debug("Stored in Cache: " + list.toString());
|
||||
} else {
|
||||
logger.debug("Got from Cache: " + list.toString());
|
||||
log.debug("Got from Cache: " + list.toString());
|
||||
}
|
||||
|
||||
int fromIndex = 0;
|
||||
|
@ -110,7 +109,7 @@ public class FileInfoImpl implements FileInfo {
|
|||
if (toIndex > list.size()) toIndex = list.size();
|
||||
if (fromIndex > toIndex) fromIndex = toIndex;
|
||||
GenericEntity<List<FileInfoType>> sublist = new GenericEntity<List<FileInfoType>>(list.subList(fromIndex, toIndex)) {};
|
||||
logger.info(String.format("Returning items %s to %s from total of %s items in the list.", fromIndex, toIndex, list.size()));
|
||||
log.info(String.format("Returning items %s to %s from total of %s items in the list.", fromIndex, toIndex, list.size()));
|
||||
return Response.ok(sublist).build();
|
||||
} catch (CacheException e) {
|
||||
return Response.serverError().build();
|
||||
|
@ -133,13 +132,13 @@ public class FileInfoImpl implements FileInfo {
|
|||
|
||||
if(search==null || search.equals("") ) {
|
||||
search = "*";
|
||||
logger.info("No search pattern supplied, using default '*'.");
|
||||
log.info("No search pattern supplied, using default '*'.");
|
||||
}
|
||||
|
||||
FileWalker finder = new FileWalker(search);
|
||||
try {
|
||||
Files.walkFileTree(dir.toPath(), EnumSet.of(FileVisitOption.FOLLOW_LINKS), depth, finder);
|
||||
logger.info("FileWalker returned '"+finder.getCount()+"' hits. '" + finder.getTotal() + "' files have been scanned.");
|
||||
log.info("FileWalker returned '"+finder.getCount()+"' hits. '" + finder.getTotal() + "' files have been scanned.");
|
||||
List<Path> result = finder.getResult();
|
||||
for(Path f : result) {
|
||||
if(! withDirectories) {
|
||||
|
@ -151,7 +150,7 @@ public class FileInfoImpl implements FileInfo {
|
|||
list.add(new FileInfoType(f, baseuri));
|
||||
}
|
||||
} catch (IOException e2) {
|
||||
logger.error(e2.getMessage(), e2);;
|
||||
log.error(e2.getMessage(), e2);;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -196,7 +195,7 @@ public Response getFile(HttpHeaders paramHttpHeaders, String file) {
|
|||
//In case we can not find the media type for some reason
|
||||
//the default assignment is taken, so we can
|
||||
//ignore this error.
|
||||
logger.debug(String.format("Could not probe media type for file '%s'. Default is '%s'", path.toString(), mime.getType()), e);
|
||||
log.debug(String.format("Could not probe media type for file '%s'. Default is '%s'", path.toString(), mime.getType()), e);
|
||||
}
|
||||
Response r = Response.ok(path.toFile(), mime).build();
|
||||
String fileName = path.getFileName().toString();
|
||||
|
@ -204,7 +203,7 @@ public Response getFile(HttpHeaders paramHttpHeaders, String file) {
|
|||
return r;
|
||||
} catch (IOException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
logger.error(e1.getMessage(), e1);
|
||||
log.error(e1.getMessage(), e1);
|
||||
return Response.serverError().build();
|
||||
}
|
||||
}
|
||||
|
@ -252,7 +251,7 @@ private Response getDirectoryAsZip(final Path path) {
|
|||
|
||||
private boolean isPermitted(String dir) {
|
||||
if(! SecurityUtils.getSubject().isPermitted( new DirectoryPermission(dir))) {
|
||||
logger.warn(String.format("User '%s' does not have permission to access '%s'.",SecurityUtils.getSubject().getPrincipal(), dir ));
|
||||
log.warn(String.format("User '%s' does not have permission to access '%s'.",SecurityUtils.getSubject().getPrincipal(), dir ));
|
||||
throw new NotAuthorizedException(new UnauthorizedException("User does not have permission to access "+ dir));
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -8,13 +8,12 @@ import javax.ws.rs.core.GenericEntity;
|
|||
import javax.ws.rs.core.HttpHeaders;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
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.exception.CacheException;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import net.brutex.mgmt.api.xml.Customer;
|
||||
import net.brutex.mgmt.api.xml.DateFilter;
|
||||
|
@ -23,9 +22,9 @@ import net.brutex.mgmt.api.xml.Query.BOOL;
|
|||
import net.brutex.mgmt.api.xml.StringEntity;
|
||||
import net.brutex.mgmt.openair.OpenAirRestConnection;
|
||||
|
||||
@Slf4j
|
||||
public class OpenAirInfoServiceImpl implements OpenAirInfoService {
|
||||
|
||||
static final Logger logger = LogManager.getLogger();
|
||||
|
||||
|
||||
@Override
|
||||
public Response getCompanies(HttpHeaders paramHttpHeaders, String search) {
|
||||
|
@ -59,7 +58,7 @@ public class OpenAirInfoServiceImpl implements OpenAirInfoService {
|
|||
final PropertiesConfiguration props;
|
||||
try {
|
||||
final String config = "../openair.properties";
|
||||
logger.debug("Loading Open Air connection details from " + this.getClass().getClassLoader().getResource("/")
|
||||
log.debug("Loading Open Air connection details from '{}'.", this.getClass().getClassLoader().getResource("/")
|
||||
+ config);
|
||||
|
||||
final URL configloc = this.getClass().getClassLoader().getResource(config);
|
||||
|
@ -76,11 +75,8 @@ public class OpenAirInfoServiceImpl implements OpenAirInfoService {
|
|||
|
||||
con = new OpenAirRestConnection(JCS.getInstance("FileCache"), company, user, password);
|
||||
return con;
|
||||
} catch (CacheException e) {
|
||||
logger.error(e);
|
||||
e.printStackTrace();
|
||||
} catch (ConfigurationException e) {
|
||||
logger.error(e);
|
||||
} catch (CacheException | ConfigurationException e) {
|
||||
log.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
org.quartz.scheduler.instanceName = XServicesScheduler
|
||||
org.quartz.threadPool.threadCount = 3
|
||||
org.quartz.jobStore.class = org.quartz.simpl.RAMJobStore
|
||||
|
||||
|
||||
#org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX
|
||||
#org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.CloudscapeDelegate
|
||||
#org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.StdJDBCDelegate
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
# SLF4J's SimpleLogger configuration file
|
||||
# Simple implementation of Logger that sends all enabled log messages, for all defined loggers, to System.err.
|
||||
|
||||
# Default logging detail level for all instances of SimpleLogger.
|
||||
# Must be one of ("trace", "debug", "info", "warn", or "error").
|
||||
# If not specified, defaults to "info".
|
||||
org.slf4j.simpleLogger.defaultLogLevel=debug
|
||||
|
||||
# Logging detail level for a SimpleLogger instance named "xxxxx".
|
||||
# Must be one of ("trace", "debug", "info", "warn", or "error").
|
||||
# If not specified, the default logging detail level is used.
|
||||
org.slf4j.simpleLogger.log.net.brutex.xservices=debug
|
||||
|
||||
# Set to true if you want the current date and time to be included in output messages.
|
||||
# Default is false, and will output the number of milliseconds elapsed since startup.
|
||||
org.slf4j.simpleLogger.showDateTime=true
|
||||
|
||||
# The date and time format to be used in the output messages.
|
||||
# The pattern describing the date and time format is the same that is used in java.text.SimpleDateFormat.
|
||||
# If the format is not specified or is invalid, the default format is used.
|
||||
# The default format is yyyy-MM-dd HH:mm:ss:SSS Z.
|
||||
#org.slf4j.simpleLogger.dateTimeFormat=yyyy-MM-dd HH:mm:ss:SSS Z
|
||||
|
||||
# Set to true if you want to output the current thread name.
|
||||
# Defaults to true.
|
||||
#org.slf4j.simpleLogger.showThreadName=true
|
||||
|
||||
# Set to true if you want the Logger instance name to be included in output messages.
|
||||
# Defaults to true.
|
||||
org.slf4j.simpleLogger.showLogName=true
|
||||
|
||||
# Set to true if you want the last component of the name to be included in output messages.
|
||||
# Defaults to false.
|
||||
org.slf4j.simpleLogger.showShortLogName=true
|
|
@ -125,4 +125,40 @@
|
|||
<dispatcher>ERROR</dispatcher>
|
||||
</filter-mapping>
|
||||
<!-- Shiro -->
|
||||
|
||||
|
||||
<servlet>
|
||||
<servlet-name>H2Console</servlet-name>
|
||||
<servlet-class>org.h2.server.web.WebServlet</servlet-class>
|
||||
<!--
|
||||
<init-param>
|
||||
<param-name>webAllowOthers</param-name>
|
||||
<param-value></param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>trace</param-name>
|
||||
<param-value></param-value>
|
||||
</init-param>
|
||||
-->
|
||||
<load-on-startup>1</load-on-startup>
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>H2Console</servlet-name>
|
||||
<url-pattern>/console/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
<!--
|
||||
<security-role>
|
||||
<role-name>admin</role-name>
|
||||
</security-role>
|
||||
<security-constraint>
|
||||
<web-resource-collection>
|
||||
<web-resource-name>H2 Console</web-resource-name>
|
||||
<url-pattern>/console/*</url-pattern>
|
||||
</web-resource-collection>
|
||||
<auth-constraint>
|
||||
<role-name>admin</role-name>
|
||||
</auth-constraint>
|
||||
</security-constraint>
|
||||
-->
|
||||
|
||||
</web-app>
|
Loading…
Reference in New Issue