Пример #1
1
  /*
   * Obtain device names configured in the WebUI (ReGa)
   */
  private static void fetchDeviceNamesFromReGa() {
    lastFetch = System.currentTimeMillis();

    L.info("Obtaining ReGa device and channel names");
    String r =
        TCLRegaHandler.sendHMScript(
            "string id;"
                + "foreach(id, root.Channels ().EnumUsedIDs())"
                + "  {"
                + "   var ch=dom.GetObject(id);"
                + "   WriteLine(ch.Address()+\"\t\"+ch.Name());"
                + "  }"
                + "foreach(id, root.Devices().EnumUsedIDs())"
                + "  {"
                + "   var d=dom.GetObject(id);"
                + "   WriteLine(d.Address()+\":0\t\"+d.Name());"
                + "  }");
    if (r == null) return;
    String lines[] = r.split("\n");
    for (String l : lines) {
      String p[] = l.split("\t");
      synchronized (nameCache) {
        if (p.length == 2) nameCache.put(p[0], p[1]);
      }
    }
    couldFetchOnce = true;
    DeviceInfo.resolveNames();
  }
  public void addSelection(Point p) {
    ExprPoint ep = null;
    int minDist = -1;

    for (ExprPoint ex : points) {
      int sd = ex.screenDist(p);
      if (ep == null || sd < minDist) {
        ep = ex;
        minDist = sd;
      }
    }

    if (ep != null) {
      Set<Point> remove = new HashSet<Point>();
      for (Point rp : selections.keySet()) {
        if (selections.get(rp).equals(ep)) {
          remove.add(rp);
        }
      }

      selections.put(p, ep);

      for (Point rp : remove) {
        selections.remove(rp);
      }
    }
  }
Пример #3
0
    // Walks the tree, checking to make sure that we haven't violated any
    // logical constraints.  This is a method for debugging.
    public boolean check() {
      String path = pathLabel();
      if (suffixLink != null) {
        String suffixPath = suffixLink.pathLabel();
        if (!path.substring(1, path.length()).equals(suffixPath)) {
          logger.log(
              Level.SEVERE,
              String.format("Suffix Link for node (%s) didn't match: %s", path, suffixPath));
          return false;
        }
      }

      for (char c : childEdges.keySet()) {
        TreeEdge e = childEdges.get(c);
        if (!e.check()) {
          return false;
        }
      }

      for (int k : terminalEdges.keySet()) {
        TreeEdge e = terminalEdges.get(k);
        if (!e.check()) {
          return false;
        }
      }

      return true;
    }
  public void summaryAction(HttpServletRequest req, HttpServletResponse res) {
    if (AccountController.redirectIfNoCookie(req, res)) return;

    Map<String, Object> viewData = new HashMap<String, Object>();
    DocumentManager docMan = new DocumentManager();

    try {

      if (req.getParameter("documentId") != null) {
        // Get the document ID
        int docId = Integer.parseInt(req.getParameter("documentId"));
        // Get the document using document id
        Document document = docMan.get(docId);
        // Set title to name of the document
        viewData.put("title", document.getDocumentName());
        // Create List of access records
        List<AccessRecord> accessRecords = new LinkedList<AccessRecord>();
        // Add access records for document to the list
        accessRecords = docMan.getAccessRecords(docId);

        viewData.put("accessRecords", accessRecords);
      } else {
        // Go back to thread page.
      }

    } catch (Exception e) {
      Logger.getLogger("").log(Level.SEVERE, "An error occurred when getting profile user", e);
    }

    view(req, res, "/views/group/Document.jsp", viewData);
  }
  /**
   * Displays a Discussion Thread page
   *
   * <p>- Requires a cookie for the session user - Requires a threadId request parameter for the
   * HTTP GET
   *
   * @param req The HTTP Request
   * @param res The HTTP Response
   */
  public void discussionAction(HttpServletRequest req, HttpServletResponse res) {
    // Ensure there is a cookie for the session user
    if (AccountController.redirectIfNoCookie(req, res)) return;

    Map<String, Object> viewData = new HashMap<>();

    if (req.getMethod() == HttpMethod.Get) {

      // Get the thread
      GroupManager gm = new GroupManager();
      int threadId = Integer.parseInt(req.getParameter("threadId"));
      DiscussionManager discussionManager = new DiscussionManager();
      DiscussionThread thread = discussionManager.getThread(threadId);
      thread.setGroup(gm.get(thread.getGroupId()));
      thread.setPosts(discussionManager.getPosts(threadId));

      // get documents for the thread
      DocumentManager docMan = new DocumentManager();
      viewData.put("documents", docMan.getDocumentsForThread(threadId));

      viewData.put("thread", thread);
      viewData.put("title", "Discussion: " + thread.getThreadName());
      view(req, res, "/views/group/DiscussionThread.jsp", viewData);
    } else {
      httpNotFound(req, res);
    }
  }
