}
}
int queueLength = 0;
try {
PipeWrapper pipe = null;
Map pipesAndThreads = null;
// Get pipesAndThreads object from webapp context.
// This is where running pipes and threads are listed
pipesAndThreads = (Map) this.getServletContext().getAttribute(PIPES_AND_THREADS);
boolean newThread = false;
if (pipesAndThreads == null) {
// No pipesAndThreads object exists -> no pipes have been started via HttpStart
// nor has SyncroStartup started any.
// Create synchronized map, as it may be modified simultaneously by several threads
pipesAndThreads = Collections.synchronizedMap(new HashMap());
this.getServletContext().setAttribute(PIPES_AND_THREADS,
pipesAndThreads);
}
Iterator pipesIt=pipesAndThreads.keySet().iterator();
boolean newPipe=true;
// Iterate through active pipes to see if the pipe the incoming request refers to
// is already executing
while(pipesIt.hasNext()){
PipeWrapper p = (PipeWrapper)pipesIt.next();
String db=((PipeExecutionThread)pipesAndThreads.get(p)).getDatabaseName();
//Since two databases could have pipes with the same name it is necessary to
//check that in addition to pipe name database name also matches.
if(p.getPipe().getName().equals(pipeName) && db.equals(database)){
//Pipe was found. No need to create a new pipe
newPipe=false;
pipe=p;
}
}
if(newPipe)
pipe = new PipeWrapper(pers.findPipeByName(pipeName), database, database + pipeName);
if(pipe == null || pipe.getPipe().getStartPassword() == null
|| !pipe.getPipe().getStartPassword().equals(startPassword)) {
return "ERROR: Incorrect pipe name or start password";
}
if(!pipe.getPipe().isHttpStartEnabled()) {
return "ERROR: HTTP start is not enabled for this pipe";
}
//If pipesAndThreads already contains the pipe, get the PipeExecutionThread from it
pipesIt=pipesAndThreads.keySet().iterator();
PipeExecutionThread pet = null;
while(pipesIt.hasNext()){
PipeWrapper p = (PipeWrapper)pipesIt.next();
String db=((PipeExecutionThread)pipesAndThreads.get(p)).getDatabaseName();
if(p.getPipe().getName().equals(pipe.getPipe().getName()) && db.equals(pipe.getDatabase())){
pet = (PipeExecutionThread) pipesAndThreads.get(p);
}
}
Long pipeId=pipe.getPipe().getId();