Process a mod_cluster mgmt command.

@param exchange the http server exchange
@param requestData the request data
@param action   the mgmt action
@throws IOException
494956
void processCommand(final HttpServerExchange exchange, final RequestData requestData, final MCMPAction action) throws IOException {
        if (exchange.getRequestPath().equals("*") || exchange.getRequestPath().endsWith("/*")) {
            processNodeCommand(exchange, requestData, action);
        } else {
            processAppCommand(exchange, requestData, action);
        }
    }
464623
protected Object performInvocation(Exchange exchange, final Object serviceObject, Method m,
                                       Object[] paramArray) throws Exception {
        JaxRsFactoryBeanCustomizer beanCustomizer = findBeanCustomizer(serviceObject.getClass());
        if (beanCustomizer != null) {
            final OperationResourceInfo ori = exchange.get(OperationResourceInfo.class);
            final ClassResourceInfo cri = ori.getClassResourceInfo();

            try {
                Object rc = beanCustomizer.serviceInvoke(serviceObject,
                                                         m,
                                                         paramArray,
                                                         cri.isSingleton(),
                                                         getBeanCustomizerContext(beanCustomizer),
                                                         exchange.getInMessage());

                return rc;
            } finally {
                beanCustomizer.afterServiceInvoke(serviceObject,
                                                  cri.isSingleton(),
                                                  getBeanCustomizerContext(beanCustomizer));
            }

        } else
            return m.invoke(serviceObject, paramArray);
    }
66200
protected void handleRequest(final HttpString method, HttpServerExchange exchange) throws Exception {
        final RequestData requestData = parseFormData(exchange);
        boolean persistent = exchange.isPersistent();
        exchange.setPersistent(false); //UNDERTOW-947 MCMP should not use persistent connections
        if (CONFIG.equals(method)) {
            processConfig(exchange, requestData);
        } else if (ENABLE_APP.equals(method)) {
            processCommand(exchange, requestData, MCMPAction.ENABLE);
        } else if (DISABLE_APP.equals(method)) {
            processCommand(exchange, requestData, MCMPAction.DISABLE);
        } else if (STOP_APP.equals(method)) {
            processCommand(exchange, requestData, MCMPAction.STOP);
        } else if (REMOVE_APP.equals(method)) {
            processCommand(exchange, requestData, MCMPAction.REMOVE);
        } else if (STATUS.equals(method)) {
            processStatus(exchange, requestData);
        } else if (INFO.equals(method)) {
            processInfo(exchange);
        } else if (DUMP.equals(method)) {
            processDump(exchange);
        } else if (PING.equals(method)) {
            processPing(exchange, requestData);
        } else {
            exchange.setPersistent(persistent);
            next.handleRequest(exchange);
        }
    }
1134526
public void ack(String requestId, String resultMessage) throws TException
    {
        int index = this.requestedMap.remove(requestId);
        DRPCInvocationsClient client = this.clients.get(index);
        client.result(requestId, resultMessage);
    }
1273989
public OvhTask serviceName_request_POST(String serviceName, OvhRequestActionEnum action) throws IOException {
		String qPath = "/hosting/web/{serviceName}/request";
		StringBuilder sb = path(qPath, serviceName);
		HashMap<String, Object>o = new HashMap<String, Object>();
		addBody(o, "action", action);
		String resp = exec(qPath, "POST", sb.toString(), o);
		return convertTo(resp, OvhTask.class);
	}