Пример #6
0
 /**
  * Stores the value for the given field associated to last inserted symbol. If no symbol has been
  * inserted yet, an exception occurs.
  */
 public void putValue(final Field field, final double val) {
   final String symbol = symbols.get(symbols.size() - 1);
   Map<Field, Double> vs = values.get(symbol);
   if (vs == null) vs = new HashMap<Field, Double>();
   vs.put(field, val);
   this.values.put(symbol, vs);
 }
Пример #7
0
  /** @param aProperties the updated properties. */
  @SuppressWarnings("rawtypes")
  final void setProperties(final Dictionary aProperties) {
    final Map<String, String> newProps = new HashMap<String, String>();

    Enumeration keys = aProperties.keys();
    while (keys.hasMoreElements()) {
      final String key = (String) keys.nextElement();
      if (!KNOWN_KEYS.contains(key) && !IGNORED_KEYS.contains(key)) {
        LOG.log(Level.WARNING, "Unknown/unsupported profile key: " + key);
        continue;
      }

      final String value = aProperties.get(key).toString();
      newProps.put(key, value.trim());
    }

    // Verify whether all known keys are defined...
    final List<String> checkedKeys = new ArrayList<String>(KNOWN_KEYS);
    checkedKeys.removeAll(newProps.keySet());
    if (!checkedKeys.isEmpty()) {
      throw new IllegalArgumentException(
          "Profile settings not complete! Missing keys are: " + checkedKeys.toString());
    }

    this.properties.putAll(newProps);

    LOG.log(
        Level.INFO,
        "New device profile settings applied for {1} ({0}) ...", //
        new Object[] {getType(), getDescription()});
  }
Пример #8
0
 private void showExternalDownloadItems() {
   final Map<String, FcpPersistentGet> items = persistentQueue.getDownloadRequests();
   for (final FcpPersistentGet downloadRequest : items.values()) {
     if (!downloadModelItems.containsKey(downloadRequest.getIdentifier())) {
       addExternalItem(downloadRequest);
     }
   }
 }
Пример #9
0
 public void collectSuffixes(Set<StringSuffix> suffices) {
   suffices.addAll(suffixes);
   for (char key : childEdges.keySet()) {
     childEdges.get(key).tailNode.collectSuffixes(suffices);
   }
   for (int key : terminalEdges.keySet()) {
     terminalEdges.get(key).tailNode.collectSuffixes(suffices);
   }
 }
Пример #10
0
 public Map<String, Rxn> getReactions(String compartment) {
   TreeMap<String, Rxn> crxns = new TreeMap<String, Rxn>();
   for (String rn : reactions.keySet()) {
     Rxn r = reactions.get(rn);
     if (r.getLocation().equals(compartment)) {
       crxns.put(rn, r);
     }
   }
   return crxns;
 }
Пример #11
0
 public Set<String> getOutputReactions(Rxn r) {
   TreeSet<String> rxns = new TreeSet<String>();
   for (String rn : reactions.keySet()) {
     Rxn rxn = reactions.get(rn);
     if (r.connects(rxn)) {
       rxns.add(rn);
     }
   }
   return rxns;
 }
