Subversion Repositories XServices

Compare Revisions

Ignore whitespace Rev 184 → Rev 185

/xservices/trunk/src/java/net/brutex/xservices/ws/rs/CVSInfoImpl.java
8,9 → 8,10
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.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,7 → 46,7
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();
 
49,7 → 53,7
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
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,7 → 142,7
 
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());
145,7 → 149,7
 
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 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
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 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
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
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
return Response.noContent().build();
}
 
public JCS getCacheInstance() {
JCS jcs = null;
public CacheAccess<Object, Object> getCacheInstance() {
CacheAccess<Object, Object> 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
+ 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.");
}
 
/xservices/trunk/src/java/net/brutex/xservices/ws/rs/DIMCMInfo.java
28,7 → 28,7
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;
 
/xservices/trunk/src/java/net/brutex/xservices/ws/rs/DIMCMInfoImpl.java
33,16 → 33,20
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
*/
public class DIMCMInfoImpl implements DIMCMInfo {
 
Logger logger = Logger.getLogger(DIMCMInfoImpl.class);
Logger logger = LogManager.getLogger();
 
/*
* (non-Javadoc)
93,7 → 97,7
/*
* try to hit cache first
*/
JCS cache = JCS.getInstance("DIMCM");
CacheAccess<Object, Object> cache = JCS.getInstance("DIMCM");
String cachekey = projSpec + directory + String.valueOf(recursive);
if(useCache) {
ItemTypeList cacheresult = (ItemTypeList) cache.get(cachekey);
328,7 → 332,8
*/
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
private String getBaseURL() {
final String CACHE_BASEURL = "DIMCM.conf.baseurl";
try {
JCS cache = JCS.getInstance("DIMCM");
CacheAccess<Object, Object> 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;
/xservices/trunk/src/java/net/brutex/xservices/ws/rs/FileInfoImpl.java
51,9 → 51,11
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
public class FileInfoImpl implements FileInfo {
Logger logger = Logger.getLogger(FileInfoImpl.class);
Logger logger = LogManager.getLogger();
 
/* (non-Javadoc)
88,7 → 90,7
String cachekey = level + "||" + withFiles + "||" + withDir + "||" + search + "||" + dir;
try {
logger.debug(String.format("Hitting cache with cachekey '%s'", cachekey));
JCS jcs = JCS.getInstance("FileCache");
CacheAccess<Object, Object> jcs = JCS.getInstance("FileCache");
 
/*Try to retrieve the file list from the cache*/
List<FileInfoType> list = (List<FileInfoType>)jcs.get(cachekey);