1075991
public void doProcess(BasicServlet servlet, HttpServletRequest req, HttpServletResponse res, PrintWriter out) 
        throws ServletException, IOException
    {
        Map<String,Object> propRequest = this.getRequestProperties(req, true);
        String strBaseURL = (String)propRequest.get(DBParams.BASE_URL);
        if (strBaseURL != null)
        {
            if (strBaseURL.endsWith(AJAX))
                strBaseURL = strBaseURL.substring(0, strBaseURL.length() - AJAX.length());
            propRequest.put(DBParams.BASE_URL, strBaseURL);
        }
        String strCodeBase = this.getRealPath(req, DBConstants.BLANK);
        if ((strCodeBase != null) && (strCodeBase.length() > 0))
        {
            if (!strCodeBase.endsWith(System.getProperty("file.separator")))
                strCodeBase = strCodeBase + System.getProperty("file.separator");
            if (strCodeBase != null)
                propRequest.put(Params.CODEBASE, strCodeBase);
        }

        servlet.setContentType(res);
        InputStream in = null;  // Not used for the default.
        if (out == null)
            out = servlet.getOutputStream(res);

        String strTarget = (String)propRequest.get(TARGET);
        if (strTarget == null)
        {   // Application method
            String strCommand = (String)propRequest.get(REMOTE_COMMAND);
            if (CREATE_REMOTE_TASK.equals(strCommand))
            {
            	Map<String, Object> taskProperties = this.getProperties();
                if (taskProperties != null)
                    propRequest.putAll(taskProperties);
                Map<String,Object> properties = this.getNextPropertiesParam(in, PROPERTIES, propRequest);
                if (properties != null)
                    propRequest.putAll(properties);
                RemoteTask remoteTask = this.getNewRemoteTask(null, propRequest);
                String strUniqueID = this.add(new TaskHolder(this, remoteTask));
                out.write(strUniqueID);
            }
        }
        else 
        {
            try {
                BaseHolder baseHolder = this.getSessionFromPath(strTarget);
                if (baseHolder != null)
                	baseHolder.doProcess(in, out, propRequest);
                else
                {
                    if (ProxyConstants.FREE_REMOTE_SESSION.equals(propRequest.get(REMOTE_COMMAND)))
                        Utility.getLogger().info("Session not found, command: " + propRequest.get(REMOTE_COMMAND)); // Common to free main session first.
                    else
                        Utility.getLogger().warning("Session not found, command: " + propRequest.get(REMOTE_COMMAND));
                }
            } catch (RemoteException ex) {
                try {
                    this.setErrorReturn(out, ex);
                } catch (RemoteException e) {
                    e.printStackTrace();
                }
            }
        }
    }
207011
void processStatus(final HttpServerExchange exchange, final RequestData requestData) throws IOException {

        final String jvmRoute = requestData.getFirst(JVMROUTE);
        final String loadValue = requestData.getFirst(LOAD);

        if (loadValue == null || jvmRoute == null) {
            processError(TYPESYNTAX, SMISFLD, exchange);
            return;
        }

        UndertowLogger.ROOT_LOGGER.receivedNodeLoad(jvmRoute, loadValue);
        final int load = Integer.parseInt(loadValue);
        if (load > 0 || load == -2) {

            final Node node = container.getNode(jvmRoute);
            if (node == null) {
                processError(MCMPErrorCode.CANT_READ_NODE, exchange);
                return;
            }

            final NodePingUtil.PingCallback callback = new NodePingUtil.PingCallback() {
                @Override
                public void completed() {
                    final String response = "Type=STATUS-RSP&State=OK&JVMRoute=" + jvmRoute + "&id=" + creationTime;
                    try {
                        if (load > 0) {
                            node.updateLoad(load);
                        }
                        sendResponse(exchange, response);
                    } catch (Exception e) {
                        UndertowLogger.ROOT_LOGGER.failedToSendPingResponse(e);
                    }
                }

                @Override
                public void failed() {
                    final String response = "Type=STATUS-RSP&State=NOTOK&JVMRoute=" + jvmRoute + "&id=" + creationTime;
                    try {
                        node.markInError();
                        sendResponse(exchange, response);
                    } catch (Exception e) {
                        UndertowLogger.ROOT_LOGGER.failedToSendPingResponseDBG(e, node.getJvmRoute(), jvmRoute);
                    }
                }
            };

            // Ping the node
            node.ping(exchange, callback);

        } else if (load == 0) {
            final Node node = container.getNode(jvmRoute);
            if (node != null) {
                node.hotStandby();
                sendResponse(exchange, "Type=STATUS-RSP&State=OK&JVMRoute=" + jvmRoute + "&id=" + creationTime);
            } else {
                processError(MCMPErrorCode.CANT_READ_NODE, exchange);
            }
        } else if (load == -1) {
            // Error, disable node
            final Node node = container.getNode(jvmRoute);
            if (node != null) {
                node.markInError();
                sendResponse(exchange, "Type=STATUS-RSP&State=NOTOK&JVMRoute=" + jvmRoute + "&id=" + creationTime);
            } else {
                processError(MCMPErrorCode.CANT_READ_NODE, exchange);
            }
        } else {
            processError(TYPESYNTAX, SMISFLD, exchange);
        }
    }