Пример #12
0
  private String calculateViewId(FacesContext context) {
    Map map = context.getExternalContext().getRequestMap();

    String viewId = (String) map.get(RequestDispatcher.INCLUDE_PATH_INFO);

    if (viewId == null) viewId = context.getExternalContext().getRequestPathInfo();

    if (viewId == null) viewId = (String) map.get(RequestDispatcher.INCLUDE_SERVLET_PATH);

    if (viewId == null) viewId = context.getExternalContext().getRequestServletPath();

    return viewId;
  }
  /**
   * Displays a page showing details for all groups in RGMS
   *
   * @param req The HTTP Request
   * @param res The HTTP Response
   */
  public void showgroupsAction(HttpServletRequest req, HttpServletResponse res) {
    // Ensure there is a cookie for the session user
    if (AccountController.redirectIfNoCookie(req, res)) return;

    Map<String, Object> viewData = new HashMap<String, Object>();
    viewData.put("title", "RGMS Groups");

    // Get all groups in the RGMS database
    GroupManager groupMan = new GroupManager();
    List<Group> groups = groupMan.getEveryGroup();
    viewData.put("allGroups", groups);

    view(req, res, "/views/group/ShowGroups.jsp", viewData);
  }
Пример #14
0
  /**
   * Stores the value for the given field associated to given symbol. Be careful: If symbol has not
   * been previously inserted, object will become incoherent.
   */
  public void putValue(final String symbol, final Field field, final double val) {
    Map<Field, Double> vs = values.get(symbol);
    if (vs == null) vs = new HashMap<Field, Double>();
    vs.put(field, val);
    this.values.put(symbol, vs);

    // Consistency check.
    for (int i = 0; i < this.symbols.size(); i++) {
      if (this.symbols.get(i).equals(symbol)) return;
    }
    log.severe(
        "Danger: inconsistent usage of ParseResult object. "
            + "'putValue' function should be called AFTER 'addSymbol'. "
            + "Read documentation");
  }
Пример #15
0
  /**
   * Notifies this <tt>ResponseCollector</tt> that a transaction described by the specified
   * <tt>BaseStunMessageEvent</tt> has failed. The possible reasons for the failure include
   * timeouts, unreachable destination, etc.
   *
   * @param event the <tt>BaseStunMessageEvent</tt> which describes the failed transaction and the
   *     runtime type of which specifies the failure reason
   * @see AbstractResponseCollector#processFailure(BaseStunMessageEvent)
   */
  @Override
  protected void processFailure(BaseStunMessageEvent event) {
    TransactionID transactionID = event.getTransactionID();

    logger.finest("A transaction expired: tranid=" + transactionID);
    logger.finest("localAddr=" + hostCandidate);

    /*
     * Clean up for the purposes of the workaround which determines the STUN
     * Request to which a STUN Response responds.
     */
    Request request;

    synchronized (requests) {
      request = requests.remove(transactionID);
    }
    if (request == null) {
      Message message = event.getMessage();

      if (message instanceof Request) request = (Request) message;
    }

    boolean completedResolvingCandidate = true;
    try {
      if (processErrorOrFailure(null, request, transactionID)) completedResolvingCandidate = false;
    } finally {
      if (completedResolvingCandidate) completedResolvingCandidate(request, null);
    }
  }
Пример #16
0
 @Override
 public void dispose() {
   synchronized (undisposed) {
     super.dispose();
     undisposed.remove(this);
   }
 }
Пример #17
0
  /**
   * Get the information associated with the specified key from the application information map.
   *
   * @param key The key corresponding to the piece of information requested
   * @param appInfo The map containing keyed application information
   * @return The information
   */
  private String getValue(final String key, final Map appInfo) {
    String value = (String) appInfo.get(key);
    if (value == null) {
      value = "Unspecified";
    }

    return value;
  }
