diff --git a/source/de/anomic/server/logging/GuiHandler.java b/source/de/anomic/server/logging/GuiHandler.java index 00c50d8b0..76292bf8e 100644 --- a/source/de/anomic/server/logging/GuiHandler.java +++ b/source/de/anomic/server/logging/GuiHandler.java @@ -45,6 +45,7 @@ package de.anomic.server.logging; import java.util.ArrayList; +import java.util.Date; import java.util.logging.ErrorManager; import java.util.logging.Filter; import java.util.logging.Formatter; @@ -143,23 +144,24 @@ public class GuiHandler extends Handler{ this.start++; } } - - /** - * Push any buffered output to the target Handler. - *

- * The buffer is then cleared. - */ + public synchronized LogRecord[] getLogArray() { - - LogRecord[] tempBuffer = new LogRecord[this.count]; + return this.getLogArray(null); + } + + + public synchronized LogRecord[] getLogArray(Long sequenceNumberStart) { + ArrayList tempBuffer = new ArrayList(this.count); for (int i = 0; i < this.count; i++) { int ix = (this.start+i)%this.buffer.length; LogRecord record = this.buffer[ix]; - tempBuffer[i] = record; + if ((sequenceNumberStart == null) || (record.getSequenceNumber() >= sequenceNumberStart.longValue())) { + tempBuffer.add(record); + } } - return tempBuffer; + return (LogRecord[]) tempBuffer.toArray(new LogRecord[tempBuffer.size()]); } public synchronized String getLog(boolean reversed, int lineCount) { diff --git a/source/de/anomic/soap/AbstractService.java b/source/de/anomic/soap/AbstractService.java index 8d9dc1fde..db45d56d7 100644 --- a/source/de/anomic/soap/AbstractService.java +++ b/source/de/anomic/soap/AbstractService.java @@ -292,7 +292,13 @@ public abstract class AbstractService { Document doc = null; try { DocumentBuilderFactory newDocBuilderFactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder newDocBuilder = newDocBuilderFactory.newDocumentBuilder(); + + // disable dtd validation + newDocBuilderFactory.setValidating(false); + newDocBuilderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); + newDocBuilderFactory.setFeature("http://xml.org/sax/features/validation", false); + + DocumentBuilder newDocBuilder = newDocBuilderFactory.newDocumentBuilder(); ByteArrayInputStream byteIn = new ByteArrayInputStream(content); doc = newDocBuilder.parse(byteIn); diff --git a/source/de/anomic/soap/httpdSoapHandler.java b/source/de/anomic/soap/httpdSoapHandler.java index 3db3b4505..43ceb3623 100644 --- a/source/de/anomic/soap/httpdSoapHandler.java +++ b/source/de/anomic/soap/httpdSoapHandler.java @@ -118,6 +118,8 @@ import de.anomic.server.logging.serverLog; */ public final class httpdSoapHandler extends httpdAbstractHandler implements httpdHandler { + public static final String SOAP_HANDLER_VERSION = "YaCySOAP V0.1"; + /* =============================================================== * Constants needed to set some SOAP properties @@ -216,12 +218,12 @@ public final class httpdSoapHandler extends httpdAbstractHandler implements http /** * Constructor of this class - * @param switchboard + * @param theSwitchboard */ - public httpdSoapHandler(serverSwitch switchboard) { + public httpdSoapHandler(serverSwitch theSwitchboard) { super(); - this.switchboard = switchboard; + this.switchboard = theSwitchboard; this.theLogger = new serverLog("SOAP"); // create a htRootPath: system pages @@ -231,7 +233,7 @@ public final class httpdSoapHandler extends httpdAbstractHandler implements http } if (this.htTemplatePath == null) { - this.htTemplatePath = new File(switchboard.getRootPath(), switchboard.getConfig("htTemplatePath","htroot/env/templates")); + this.htTemplatePath = new File(theSwitchboard.getRootPath(), theSwitchboard.getConfig("htTemplatePath","htroot/env/templates")); // if (!(this.htTemplatePath.exists())) this.htTemplatePath.mkdir(); } @@ -246,11 +248,11 @@ public final class httpdSoapHandler extends httpdAbstractHandler implements http additionalServices = new Properties(); // getting the property filename containing the file list - String fileName = switchboard.getConfig("soap.serviceDeploymentList",""); + String fileName = theSwitchboard.getConfig("soap.serviceDeploymentList",""); if (fileName.length() > 0) { BufferedInputStream fileInput = null; try { - File deploymentFile = new File(switchboard.getRootPath(),fileName); + File deploymentFile = new File(theSwitchboard.getRootPath(),fileName); fileInput = new BufferedInputStream(new FileInputStream(deploymentFile)); // load property list @@ -384,6 +386,8 @@ public final class httpdSoapHandler extends httpdAbstractHandler implements http Document doc = generateWSDL(msgContext); if (doc != null) { + // TODO: what about doc.getInputEncoding()? + // TODO: what about getXmlEncoding? // Converting the the wsdl document into a byte-array String responseDoc = XMLUtils.DocumentToString(doc); byte[] result = responseDoc.getBytes("UTF-8"); @@ -481,6 +485,7 @@ public final class httpdSoapHandler extends httpdAbstractHandler implements http sendMessage(conProp,requestHeader,response,soapEx.getStatusCode(),soapEx.getStatusText(),soapErrorMsg); } else { this.theLogger.logSevere("Unexpected Exception while sending data to client",e); + } } catch (Exception ex) { // the http response header was already send. Just log the error @@ -644,6 +649,10 @@ public final class httpdSoapHandler extends httpdAbstractHandler implements http return result; } + /** + * TODO: handle accept-charset http header + * TODO: what about content-encoding, transfer-encoding here? + */ protected void sendMessage(Properties conProp, httpHeader requestHeader, OutputStream out, int statusCode, String statusText, String contentType, byte[] MessageBody) throws IOException { // write out the response header respondHeader(conProp, out, statusCode, statusText, (MessageBody==null)?null:contentType, (MessageBody==null)?-1:MessageBody.length, null, null); @@ -653,6 +662,9 @@ public final class httpdSoapHandler extends httpdAbstractHandler implements http out.flush(); } + /** + * TODO: handle accept-charset http header + */ protected void sendMessage(Properties conProp, httpHeader requestHeader, OutputStream out, int statusCode, String statusText, Message soapMessage) throws IOException, SOAPException { httpChunkedOutputStream chunkedOut = null; GZIPOutputStream gzipOut = null; @@ -717,7 +729,7 @@ public final class httpdSoapHandler extends httpdAbstractHandler implements http String transferEncoding ) throws IOException { httpHeader outgoingHeader = new httpHeader(); - outgoingHeader.put(httpHeader.SERVER,"AnomicHTTPD (www.anomic.de)"); + outgoingHeader.put(httpHeader.SERVER, SOAP_HANDLER_VERSION); if (conttype != null) outgoingHeader.put(httpHeader.CONTENT_TYPE,conttype); if (contlength != -1) outgoingHeader.put(httpHeader.CONTENT_LENGTH, Long.toString(contlength)); if (contentEncoding != null) outgoingHeader.put(httpHeader.CONTENT_ENCODING, contentEncoding); diff --git a/source/de/anomic/soap/services/AdminService.java b/source/de/anomic/soap/services/AdminService.java index 28ee5451b..a727b62ea 100644 --- a/source/de/anomic/soap/services/AdminService.java +++ b/source/de/anomic/soap/services/AdminService.java @@ -46,6 +46,10 @@ package de.anomic.soap.services; import java.util.ArrayList; +import java.util.logging.Handler; +import java.util.logging.LogRecord; +import java.util.logging.Logger; +import java.util.logging.XMLFormatter; import javax.xml.parsers.ParserConfigurationException; @@ -58,6 +62,7 @@ import de.anomic.plasma.plasmaSwitchboard; import de.anomic.server.serverCore; import de.anomic.server.serverObjects; import de.anomic.server.serverThread; +import de.anomic.server.logging.GuiHandler; import de.anomic.soap.AbstractService; import de.anomic.yacy.yacyCore; import de.anomic.yacy.yacySeed; @@ -514,13 +519,14 @@ public class AdminService extends AbstractService { } /** + * Function to configure the message forwarding settings of a peer. + * @see Peer Configuration - Message Forwarding * - * @param enableForwarding - * @param forwardingCommand - * @param forwardingTo - * @throws AxisFault + * @param enableForwarding specifies if forwarding should be enabled + * @param forwardingCommand the forwarding command to use. e.g. /usr/sbin/sendmail + * @param forwardingTo the delivery destination. e.g. root@localhost * - * @link Peer Configuration - Message Forwarding + * @throws AxisFault if authentication failed */ public void setMessageForwarding( Boolean enableForwarding, @@ -545,6 +551,8 @@ public class AdminService extends AbstractService { } /** + * Function to query the current message forwarding configuration of a peer. + * @see Peer Configuration - Message Forwarding * * @return a XML document of the following format *

@@ -555,10 +563,9 @@ public class AdminService extends AbstractService {
      *   <msgForwardingTo>root@localhost</msgForwardingTo>
      * </msgForwarding>
      * 
- * @throws AxisFault - * @throws ParserConfigurationException * - * @link Peer Configuration - Message Forwarding + * @throws AxisFault if authentication failed + * @throws ParserConfigurationException on XML parser errors */ public Document getMessageForwarding() throws AxisFault, ParserConfigurationException { // extracting the message context @@ -583,4 +590,42 @@ public class AdminService extends AbstractService { return xmlDoc; } + + public Document getServerLog(Long sequenceNumber) throws Exception { + // extracting the message context + extractMessageContext(AUTHENTICATION_NEEDED); + + Handler logHandler = null; + LogRecord[] log = null; + + // getting the root handler + Logger logger = Logger.getLogger(""); + + // take a look for the GuiHandler + Handler[] handlers = logger.getHandlers(); + for (int i=0; i + + + + - + - + - + - + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + - + @@ -198,8 +209,8 @@ Built on Apr 22, 2006 (06:55:48 PDT)--> - + @@ -208,8 +219,8 @@ Built on Apr 22, 2006 (06:55:48 PDT)--> - + @@ -218,8 +229,8 @@ Built on Apr 22, 2006 (06:55:48 PDT)--> - + @@ -228,8 +239,8 @@ Built on Apr 22, 2006 (06:55:48 PDT)--> - + @@ -238,8 +249,8 @@ Built on Apr 22, 2006 (06:55:48 PDT)--> - + @@ -248,8 +259,8 @@ Built on Apr 22, 2006 (06:55:48 PDT)--> - + @@ -258,8 +269,8 @@ Built on Apr 22, 2006 (06:55:48 PDT)--> - + @@ -268,8 +279,8 @@ Built on Apr 22, 2006 (06:55:48 PDT)--> - + @@ -278,8 +289,8 @@ Built on Apr 22, 2006 (06:55:48 PDT)--> - + @@ -288,8 +299,8 @@ Built on Apr 22, 2006 (06:55:48 PDT)--> - + @@ -298,8 +309,8 @@ Built on Apr 22, 2006 (06:55:48 PDT)--> - + @@ -308,8 +319,8 @@ Built on Apr 22, 2006 (06:55:48 PDT)--> - + @@ -318,8 +329,8 @@ Built on Apr 22, 2006 (06:55:48 PDT)--> - + @@ -328,8 +339,8 @@ Built on Apr 22, 2006 (06:55:48 PDT)--> - + @@ -338,8 +349,8 @@ Built on Apr 22, 2006 (06:55:48 PDT)--> - + @@ -348,18 +359,28 @@ Built on Apr 22, 2006 (06:55:48 PDT)--> - + + + + + + + + + + + - + @@ -368,7 +389,7 @@ Built on Apr 22, 2006 (06:55:48 PDT)--> - + \ No newline at end of file diff --git a/test/de/anomic/soap/services/AdminServiceTest.java b/test/de/anomic/soap/services/AdminServiceTest.java index 2e72d923b..845d07285 100644 --- a/test/de/anomic/soap/services/AdminServiceTest.java +++ b/test/de/anomic/soap/services/AdminServiceTest.java @@ -63,4 +63,9 @@ public class AdminServiceTest extends AbstractServiceTest { (String)oldValues.get("msgForwardingTo") ); } + + public void testGetServerLog() throws RemoteException { + Document xml = ((AdminService)service).getServerLog(0); + System.out.println(XMLUtils.DocumentToString(xml)); + } }