Subversion Repositories XServices

Compare Revisions

Ignore whitespace Rev 198 → Rev 199

/xservices/trunk/src/main/java/net/brutex/xservices/ws/rs/CVSInfoImpl.java
12,6 → 12,7
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.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,8 → 44,9
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();
 
53,7 → 53,7
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
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,7 → 142,7
 
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());
149,7 → 149,7
 
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 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
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 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
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
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
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
+ 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) {
} catch (CommandAbortedException | AuthenticationException | ConfigurationException e) {
e.printStackTrace();
} catch (ConfigurationException e) {
e.printStackTrace();
} catch (AuthenticationException e) {
e.printStackTrace();
}
return Response.noContent().build();
return Response.noContent().build();
}
 
private AttributeType getAttribute(String name, String value) {