Пример #18
0
  /**
   * Load the application information from the properties file specified by the application adaptor.
   * The resource bundle information is stored in a Map for convenient access.
   *
   * @param path Path to the source information.
   * @return The map containing the application information
   */
  private Map loadApplicationInfo(final String path) {
    Map infoMap;

    try {
      infoMap = Util.loadResourceBundle(path);
    } catch (MissingResourceException exception) {
      final String message = "No application \"About Box\" information resource found at: " + path;
      Logger.getLogger("global").log(Level.WARNING, message, exception);
      System.err.println(message);

      // substitute with default information
      infoMap = new HashMap();
      infoMap.put("name", Application.getAdaptor().getClass().getName());
    }

    return infoMap;
  }
Пример #19
0
 private String colorize(String string) {
   if (string.indexOf(ChatColor.COLOR_CHAR) < 0) {
     return string; // no colors in the message
   } else if (!jLine || !reader.getTerminal().isAnsiSupported()) {
     return ChatColor.stripColor(string); // color not supported
   } else {
     // colorize or strip all colors
     for (ChatColor color : colors) {
       if (replacements.containsKey(color)) {
         string = string.replaceAll("(?i)" + color.toString(), replacements.get(color));
       } else {
         string = string.replaceAll("(?i)" + color.toString(), "");
       }
     }
     return string + Ansi.ansi().reset().toString();
   }
 }
Пример #20
0
 /**
  * View traces for debugging
  *
  * @return printable version of traces
  */
 public static String getTraces() {
   StringBuilder sb = new StringBuilder();
   for (String s : undisposed.values()) {
     sb.append(s);
     sb.append("\n");
   }
   return sb.toString();
 }
Пример #21
0
 public void print(int indent, PrintStream ps) {
   if (isLeaf()) {
     printSuffixes(ps);
     ps.println();
   } else {
     int i = 0;
     for (char c : childEdges.keySet()) {
       TreeEdge edge = childEdges.get(c);
       edge.print(indent, i != 0, ps);
       i++;
     }
     for (int k : terminalEdges.keySet()) {
       TreeEdge edge = terminalEdges.get(k);
       edge.print(indent, i != 0, ps);
       i++;
     }
   }
 }
Пример #22
0
    public void addEdge(TreeEdge e) {
      if (e.start() == e.string.length() - 1) {
        int key = e.string.getIndex();
        if (terminalEdges.containsKey(key)) {
          throw new IllegalArgumentException();
        }

        e.headNode = this;
        terminalEdges.put(key, e);
      } else {
        char key = e.getChar(0);
        if (childEdges.containsKey(key)) {
          throw new IllegalArgumentException();
        }
        e.headNode = this;
        childEdges.put(key, e);
      }
    }
Пример #23
0
 private void remember(Object tv) { // remember where allocated
   synchronized (undisposed) {
     java.io.StringWriter sw = new java.io.StringWriter();
     java.io.PrintWriter pw = new java.io.PrintWriter(sw);
     new Exception("This vector was never disposed").printStackTrace(pw);
     pw.flush();
     undisposed.put(tv, sw.toString());
     // LOG.info("**********************************************");
     // LOG.info(sw.toString());
     max = Math.max(max, undisposed.size());
     total += 1;
     if (undisposed.size() > 12 && !printedUndisposed) {
       LOG.severe("**********************************************");
       LOG.severe(getTraces());
       LOG.severe("**********************************************");
       printedUndisposed = true;
     }
   }
 }
