Package com.webobjects.appserver

Examples of com.webobjects.appserver.WOResponse


                workers[i].join();
            }
        } catch (InterruptedException ie) {}

        for (int i=0; i<theCount; i++) {
            WOResponse aResponse = responses[i];
            MInstance anInstance = (MInstance) instArray.objectAtIndex(i);
            if (aResponse != null) {
                anInstance.updateRegistration(new NSTimestamp());
                if (aResponse.headerForKey("x-webobjects-refusenewsessions") != null) {
                    anInstance.setRefusingNewSessions(true);
                } else {
                    anInstance.setRefusingNewSessions(false);
                }

                NSDictionary instanceResponse = null;
                NSData responseContent = aResponse.content();
                try {
                    instanceResponse = (NSDictionary) new _JavaMonitorDecoder().decodeRootObject(responseContent);
                } catch (WOXMLException wxe) {
                    try {
                        Object o = NSPropertyListSerialization.propertyListFromString(new String(responseContent.bytes()));
View Full Code Here


    @Override
    public WOActionResults defaultAction() {
        // KH - make this faster as well :)
        Application theApplication = (Application) WOApplication.application();
        WOResponse aResponse = theApplication.createResponseInContext(null);
        WORequest aRequest = request();
        MSiteConfig aConfig = theApplication.siteConfig();

        theApplication._lock.startReading();
        try {

            // Check for correct password
            String passwordHeader = aRequest.headerForKey("password");
            if (!aConfig.comparePasswordWithPassword(passwordHeader)) {
                NSLog.debug.appendln("Attempt to call Direct Action: defaultAction with incorrect password.");
                aResponse.setStatus(WOMessage.HTTP_STATUS_FORBIDDEN);
                aResponse.appendContentString("Attempt to call Direct Action: defaultAction on wotaskd with incorrect password.");
                // we endReading at the finally block
                return aResponse;
            }

            aResponse.appendContentString("<html><head><title>Wotaskd for WebObjects 5</title></head><body>");
            aResponse.appendContentString("<center><b>Wotaskd for WebObjects 5: " + _hostName + "</b></center>");
            aResponse.appendContentString("<br><br><hr><br>Site Config as written to disk<br><hr><br><pre>");
            aResponse.appendContentString(WOMessage.stringByEscapingHTMLString(aConfig.generateSiteConfigXML()));
            aResponse.appendContentString("</pre><br><br><hr><br>Adaptor Config as sent to Local WOAdaptors - All Running Applications and Instances<br><hr><br><pre>");
            aResponse.appendContentString(WOMessage.stringByEscapingHTMLString(aConfig.generateAdaptorConfigXML(true, true)));
            aResponse.appendContentString("</pre><br><br><br><br>Adaptor Config as sent to remote WOAdaptors - All Registered and Running Applications and Instances<br><hr><br><pre>");
            aResponse.appendContentString(WOMessage.stringByEscapingHTMLString(aConfig.generateAdaptorConfigXML(true, false)));
            aResponse.appendContentString("</pre><br><br><hr><br>Adaptor Config as written to disk - All Registered Applications and Instances<br><hr><br><pre>");
            aResponse.appendContentString(WOMessage.stringByEscapingHTMLString(aConfig.generateAdaptorConfigXML(false, false)));
            aResponse.appendContentString("</pre><br><br><hr><br>Properties of this wotaskd<br><hr><br><pre>");

            aResponse.appendContentString("The Configuration Directory is: " + MSiteConfig.configDirectoryPath());
            aResponse.appendContentString("<br>");
            if (((Application)WOApplication.application()).shouldWriteAdaptorConfig()) {
                aResponse.appendContentString("Wotaskd is writing WOConfig.xml to disk");
            } else {
                aResponse.appendContentString("Wotaskd is NOT writing WOConfig.xml to disk");
            }
            aResponse.appendContentString("<br>");
            aResponse.appendContentString("The multicast address is: " + ((Application)WOApplication.application()).multicastAddress());
            aResponse.appendContentString("<br>");
            aResponse.appendContentString("This wotaskd is running on Port: " + WOApplication.application().port());
            aResponse.appendContentString("<br>");
            if (((Application)WOApplication.application()).shouldRespondToMulticast()) {
                aResponse.appendContentString("Wotaskd is responding to Multicast");
            } else {
                aResponse.appendContentString("Wotaskd is NOT responding to Multicast");
            }
            aResponse.appendContentString("<br>");
            aResponse.appendContentString("WOAssumeApplicationIsDeadMultiplier is " + (aConfig._appIsDeadMultiplier / 1000));
            aResponse.appendContentString("<br>");
            aResponse.appendContentString("The System Properties are: ");
            aResponse.appendContentString(WOMessage.stringByEscapingHTMLString(System.getProperties().toString()));
            aResponse.appendContentString("</pre><br><br></body></html>");
        } finally {
            theApplication._lock.endReading();
        }

        return aResponse;
View Full Code Here

        try {
            xml = ((Application)WOApplication.application()).siteConfig().generateAdaptorConfigXML(true, shouldIncludeUnregisteredInstances);
        } finally {
            theApplication._lock.endReading();
        }
        WOResponse aResponse = WOApplication.application().createResponseInContext(null);
        aResponse.appendContentString(xml);
        aResponse.setHeader("text/xml", "content-type");
        aResponse.setHeader(aFormat.format(new NSTimestamp()), "Last-Modified");
        if (NSLog.debugLoggingAllowedForLevelAndGroups(NSLog.DebugLevelDetailed, NSLog.DebugGroupDeployment))
            NSLog.debug.appendln("woConfigAction returned: " + xml);

        return aResponse;
    }
View Full Code Here


    // used by WOInfoCenter and perhaps others
    public WOActionResults findPortAction() {
        Application theApplication = (Application) WOApplication.application();
        WOResponse aResponse = theApplication.createResponseInContext(null);
        WORequest aRequest = request();
        String portString = null;

        // We wouldn't have registered it in the first place, so we don't regenerate
        if (WOHostUtilities.isAnyLocalInetAddress(aRequest._originatingAddress(), false) ) {
            String anAppName = request().stringFormValueForKey("appName");
            portString = theApplication.localMonitor().portForUnregisteredAppNamed(anAppName);
        }

        if (portString == null) {
            portString = "-1";
        }
        aResponse.appendContentString(portString);
        return aResponse;
    }
View Full Code Here

        appendIdentifierTagAndValue(this, _id, woresponse, wocontext);
      }

      @Override
      public void appendToResponse(WOResponse woresponse, WOContext wocontext) {
        WOResponse newResponse = cleanupXHTML ? new ERXResponse() : woresponse;
        super.appendToResponse(newResponse, wocontext);

        processResponse(this, newResponse, wocontext, 0, nameInContext(wocontext, wocontext.component()));
        if (ERXPatcher.DynamicElementsPatches.cleanupXHTML) {
          woresponse.appendContentString(newResponse.contentString());
        }
      }
View Full Code Here

        appendIdentifierTagAndValue(this, _id, woresponse, wocontext);
      }

      @Override
      public void appendToResponse(WOResponse woresponse, WOContext wocontext) {
        WOResponse newResponse = cleanupXHTML ? new ERXResponse() : woresponse;
        super.appendToResponse(newResponse, wocontext);

        processResponse(this, newResponse, wocontext, 0, nameInContext(wocontext, wocontext.component()));
        if (ERXPatcher.DynamicElementsPatches.cleanupXHTML) {
          woresponse.appendContentString(newResponse.contentString());
        }
      }
View Full Code Here

        }
        return null;
    }

    private WOResponse _handleRequest(WORequest aRequest) {
        WOResponse aResponse = BadLifebeatResponse;

        // http://localhost:1085/cgi-bin/WebObjects/wotaskd.woa/wlb?<notification name>&<instance name>&<hostname>&<port>
        // <notification name> = "hasStarted", "lifebeat", "willStop", "willCrash"

        NSArray values = NSArray.componentsSeparatedByString(aRequest.queryString(), "&");
View Full Code Here

        NSData content = new NSData(contentXML);

        //        String urlString = MObject.adminActionStringPrefix + anInstance.application().realName() + MObject.adminActionStringPostfix;
        String urlString = MObject.adminActionStringPrefix + anInstance.applicationName() + MObject.adminActionStringPostfix;
        WORequest aRequest = new WORequest(MObject._POST, urlString, MObject._HTTP1, null, content, null);
        WOResponse aResponse = null;

        try {
            WOHTTPConnection anHTTPConnection = new WOHTTPConnection(anInstance.host().name(), anInstance.port().intValue());
            anHTTPConnection.setReceiveTimeout(_receiveTimeout);
View Full Code Here

    private String errorResponse = null;

    public WOResponse sendRequestToWotaskd(WORequest aRequest, boolean willChange, boolean isSync) {
        if (NSLog.debugLoggingAllowedForLevelAndGroups(NSLog.DebugLevelDetailed, NSLog.DebugGroupDeployment))
            NSLog.debug.appendln("!@#$!@#$ sendRequestToWotaskd creates a WOHTTPConnection");
        WOResponse aResponse = null;

        try {
            WOHTTPConnection anHTTPConnection = new WOHTTPConnection(name(), WOApplication.application().lifebeatDestinationPort());
            anHTTPConnection.setReceiveTimeout(_receiveTimeout);
View Full Code Here

            NSLog.debug.appendln("!@#$!@#$ getSiteConfigFromHostAndPort creates a WOHTTPConnection");
        NSDictionary monitorRequest = new NSDictionary<String, String>("SITE", "queryWotaskd");
        NSData content = new NSData( (new _JavaMonitorCoder()).encodeRootObjectForKey(monitorRequest, "monitorRequest") );

        WORequest aRequest = new ERXRequest(MObject._POST, MObject.directActionString, MObject._HTTP1, NSDictionary.EmptyDictionary, content, null);
        WOResponse aResponse = null;

        try {
            WOHTTPConnection anHTTPConnection = new WOHTTPConnection(configHostName, aPort);
            anHTTPConnection.setReceiveTimeout(5000);

            if (anHTTPConnection.sendRequest(aRequest)) {
                aResponse = anHTTPConnection.readResponse();
            }
        } catch(Exception localException) {
            log.error("Failed to connect to Host: " + configHostName + " and Port: " + aPort);
            throw new MonitorException("Failed to connect to Host: " + configHostName + " and Port: " + aPort);
        }

        NSDictionary xmlDict = NSDictionary.EmptyDictionary;
        if (aResponse != null) {
            try {
                xmlDict = (NSDictionary) new _JavaMonitorDecoder().decodeRootObject(aResponse.content());
            } catch (WOXMLException wxe) {
                log.error("Got non-parsable data from Host: " + configHostName + " + and Port: " + aPort + ". Data received was: " + aResponse.contentString() + ". It is possible that the Wotaskd on the remote host is of the wrong version");
                throw new MonitorException("Got non-parsable data from Host: " + configHostName + " + and Port: " + aPort + ". Data received was: " +aResponse.contentString() + ". It is possible that the Wotaskd on the remote host is of the wrong version");
            }
        }

        NSArray errorResponse = (NSArray) xmlDict.valueForKey("errorResponse");
        if (errorResponse != null) {
View Full Code Here

TOP

Related Classes of com.webobjects.appserver.WOResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.