381670
@PreAuthorize("hasRole('ROLE_TWE_ADMIN')")
    @RequestMapping(method = RequestMethod.POST, value = "/workflow/instances/{woinRefNum}")
    public String performActionOnInstance( RedirectAttributes model, @PathVariable long woinRefNum, @RequestParam() String action ){
        if( "abort".equals( action ) || "suspend".equals( action ) || "resume".equals( action ) || "retry".equals( action ) ){
            try{
                if( "abort".equals( action ) ){
                    facade.abortWorkflowInstance( woinRefNum );
                    model.addFlashAttribute( "successMessage", "workflow.instance.action.abort.success" );
                }
                else if( "suspend".equals( action ) ){
                    facade.suspendWorkflowInstance( woinRefNum );
                    model.addFlashAttribute( "successMessage", "workflow.instance.action.suspend.success" );
                }
                else if( "resume".equals( action ) ){
                    facade.resumeWorkflowInstance( woinRefNum );
                    model.addFlashAttribute( "successMessage", "workflow.instance.action.resume.success" );
                }
                else if( "retry".equals( action ) ){
                    facade.retryWorkflowInstance( woinRefNum );
                    model.addFlashAttribute( "successMessage", "workflow.instance.action.retry.success" );
                }
            }
            catch( UnexpectedStatusException e ){
                model.addFlashAttribute( "errorMessage", "workflow.instance.action.error.unexpectedstatus" );
            }
        }
        else{
            model.addFlashAttribute( "unknownAction", action );
            model.addFlashAttribute( "errorMessage", "workflow.instance.action.error.unknownaction" );
        }
        return "redirect:" + configuration.getConsoleMappingPrefix() + "/console/workflow/instances/" + woinRefNum;
    }
696197
public void process(RootDoc root) throws IOException {
        // out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
        out.println("<XMI xmi.version=\"1.1\" >");

        out.println(" <XMI.header>");
        out.println("  <XMI.metamodel href=\"/vol/acfiles7/egonw/SourceForge/CDK/cdk/reports/javadoc/test2.xmi\" version=\"1.1\" name=\"UML\" />");
        out.println("  <XMI.model href=\"/vol/acfiles7/egonw/SourceForge/CDK/cdk/reports/javadoc/test2.xmi\" version=\"1\" name=\"/vol/acfiles7/egonw/SourceForge/CDK/cdk/reports/javadoc/test2.xmi\" />");
        out.println(" </XMI.header>");

        out.println(" <XMI.content>");
        out.println("  <docsettings viewid=\"-1\" documentation=\"\" uniqueid=\"1\" />");
        out.println("  <umlobjects>");
        generateUMLClass(root.specifiedPackages());
        out.println("  </umlobjects>");
        out.println("  <diagrams/>");
        out.println("  <listview>");
        out.println("   <listitem open=\"1\" type=\"800\" id=\"-1\" label=\"Views\" >");
        generateLogicalView(root.specifiedPackages());
        out.println("    <listitem open=\"1\" type=\"802\" id=\"-1\" label=\"Use Case View\" />");
        out.println("   </listitem>");
        out.println("  </listview>");
        out.println(" </XMI.content>");
        out.println("</XMI>");
    }
757991
@Override
    public void process(Exchange exchange) throws Exception {
        if (log.isTraceEnabled()) {
            log.trace(exchange.toString());
        }

        if (pin.isOpen()) {

            KuraGPIOAction messageAction = exchange.getIn().getHeader(KuraGPIOConstants.CAMEL_KURA_GPIO_ACTION,
                    getAction(), KuraGPIOAction.class);

            if (messageAction == null) {
                log.trace("No action pick up body");
                output(exchange);
            } else {
                log.trace("action= {} ", action);
                switch (messageAction) {

                case TOGGLE:
                    pin.setValue(!pin.getValue());
                    break;

                case LOW:
                    pin.setValue(false);
                    break;

                case HIGH:
                    pin.setValue(true);
                    break;

                case BLINK:

                    pool.submit(new Runnable() {

                        @Override
                        public void run() {
                            try {
                                Thread.sleep(getEndpoint().getDelay());
                                pin.setValue(!pin.getValue());
                                Thread.sleep(getEndpoint().getDuration());
                                pin.setValue(!pin.getValue());
                            } catch (Exception e) {
                                log.error("Thread interruption into BLINK sequence", e);
                            }
                        }
                    });

                    break;

                default:
                    log.error("Any action set found");
                    break;
                }
            }
        } else {
            log.warn("Pin {} is close", pin.getIndex());
        }
    }