Пример #24
0
  /**
   * Sends a specific <tt>Request</tt> to the STUN server associated with this
   * <tt>StunCandidateHarvest</tt>.
   *
   * @param request the <tt>Request</tt> to send to the STUN server associated with this
   *     <tt>StunCandidateHarvest</tt>
   * @param firstRequest <tt>true</tt> if the specified <tt>request</tt> should be sent as the first
   *     request in the terms of STUN; otherwise, <tt>false</tt>
   * @return the <tt>TransactionID</tt> of the STUN client transaction through which the specified
   *     <tt>Request</tt> has been sent to the STUN server associated with this
   *     <tt>StunCandidateHarvest</tt>
   * @param transactionID the <tt>TransactionID</tt> of <tt>request</tt> because <tt>request</tt>
   *     only has it as a <tt>byte</tt> array and <tt>TransactionID</tt> is required for the
   *     <tt>applicationData</tt> property value
   * @throws StunException if anything goes wrong while sending the specified <tt>Request</tt> to
   *     the STUN server associated with this <tt>StunCandidateHarvest</tt>
   */
  protected TransactionID sendRequest(
      Request request, boolean firstRequest, TransactionID transactionID) throws StunException {
    if (!firstRequest && (longTermCredentialSession != null))
      longTermCredentialSession.addAttributes(request);

    StunStack stunStack = harvester.getStunStack();
    TransportAddress stunServer = harvester.stunServer;
    TransportAddress hostCandidateTransportAddress = hostCandidate.getTransportAddress();

    if (transactionID == null) {
      byte[] transactionIDAsBytes = request.getTransactionID();

      transactionID =
          (transactionIDAsBytes == null)
              ? TransactionID.createNewTransactionID()
              : TransactionID.createTransactionID(harvester.getStunStack(), transactionIDAsBytes);
    }
    synchronized (requests) {
      try {
        transactionID =
            stunStack.sendRequest(
                request, stunServer, hostCandidateTransportAddress, this, transactionID);
      } catch (IllegalArgumentException iaex) {
        if (logger.isLoggable(Level.INFO)) {
          logger.log(
              Level.INFO,
              "Failed to send "
                  + request
                  + " through "
                  + hostCandidateTransportAddress
                  + " to "
                  + stunServer,
              iaex);
        }
        throw new StunException(StunException.ILLEGAL_ARGUMENT, iaex.getMessage(), iaex);
      } catch (IOException ioex) {
        if (logger.isLoggable(Level.INFO)) {
          logger.log(
              Level.INFO,
              "Failed to send "
                  + request
                  + " through "
                  + hostCandidateTransportAddress
                  + " to "
                  + stunServer,
              ioex);
        }
        throw new StunException(StunException.NETWORK_ERROR, ioex.getMessage(), ioex);
      }

      requests.put(transactionID, request);
    }
    return transactionID;
  }
Пример #25
0
  /** Clones result COPYING all data into new variables. */
  public Object clone() {
    final ParseResult cloned = new ParseResult();

    for (int i = 0; i < this.symbols.size(); i++) {
      cloned.symbols.add(this.symbols.get(i));
    }

    for (final Map.Entry<String, Map<Field, Double>> entry1 : this.values.entrySet()) {
      final Map<Field, Double> vals = new HashMap<Field, Double>();
      for (final Map.Entry<Field, Double> entry2 : entry1.getValue().entrySet()) {
        vals.put(entry2.getKey(), entry2.getValue());
      }
      cloned.values.put(entry1.getKey(), vals);
    }

    for (final Calendar c : this.calendars) {
      cloned.calendars.add((Calendar) c.clone());
    }

    return cloned;
  }
 public DvnCitationFileWriter(Map<String, String> resultInfo) {
   this.offlineCitation = resultInfo.get("offlineCitation");
   this.subsetUNF = resultInfo.get("fileUNF");
   this.variableList = resultInfo.get("variableList");
   this.requestType = resultInfo.get("option");
   if ((resultInfo.containsKey("subsettingCriteria"))
       && (resultInfo.get("subsettingCriteria") != null)) {
     this.subsettingCriteria = resultInfo.get("subsettingCriteria");
   } else {
     this.subsettingCriteria = "";
   }
 }
