From: Julio G. <ju...@us...> - 2004-03-30 15:55:02
|
Update of /cvsroot/smartfrog/core/smartfrog/src/org/smartfrog/sfcore/common In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20917/smartfrog/src/org/smartfrog/sfcore/common Modified Files: ConfigurationDescriptor.java Log Message: Fixed problem when parsing DeploymentURL that contained a resource URL with ':' Index: ConfigurationDescriptor.java =================================================================== RCS file: /cvsroot/smartfrog/core/smartfrog/src/org/smartfrog/sfcore/common/ConfigurationDescriptor.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ConfigurationDescriptor.java 29 Mar 2004 17:24:14 -0000 1.7 --- ConfigurationDescriptor.java 30 Mar 2004 15:43:23 -0000 1.8 *************** *** 297,300 **** --- 297,304 ---- /** + * Internal buffer to parse urls. + */ + private String tempURL = null; + /** * Creates a Configuration Descriptor using a deployment URL * @param deploymentURL Format: 'name:ACTION:url:sfConfig:HOST:PROCESS' *************** *** 319,327 **** throw new SmartFrogInitException("Deployment URL: null"); } ! String tempURL = null; String item = null; deploymentURL = deploymentURL.trim(); if (deploymentURL.length() < 1) throw new SmartFrogInitException("Deployment URL: wrong format"); //Check if url starts with " and extract name: //"HOST guijarro-j-3.hpl.hp.com:rootProcess:sfDefault:display":TER:::localhost:subprocess; --- 323,333 ---- throw new SmartFrogInitException("Deployment URL: null"); } ! tempURL = null; String item = null; deploymentURL = deploymentURL.trim(); if (deploymentURL.length() < 1) throw new SmartFrogInitException("Deployment URL: wrong format"); + + // GET NAME //Check if url starts with " and extract name: //"HOST guijarro-j-3.hpl.hp.com:rootProcess:sfDefault:display":TER:::localhost:subprocess; *************** *** 347,359 **** } ! String[] deploymenturl = tempURL.split(":",-1); ! ! if (deploymenturl.length<1) throw ! new SmartFrogInitException("Deployment URL: wrong format"); try { ! if (deploymenturl[3]!=null) { ! //Logger.log("Type: "+(String)deploymenturl[0]); ! this.setActionType(deploymenturl[0]); ! } } catch (Exception ex) { throw new SmartFrogInitException( --- 353,360 ---- } ! //GET ACTION try { ! this.setActionType(tempURL.substring(0,tempURL.indexOf(":"))); ! tempURL = (tempURL.substring(tempURL.indexOf(":")+1,tempURL.length())); } catch (Exception ex) { throw new SmartFrogInitException( *************** *** 361,411 **** deploymentURL, ex); } try { ! if (deploymenturl[3]!=null) { ! //Logger.log("Url: "+(String)deploymenturl[1]); ! this.setUrl(deploymenturl[1]); ! if (this.getUrl().equals(" ")) { ! this.setUrl(null); ! } ! } ! } catch (Exception ex) { ! throw new SmartFrogInitException("Error parsing URL in: "+ ! deploymentURL, ex); ! } ! try { ! //Logger.log("DeployRef: "+(String)deploymenturl[2]); ! this.setDeployReference(deploymenturl[2]); } catch (Exception ex) { throw new SmartFrogInitException( ! "Error parsing DEPLOY_REFERENCE in: "+ deploymentURL, ex); } try { ! //Logger.log("host: "+(String)deploymenturl[3]); ! if (deploymenturl[3]!=null) { ! this.setHost((deploymenturl[3])); ! if (this.getHost().equals("")) { ! this.setHost(null); ! } ! } } catch (Exception ex) { throw new SmartFrogInitException("Error parsing HOST in: "+ deploymentURL, ex); } try { ! if (!deploymentURL.endsWith(":")) { ! //Logger.log("subproc: "+(String)deploymenturl[4]); ! if (deploymenturl[4]!=null) { ! this.setSubProcess(deploymenturl[4]); ! if (this.getSubProcess().equals("")) { ! this.setSubProcess(null); ! } ! } ! } } catch (Exception ex) { throw new SmartFrogInitException( ! "Error parsing SUBPROCESS in: "+ deploymentURL, ex); } } catch (Throwable thr){ this.resultException = thr; --- 362,400 ---- deploymentURL, ex); } + + //GET SUBPROCESS_NAME try { ! this.setSubProcess(getAndCutLastFieldTempURL (":")); } catch (Exception ex) { throw new SmartFrogInitException( ! "Error parsing SUBPROCESS_NAME in: "+ deploymentURL, ex); } + + //GET HOST_NAME try { ! this.setHost(getAndCutLastFieldTempURL (":")); } catch (Exception ex) { throw new SmartFrogInitException("Error parsing HOST in: "+ deploymentURL, ex); } + + //GET DEPLOY_REFERENCE try { ! this.setDeployReference(getAndCutLastFieldTempURL (":")); } catch (Exception ex) { throw new SmartFrogInitException( ! "Error parsing DEPLOY_REFERENCE in: "+ ! deploymentURL, ex); ! } ! //GET URL ! try { ! this.setUrl(tempURL); ! } catch (Exception ex) { ! throw new SmartFrogInitException( ! "Error parsing DEPLOY_REFERENCE in: "+ deploymentURL, ex); } + } catch (Throwable thr){ this.resultException = thr; *************** *** 415,418 **** --- 404,420 ---- /** + * Returns and cuts the last field from TempURL. Token marks the beginning + * of the field. + * @param token + * @return last field from TempURL marked by token + * @throws java.lang.Exception + */ + private String getAndCutLastFieldTempURL( String token) throws Exception{ + String field = null; + field = tempURL.substring(tempURL.lastIndexOf(token)+1,tempURL.length()); + tempURL= (tempURL.substring(0, tempURL.lastIndexOf(token))); + return field; + } + /** * * @param name application/component name *************** *** 666,669 **** --- 668,673 ---- */ public void setHost(String host) { + if (host==null) return; + if (host.trim().equals("")) return; this.host = host; } *************** *** 682,685 **** --- 686,691 ---- */ public void setSubProcess(String subProcess) { + if (subProcess==null) return; + if (subProcess.trim().equals("")) return; this.subProcess = subProcess; } |