859318
public MessageIDEnvelope sendActions(Actions data) throws ApiException {
        ApiResponse<MessageIDEnvelope> resp = sendActionsWithHttpInfo(data);
        return resp.getData();
    }
492586
protected function doProcess(Exchange $mainExchange, SerializableArray $processingContext)
    {
        foreach ($this->itineraries as $itinerary) {
            $exchange = new Exchange();

            // Set headers
            if (!empty($mainExchange->getHeaders())) {
                $exchange->setHeaders($mainExchange->getHeaders());
            }

            $exchange->setHeader(Exchange::HEADER_HANDLER, $mainExchange->getHeader(Exchange::HEADER_HANDLER));
            $exchange->setHeader(Exchange::HEADER_PARENT_EXCHANGE, $mainExchange->getId());
            $exchange->setHeader(Exchange::HEADER_FROM, $mainExchange->getHeader(Exchange::HEADER_FROM));

            // Set Itinerary
            $exchange->getItinerary()->prepend($itinerary);
            $exchange->getItinerary()->setName('Multicast from "'.$mainExchange->getItinerary()->getName().'"');

            // Set Message
            $msgCopy = unserialize(serialize($mainExchange->getIn()));
            $exchange->setIn($msgCopy);

            $event = new NewExchangeEvent($exchange);
            $event->setTimestampToCurrent();
            $this->eventDispatcher->dispatch(NewExchangeEvent::TYPE_NEW_EXCHANGE_EVENT, $event);
        }
    }
1079058
@Override
    public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {

        nameValidator.validate(operation);
        final String attributeName = operation.require(NAME).asString();

        final ModelNode submodel = context.readResource(PathAddress.EMPTY_ADDRESS).getModel();
        final ModelNode currentValue = submodel.get(attributeName).clone();

        context.getResult().set(currentValue);
    }
723675
@Override
  public Answer processRequest(Request request) {
    dumpMessage(request,false);
    if (request.getCommandCode() != commandCode) {
      log.error("Received bad answer: " + request.getCommandCode());
      return null;
    }
    AvpSet requestAvpSet = request.getAvps();

    Avp exchangeTypeAvp = requestAvpSet.getAvp(exchangeTypeCode, vendorID);
    Avp exchangeDataAvp = requestAvpSet.getAvp(exchangeDataCode, vendorID);
    if (exchangeTypeAvp == null) {
      log.error("Request does not have Exchange-Type");

      Answer answer = createAnswer(request, 5004, EXCHANGE_TYPE_TERMINATING);
      dumpMessage(answer,true);
      return answer; // set
                                      // exchange
                                      // type
                                      // to
                                      // terminating
    }
    if (exchangeDataAvp == null) {
      log.error("Request does not have Exchange-Data");
      Answer answer = createAnswer(request, 5004, EXCHANGE_TYPE_TERMINATING);
      dumpMessage(answer,true);
      return answer; // set
                                      // exchange
                                      // type
                                      // to
                                      // terminating
    }
    // cast back to int(Enumerated is Unsigned32, and API represents it as
    // long so its easier
    // to manipulate
    try {
      switch ((int) exchangeTypeAvp.getUnsigned32()) {
      case EXCHANGE_TYPE_INITIAL:
        // JIC check;
        String data = exchangeDataAvp.getUTF8String();
        this.session = this.factory.getNewSession(request.getSessionId());
        if (data.equals(TO_RECEIVE[toReceiveIndex])) {
          // create session;

          Answer answer = createAnswer(request, 2001, EXCHANGE_TYPE_INITIAL); // set
                                                // exchange
                                                // type
                                                // to
                                                // terminating
          toReceiveIndex++;
          dumpMessage(answer,true);
          return answer;
        } else {
          log.error("Received wrong Exchange-Data: " + data);
          Answer answer = request.createAnswer(6000);
        }
        break;
      case EXCHANGE_TYPE_INTERMEDIATE:
        // JIC check;
        data = exchangeDataAvp.getUTF8String();
        if (data.equals(TO_RECEIVE[toReceiveIndex])) {

          Answer answer = createAnswer(request, 2001, EXCHANGE_TYPE_INTERMEDIATE); // set
                                                // exchange
                                                // type
                                                // to
                                                // terminating
          toReceiveIndex++;
          dumpMessage(answer,true);
          return answer;
        } else {
          log.error("Received wrong Exchange-Data: " + data);
        }
        break;
      case EXCHANGE_TYPE_TERMINATING:
        data = exchangeDataAvp.getUTF8String();
        if (data.equals(TO_RECEIVE[toReceiveIndex])) {
          // good, we reached end of FSM.
          finished = true;
          // release session and its resources.
          Answer answer = createAnswer(request, 2001, EXCHANGE_TYPE_TERMINATING); // set
                                              // exchange
                                              // type
                                              // to
                                              // terminating
          toReceiveIndex++;
          this.session.release();
          finished = true;
          this.session = null;
          dumpMessage(answer,true);
          return answer;

        } else {
          log.error("Received wrong Exchange-Data: " + data);
        }
        break;
      default:
        log.error("Bad value of Exchange-Type avp: " + exchangeTypeAvp.getUnsigned32());
        break;
      }
    } catch (AvpDataException e) {
      // thrown when interpretation of byte[] fails
      e.printStackTrace();
    } catch (InternalException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    //error, something bad happened.
    finished = true;
    return null;
  }
460583
@Override
    public void handleRequest(final HttpServerExchange exchange) throws Exception {
        if(exchange.isInIoThread()) {
            exchange.dispatch(this);
            return;
        }
        SecurityContext context = exchange.getSecurityContext();
        if (context.authenticate()) {
            if(!exchange.isComplete()) {
               next.handleRequest(exchange);
            }
        } else {
            if(exchange.getStatusCode() >= StatusCodes.BAD_REQUEST && !exchange.isComplete()) {
                ServletRequestContext src = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY);
                src.getOriginalResponse().sendError(exchange.getStatusCode());
            } else {
                exchange.endExchange();
            }
        }
    }