Пример #27
0
  public void loadNetwork() throws IOException {
    logger.log(Level.INFO, "Loading metabolism network...");

    File file = props.getNetworkFile();
    Mapper<String, MetabolicEntry> entryMapper = new MetabolicEntry.MetabolicMapper();
    Parser<MetabolicEntry> parser = new Parser<MetabolicEntry>(file, entryMapper);

    while (parser.hasNext()) {
      MetabolicEntry entry = parser.next();
      entries.add(entry);

      Rxn rxn =
          new Rxn(
              props,
              entry.getReaction(),
              entry.getAbbreviation(),
              entry.getReactionName(),
              entry.getORF());
      reactions.put(entry.getAbbreviation(), rxn);

      locations.add(rxn.getLocation());

      LogicalORFTree lot = new LogicalORFTree(entry.getORF());
      ORFSet os = new ORFSet(entry.getORF());

      totalORFs.addAll(os.getORFs());
      orfSets.put(entry.getAbbreviation(), lot);
    }

    logger.log(Level.FINE, String.format("Loaded %d entries.", entries.size()));

    abbrevs = new MetabolismAbbreviations(props);
    abbrevs.loadAbbreviations();

    logger.log(Level.FINEST, "Loaded abbrevations.");
  }
  public void doLayout() {
    selections.clear();
    if (points == null) {
      points = new Vector<ExprPoint>();
    }
    points.clear();

    for (Pair<Integer, Double> p : watsonProbes) {
      ExprPoint ep = new ExprPoint(p.getFirst(), p.getLast(), '+');
      points.add(ep);
    }

    for (Pair<Integer, Double> p : crickProbes) {
      ExprPoint ep = new ExprPoint(p.getFirst(), p.getLast(), '-');
      points.add(ep);
    }
  }
