X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=webservices%2Fcompbio%2Fws%2Fserver%2FWSUtil.java;h=d0c92267353ecdeda930eb844e8f0494c591cb65;hb=5578f2d3e8226bd931755da3feeecb91fdb26c3f;hp=da4182c6b85b215a734bf2e7b0064e65e9677df9;hpb=0f73a668ad9aa4905b4c90948af0ede97b544c90;p=jabaws.git diff --git a/webservices/compbio/ws/server/WSUtil.java b/webservices/compbio/ws/server/WSUtil.java index da4182c..d0c9226 100644 --- a/webservices/compbio/ws/server/WSUtil.java +++ b/webservices/compbio/ws/server/WSUtil.java @@ -115,8 +115,7 @@ public final class WSUtil { static void reportUsage(ConfiguredExecutable confExec, Logger logger) { if (GAUtils.IS_GA_ENABLED) { - Services service = ServicesUtil.getServiceByRunner(confExec - .getExecutable().getClass()); + Services service = ServicesUtil.getServiceByRunner(confExec.getExecutable().getClass()); GAUtils.reportUsage(service); logger.info("Reporting GA usage for " + service); } @@ -128,15 +127,14 @@ public final class WSUtil { if (limit != null && limit.isExceeded(sequences)) { throw LimitExceededException.newLimitExceeded(limit, sequences); } - log.debug("Method: " + method + " with task: " + confExec.getTaskId()); compbio.runner.Util.writeInput(sequences, confExec); AsyncExecutor engine = Configurator.getAsyncEngine(confExec); String jobId = engine.submitJob(confExec); reportUsage(confExec, log); return jobId; } - - // Same as analize but Alifold takes clustal input not fasta + + // Same as analize(...) but RNAalifold takes clustal input not fasta // An if condition in the above method might be a better solution but // you need a way of finding out the type of confExec at runtime @@ -146,8 +144,6 @@ public final class WSUtil { if (limit != null && limit.isExceeded(sequences)) { throw LimitExceededException.newLimitExceeded(limit, sequences); } - log.debug("Method: " + method + " with task: " + confExec.getTaskId()); - // This line is different from the above method compbio.runner.Util.writeClustalInput(sequences, confExec, '-'); AsyncExecutor engine = Configurator.getAsyncEngine(confExec); String jobId = engine.submitJob(confExec); @@ -178,10 +174,28 @@ public final class WSUtil { } if (fs.getLength() != len) { throw new JobSubmissionException( - "All sequences must be of the same length. Please align " - + "the sequences prior to submission! The first sequence length is : " - + len + " but the sequence '" + fs.getId() - + "' length is " + fs.getLength()); + "All sequences must be of the same length. Please align the sequences " + + " prior to submission! The first sequence length is : " + len + + " but the sequence '" + fs.getId() + "' length is " + fs.getLength()); + } + } + } + + public static void validateJpredInput(List sequences) + throws JobSubmissionException { + validateFastaInput(sequences); + int len = 0; + for (FastaSequence fs : sequences) { + if (len == 0) { + len = fs.getLength(); + continue; + } + if (fs.getLength() != len) { + System.out.println("FASTA rec: id = " + fs.getId() + ": seq = " + fs.getSequence()); + throw new JobSubmissionException( + "All sequences must be of the same length. Please align the sequences " + + " prior to submission! The first sequence length is : " + len + + " but the sequence '" + fs.getId() + "' length is " + fs.getLength()); } } } @@ -190,48 +204,10 @@ public final class WSUtil { throws ResultNotAvailableException { WSUtil.validateJobId(jobId); AsyncExecutor asyncEngine = Configurator.getAsyncEngine(jobId); - ConfiguredExecutable aacon = (ConfiguredExecutable) asyncEngine - .getResults(jobId); - + ConfiguredExecutable aacon = (ConfiguredExecutable) asyncEngine.getResults(jobId); ScoreManager mas = aacon.getResults(); - log.trace(jobId + " getConservation : " + mas); return mas; } - - /* - * UNUSED - * - * @SuppressWarnings("unchecked") static LimitsManager - * getLimits(Class> clazz, WebServiceContext - * wsContext) { - * - * String LIMIT_KEY = CACHE_KEY + clazz.getCanonicalName(); LimitsManager - * limit = (LimitsManager) getObjectFromApplContext( LIMIT_KEY, - * wsContext); if (limit == null) { synchronized (WSUtil.class) { limit = - * (LimitsManager) getObjectFromApplContext(LIMIT_KEY, wsContext); if - * (limit == null) { limit = compbio.runner.Util - * .getLimits((Class>) clazz); - * addObjectToApplContext(wsContext, LIMIT_KEY, limit); } } } return limit; - * } - * - * static void addObjectToApplContext(WebServiceContext wsContext, String - * objKey, Object obj) { assert !Util.isEmpty(objKey) : - * "Key for the object must not be empty! "; assert wsContext != null; - * - * ServletContext ctx = ((javax.servlet.ServletContext) wsContext - * .getMessageContext().get(MessageContext. SERVLET_CONTEXT)); assert ctx != - * null; log.debug("Adding object with key '" + objKey + "' and value '" + - * obj + "' to the application context"); ctx.setAttribute(objKey, obj); } - * static Object getObjectFromApplContext(String objKey, WebServiceContext - * wsContext) { assert !Util.isEmpty(objKey) : - * "Key for the object must not be empty! "; assert wsContext != null; - * - * ServletContext ctx = ((javax.servlet.ServletContext) wsContext - * .getMessageContext().get(MessageContext. SERVLET_CONTEXT)); Object obj = - * ctx.getAttribute(objKey); log.trace("Retrieving object with key '" + - * objKey + "' and value '" + obj + "' from the application context"); - * return obj; } - */ }