/** * Extract a numeric (int) value from the HTTP headers. */ public static int extractNumericHeaderValue (final String[] headers, final String key) { final String s = extractHeaderValue(headers, key); try { return Integer.parseInt(s); } catch (final Throwable t) { // ignore } return -1; }
/** * Determines how many bytes are still to be read. */ public static int determineBytesToRead (final String[] headers) { /* final int headerLength = extractNumericHeaderValue(headers, K_HEADER_LENGTH); final int contentLength = extractNumericHeaderValue(headers, K_CONTENT_LENGTH); log.debug ("determineBytesToRead() hl : "+headerLength+ " cl : "+contentLength+ " delta = "+(contentLength - headerLength)); return contentLength - headerLength; */ return extractNumericHeaderValue(headers, K_CONTENT_LENGTH); }
public org.jdom.Element getStatus () { org.jdom.Element result = new org.jdom.Element(getName()); result.addContent(XmlUtils.getClassElt(this)); result.addContent(XmlUtils.getRevisionElt("$Id: RestService.java 2713 2006-06-01 14:38:45Z jmettraux $")); return result; }
final String[] headers = extractHeaders(channel); final String firstLine = headers[0]; if ( ! verify(key, firstLine)) return; final Long sessionId = extractSessionId(firstLine); authenticate(key, headers); return;
/** * Returns the WorkSessionServer instance serving logins to the RMI * WorkSessions. */ protected WorkSessionServer getWorkSessionServer () throws Exception { WorkSessionServer result = (WorkSessionServer)this.getService() .getContext().lookup(sessionServerKey); if (result != null) return result; // // instantiating the workSessionServer result = new WorkSessionServerImpl(); ((Service)result).init (this.sessionServerKey, this.getService().getContext(), this.getService().getParams()); this.getService().getContext() .put(this.sessionServerKey, result); return result; }
public void init (final RestService service, final Long sessionId, final String username, final String password) throws ServiceException { super.init(service, sessionId, username, password); // // locating the coder that will be used final WorkItemCoderLoader loader = openwfe.org.engine.Definitions .getWorkItemCoderLoader(this.getService().getContext()); if (log.isDebugEnabled()) log.debug("init() loader is "+loader); this.coder = (XmlWorkItemAndHeaderCoder)loader.getXmlCoder(); log.info ("HeaderCoder successfully located"); }
String sAuth = extractHeaderValue(headers, "Authorization"); final Long sessionId = generateNewSessionId(); newRestSession(sessionId, ss[0], ss[1]); ss = null;
ServiceException setDefaultPort(DEFAULT_PORT); // else it will listen on 7000... log.info("Service '"+getName()+"' ready.");
public static org.jdom.Element parseBody (final SelectionKey key, final String[] headers) throws Exception { log.debug("parseBody()"); final int bytesToRead = RestService.determineBytesToRead(headers); //Thread.yield(); // // build XML doc final SocketChannel channel = (SocketChannel)key.channel(); final java.io.InputStream is = new java.io.BufferedInputStream (new ChannelInputStream(channel, bytesToRead, 100)); final org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(); final org.jdom.Document doc = builder.build(is); //Utils.dump // ("rest_session_", openwfe.org.xml.XmlUtils.toByteArray(doc)); return doc.getRootElement(); }
public void init (final RestService service, final Long sessionId, final String username, final String password) throws ServiceException { super.init(service, sessionId, username, password); // // locating the coder that will be used final WorkItemCoderLoader loader = Definitions .getWorkItemCoderLoader(this.getService().getContext()); this.coder = (XmlWorkItemCoder)loader.getXmlCoder(); log.info ("WorkItemCoder successfully located"); }