Пример #29
0
 /*
  * Obtain device names from a JSON table (e.g. from hm-manager)
  */
 private static void fetchDeviceNamesFromNameTable(String filename) {
   lastFetch = System.currentTimeMillis();
   try (FileReader f = new FileReader(filename)) {
     JsonObject table = Json.parse(f).asObject();
     int cnt = 0;
     synchronized (nameCache) {
       for (Member m : table) {
         nameCache.put(m.getName(), m.getValue().asString());
         cnt++;
       }
     }
     L.log(Level.INFO, "Read " + cnt + " entries from name table " + filename);
     couldFetchOnce = true;
     DeviceInfo.resolveNames();
   } catch (Exception e) {
     L.log(Level.WARNING, "Error reading device name table " + filename, e);
   }
 }
  public void doProcess(HttpServletRequest req, HttpServletResponse res, boolean isPost) {
    StringBuffer bodyContent = null;
    OutputStream out = null;
    PrintWriter writer = null;
    String serviceKey = null;

    try {
      BufferedReader in = req.getReader();
      String line = null;
      while ((line = in.readLine()) != null) {
        if (bodyContent == null) bodyContent = new StringBuffer();
        bodyContent.append(line);
      }
    } catch (Exception e) {
    }
    try {
      if (requireSession) {
        // check to see if there was a session created for this request
        // if not assume it was from another domain and blow up
        // Wrap this to prevent Portlet exeptions
        HttpSession session = req.getSession(false);
        if (session == null) {
          res.setStatus(HttpServletResponse.SC_FORBIDDEN);
          return;
        }
      }
      serviceKey = req.getParameter("id");
      // only to preven regressions - Remove before 1.0
      if (serviceKey == null) serviceKey = req.getParameter("key");
      // check if the services have been loaded or if they need to be reloaded
      if (services == null || configUpdated()) {
        getServices(res);
      }
      String urlString = null;
      String xslURLString = null;
      String userName = null;
      String password = null;
      String format = "json";
      String callback = req.getParameter("callback");
      String urlParams = req.getParameter("urlparams");
      String countString = req.getParameter("count");
      // encode the url to prevent spaces from being passed along
      if (urlParams != null) {
        urlParams = urlParams.replace(' ', '+');
      }

      try {
        if (services.has(serviceKey)) {
          JSONObject service = services.getJSONObject(serviceKey);
          // default to the service default if no url parameters are specified
          if (urlParams == null && service.has("defaultURLParams")) {
            urlParams = service.getString("defaultURLParams");
          }
          String serviceURL = service.getString("url");
          // build the URL
          if (urlParams != null && serviceURL.indexOf("?") == -1) {
            serviceURL += "?";
          } else if (urlParams != null) {
            serviceURL += "&";
          }
          String apikey = "";
          if (service.has("username")) userName = service.getString("username");
          if (service.has("password")) password = service.getString("password");
          if (service.has("apikey")) apikey = service.getString("apikey");
          urlString = serviceURL + apikey;
          if (urlParams != null) urlString += "&" + urlParams;
          if (service.has("xslStyleSheet")) {
            xslURLString = service.getString("xslStyleSheet");
          }
        }
        // code for passing the url directly through instead of using configuration file
        else if (req.getParameter("url") != null) {
          String serviceURL = req.getParameter("url");
          // build the URL
          if (urlParams != null && serviceURL.indexOf("?") == -1) {
            serviceURL += "?";
          } else if (urlParams != null) {
            serviceURL += "&";
          }
          urlString = serviceURL;
          if (urlParams != null) urlString += urlParams;
        } else {
          writer = res.getWriter();
          if (serviceKey == null)
            writer.write("XmlHttpProxyServlet Error: id parameter specifying serivce required.");
          else
            writer.write(
                "XmlHttpProxyServlet Error : service for id '" + serviceKey + "' not  found.");
          writer.flush();
          return;
        }
      } catch (Exception ex) {
        getLogger().severe("XmlHttpProxyServlet Error loading service: " + ex);
      }

      Map paramsMap = new HashMap();
      paramsMap.put("format", format);
      // do not allow for xdomain unless the context level setting is enabled.
      if (callback != null && allowXDomain) {
        paramsMap.put("callback", callback);
      }
      if (countString != null) {
        paramsMap.put("count", countString);
      }

      InputStream xslInputStream = null;

      if (urlString == null) {
        writer = res.getWriter();
        writer.write(
            "XmlHttpProxyServlet parameters:  id[Required] urlparams[Optional] format[Optional] callback[Optional]");
        writer.flush();
        return;
      }
      // default to JSON
      res.setContentType(responseContentType);
      out = res.getOutputStream();
      // get the stream for the xsl stylesheet
      if (xslURLString != null) {
        // check the web root for the resource
        URL xslURL = null;
        xslURL = ctx.getResource(resourcesDir + "xsl/" + xslURLString);
        // if not in the web root check the classpath
        if (xslURL == null) {
          xslURL =
              XmlHttpProxyServlet.class.getResource(classpathResourcesDir + "xsl/" + xslURLString);
        }
        if (xslURL != null) {
          xslInputStream = xslURL.openStream();
        } else {
          String message =
              "Could not locate the XSL stylesheet provided for service id "
                  + serviceKey
                  + ". Please check the XMLHttpProxy configuration.";
          getLogger().severe(message);
          try {
            out.write(message.getBytes());
            out.flush();
            return;
          } catch (java.io.IOException iox) {
          }
        }
      }
      if (!isPost) {
        xhp.doGet(urlString, out, xslInputStream, paramsMap, userName, password);
      } else {
        if (bodyContent == null)
          getLogger()
              .info(
                  "XmlHttpProxyServlet attempting to post to url "
                      + urlString
                      + " with no body content");
        xhp.doPost(
            urlString,
            out,
            xslInputStream,
            paramsMap,
            bodyContent.toString(),
            req.getContentType(),
            userName,
            password);
      }
    } catch (Exception iox) {
      iox.printStackTrace();
      getLogger().severe("XmlHttpProxyServlet: caught " + iox);
      try {
        writer = res.getWriter();
        writer.write(iox.toString());
        writer.flush();
      } catch (java.io.IOException ix) {
        ix.printStackTrace();
      }
      return;
    } finally {
      try {
        if (out != null) out.close();
        if (writer != null) writer.close();
      } catch (java.io.IOException iox) {
      }
    }
  }