42965
@Override
    public RequestCtx handleRequest(HttpServletRequest request,
                                    HttpServletResponse response)
    throws IOException, ServletException {

        RequestCtx req = null;

        String action = request.getParameter("action");

        if (action == null) {
            throw new ServletException("Invalid request, action parameter must be specified.");
        }


        Map<URI, AttributeValue> actions = new HashMap<URI, AttributeValue>();
        Map<URI, AttributeValue> resAttr;

        try {

            resAttr = ResourceAttributes.getRepositoryResources();

            // note - no API specified in legacy XACML, so none specified here
            /*
            actions.put(Constants.ACTION.API.getURI(),
                        Constants.ACTION.APIA.getStringAttribute()));
            */

            if (action.equals("status")) {
                actions.put(Constants.ACTION.ID.getURI(),
                            Constants.ACTION.SERVER_STATUS.getStringAttribute());
            } else if (action.equals("reloadPolicies")) {
                actions.put(Constants.ACTION.ID.getURI(),
                            Constants.ACTION.RELOAD_POLICIES.getStringAttribute());
            } else if (action.equals("modifyDatastreamControlGroup")) {
                // FCREPO-765, no specific URI defined for this operation
                actions.put(Constants.ACTION.ID.getURI(),
                            Constants.ACTION.RELOAD_POLICIES.getStringAttribute());
            } else {
                throw new ServletException("Invalid request, invalid action parameter specified:" + action);
            }


            req =
                getContextHandler().buildRequest(getSubjects(request),
                                                 actions,
                                                 resAttr,
                                                 getEnvironment(request));

            LogUtil.statLog(request.getRemoteUser(),
                            Constants.ACTION.LIST_METHODS.uri,
                            Constants.FEDORA_REPOSITORY_PID.uri,
                            null);
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            throw new ServletException(e);
        }

        return req;
    }
809691
protected <T, A> AsyncFuture<T> executeRequest(final ManagementRequest<T, A> request, final Channel channel, final ActiveOperation<T, A> support) {
        assert support != null;
        updateChannelRef(support, channel);
        final Integer requestId = this.requestID.incrementAndGet();
        final ActiveRequest<T, A> ar = new ActiveRequest<T, A>(support, request);
        requests.put(requestId, ar);
        final ManagementRequestHeader header = new ManagementRequestHeader(ManagementProtocol.VERSION, requestId, support.getOperationId(), request.getOperationType());
        final ActiveOperation.ResultHandler<T> resultHandler = support.getResultHandler();
        try {
            request.sendRequest(resultHandler, new ManagementRequestContextImpl<T, A>(support, channel, header, getExecutor()));
        } catch (Exception e) {
            resultHandler.failed(e);
            requests.remove(requestId);
        }
        return support.getResult();
    }