Search in sources :

Example 6 with AxisConfiguration

use of org.apache.axis2.engine.AxisConfiguration in project jaggery by wso2.

the class JaggeryAppAdmin method uploadWebapp.

/**
     * Upload a webapp
     *
     * @param webappUploadDataList Array of data representing the webapps that are to be uploaded
     * @return true - if upload was successful
     * @throws org.apache.axis2.AxisFault If an error occurrs while uploading
     */
@SuppressFBWarnings({ "PATH_TRAVERSAL_IN", "PATH_TRAVERSAL_IN" })
public boolean uploadWebapp(WebappUploadData[] webappUploadDataList) throws AxisFault {
    AxisConfiguration axisConfig = getAxisConfig();
    String repoPath = axisConfig.getRepository().getPath();
    String jaggeryAppsPath = getWebappDeploymentDirPath();
    for (WebappUploadData uploadData : webappUploadDataList) {
        String fName = uploadData.getFileName();
        if (fName.contains(".")) {
            fName = fName.split("\\.")[0];
        }
        File webappsDir = new File(jaggeryAppsPath + File.separator + fName);
        File jaggeryAppsFile = new File(jaggeryAppsPath);
        if (webappsDir.exists()) {
            String msg = "Jaggery app with the same name already exists";
            log.error(msg);
            throw new AxisFault(msg);
        } else if (!jaggeryAppsFile.exists()) {
            //if deployment directory is not there we create it
            if (!jaggeryAppsFile.mkdir()) {
                String error = "Jaggery deployment directory not found and cannot be created when uploading";
                log.error(error);
                throw new AxisFault(error);
            }
        }
        ArchiveManipulator archiveManipulator = new ArchiveManipulator();
        try {
            archiveManipulator.extractFromStream(uploadData.getDataHandler().getInputStream(), jaggeryAppsPath + File.separator + fName);
        } catch (IOException e) {
            log.error("Could not unzip the Jaggery App Archive", e);
            throw new AxisFault(e.getMessage(), e);
        }
    }
    return true;
}
Also used : AxisFault(org.apache.axis2.AxisFault) AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) ArchiveManipulator(org.wso2.carbon.utils.ArchiveManipulator) WebappUploadData(org.wso2.carbon.webapp.mgt.WebappUploadData) IOException(java.io.IOException) File(java.io.File) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 7 with AxisConfiguration

use of org.apache.axis2.engine.AxisConfiguration in project MassBank-web by MassBank.

the class AdminActions method processdisengageModule.

@Action(name = "disengageModule", post = true)
public Redirect processdisengageModule(HttpServletRequest req) throws AxisFault {
    String type = req.getParameter("type");
    String serviceName = req.getParameter("serviceName");
    String moduleName = req.getParameter("module");
    AxisConfiguration axisConfiguration = configContext.getAxisConfiguration();
    AxisService service = axisConfiguration.getService(serviceName);
    AxisModule module = axisConfiguration.getModule(moduleName);
    if (type.equals("operation")) {
        if (service.isEngaged(module.getName()) || axisConfiguration.isEngaged(module.getName())) {
            return new Redirect(LIST_SERVICES).withStatus(false, "Can not disengage module " + moduleName + ". This module is engaged at a higher level.");
        } else {
            String opName = req.getParameter("operation");
            AxisOperation op = service.getOperation(new QName(opName));
            op.disengageModule(module);
            return new Redirect(LIST_SERVICES).withStatus(true, "Module " + moduleName + " was disengaged from " + "operation " + opName + " in service " + serviceName + ".");
        }
    } else {
        if (axisConfiguration.isEngaged(module.getName())) {
            return new Redirect(LIST_SERVICES).withStatus(false, "Can not disengage module " + moduleName + ". " + "This module is engaged at a higher level.");
        } else {
            service.disengageModule(axisConfiguration.getModule(moduleName));
            return new Redirect(LIST_SERVICES).withStatus(true, "Module " + moduleName + " was disengaged from" + " service " + serviceName + ".");
        }
    }
}
Also used : AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) AxisOperation(org.apache.axis2.description.AxisOperation) QName(javax.xml.namespace.QName) AxisService(org.apache.axis2.description.AxisService) AxisModule(org.apache.axis2.description.AxisModule)

Example 8 with AxisConfiguration

use of org.apache.axis2.engine.AxisConfiguration in project MassBank-web by MassBank.

the class AdminActions method deleteService.

@Action(name = "deleteService", post = true)
public Redirect deleteService(HttpServletRequest req) throws AxisFault {
    String serviceName = req.getParameter("serviceName");
    AxisConfiguration axisConfiguration = configContext.getAxisConfiguration();
    if (axisConfiguration.getService(serviceName) != null) {
        axisConfiguration.removeService(serviceName);
        return new Redirect(LIST_SERVICES).withStatus(true, "Service '" + serviceName + "' has been successfully removed.");
    } else {
        return new Redirect(LIST_SERVICES).withStatus(false, "Failed to delete service '" + serviceName + "'. Service doesn't exist.");
    }
}
Also used : AxisConfiguration(org.apache.axis2.engine.AxisConfiguration)

Example 9 with AxisConfiguration

use of org.apache.axis2.engine.AxisConfiguration in project wso2-axis2-transports by wso2.

the class JMSSenderTestCase method testTransactionCommandParameter.

/**
 * Test case for EI-1244.
 * test transport.jms.TransactionCommand parameter in transport url when sending the message.
 * This will verify the fixes which prevent possible OOM issue when publishing messages to a broker using jms.
 *
 * @throws Exception
 */
public void testTransactionCommandParameter() throws Exception {
    JMSSender jmsSender = PowerMockito.spy(new JMSSender());
    JMSOutTransportInfo jmsOutTransportInfo = Mockito.mock(JMSOutTransportInfo.class);
    JMSMessageSender jmsMessageSender = Mockito.mock(JMSMessageSender.class);
    Session session = Mockito.mock(Session.class);
    Mockito.doReturn(session).when(jmsMessageSender).getSession();
    PowerMockito.whenNew(JMSOutTransportInfo.class).withArguments(any(String.class)).thenReturn(jmsOutTransportInfo);
    Mockito.doReturn(jmsMessageSender).when(jmsOutTransportInfo).createJMSSender(any(MessageContext.class));
    PowerMockito.doNothing().when(jmsSender, "sendOverJMS", ArgumentMatchers.any(), ArgumentMatchers.any(), ArgumentMatchers.any(), ArgumentMatchers.any(), ArgumentMatchers.any());
    jmsSender.init(new ConfigurationContext(new AxisConfiguration()), new TransportOutDescription("jms"));
    MessageContext messageContext = new MessageContext();
    // append the transport.jms.TransactionCommand
    String targetAddress = "jms:/SimpleStockQuoteService?transport.jms.ConnectionFactoryJNDIName=" + "QueueConnectionFactory&transport.jms.TransactionCommand=begin" + "&java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory";
    Transaction transaction = new TestJMSTransaction();
    messageContext.setProperty(JMSConstants.JMS_XA_TRANSACTION, transaction);
    jmsSender.sendMessage(messageContext, targetAddress, null);
    Map<Transaction, ArrayList<JMSMessageSender>> jmsMessageSenderMap = Whitebox.getInternalState(JMSSender.class, "jmsMessageSenderMap");
    Assert.assertEquals("Transaction not added to map", 1, jmsMessageSenderMap.size());
    List senderList = jmsMessageSenderMap.get(transaction);
    Assert.assertNotNull("List is null", senderList);
    Assert.assertEquals("List is empty", 1, senderList.size());
}
Also used : ConfigurationContext(org.apache.axis2.context.ConfigurationContext) AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) ArrayList(java.util.ArrayList) Transaction(javax.transaction.Transaction) ArrayList(java.util.ArrayList) List(java.util.List) MessageContext(org.apache.axis2.context.MessageContext) Session(javax.jms.Session) TransportOutDescription(org.apache.axis2.description.TransportOutDescription)

Example 10 with AxisConfiguration

use of org.apache.axis2.engine.AxisConfiguration in project wso2-axis2-transports by wso2.

the class DefaultSMSMessageBuilderImpl method buildMessaage.

public MessageContext buildMessaage(SMSMessage msg, ConfigurationContext configurationContext) throws InvalidMessageFormatException {
    String message = msg.getContent();
    String sender = msg.getSender();
    String receiver = msg.getReceiver();
    String[] parts = message.split(":");
    // may be can add feature to send message format for a request like ????
    if (parts.length < 2) {
        throw new InvalidMessageFormatException("format must be  \"service_name \" : \"opration_name\" : " + "\"parm_1=val_1\" :..:\"param_n = val_n\"");
    } else {
        AxisConfiguration repo = configurationContext.getAxisConfiguration();
        MessageContext messageContext = configurationContext.createMessageContext();
        parts = trimSplited(parts);
        try {
            AxisService axisService = repo.getService(parts[0]);
            if (axisService == null) {
                throw new InvalidMessageFormatException("Service : " + parts[0] + "does not exsist");
            } else {
                messageContext.setAxisService(axisService);
                AxisOperation axisOperation = axisService.getOperation(new QName(parts[1]));
                if (axisOperation == null) {
                    throw new InvalidMessageFormatException("Operation: " + parts[1] + " does not exsist");
                }
                messageContext.setAxisOperation(axisOperation);
                messageContext.setAxisMessage(axisOperation.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE));
                Map params = getParams(parts, 2);
                SOAPEnvelope soapEnvelope = createSoapEnvelope(messageContext, params);
                messageContext.setServerSide(true);
                messageContext.setEnvelope(soapEnvelope);
                TransportInDescription in = configurationContext.getAxisConfiguration().getTransportIn("sms");
                TransportOutDescription out = configurationContext.getAxisConfiguration().getTransportOut("sms");
                messageContext.setIncomingTransportName("sms");
                messageContext.setProperty(SMSTransportConstents.SEND_TO, sender);
                messageContext.setProperty(SMSTransportConstents.DESTINATION, receiver);
                messageContext.setTransportIn(in);
                messageContext.setTransportOut(out);
                handleSMSProperties(msg, messageContext);
                return messageContext;
            }
        } catch (AxisFault axisFault) {
            log.debug("[DefaultSMSMessageBuilderImpl] Error while extracting the axis2Service \n" + axisFault);
        }
    }
    return null;
}
Also used : AxisFault(org.apache.axis2.AxisFault) AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) QName(javax.xml.namespace.QName) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope) MessageContext(org.apache.axis2.context.MessageContext) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)10 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)5 TransportOutDescription (org.apache.axis2.description.TransportOutDescription)4 QName (javax.xml.namespace.QName)2 AxisFault (org.apache.axis2.AxisFault)2 MessageContext (org.apache.axis2.context.MessageContext)2 AxisService (org.apache.axis2.description.AxisService)2 TransportInDescription (org.apache.axis2.description.TransportInDescription)2 CustomAxisConfigurator (org.apache.axis2.transport.CustomAxisConfigurator)2 Setup (org.apache.axis2.transport.testkit.tests.Setup)2 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 File (java.io.File)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Session (javax.jms.Session)1 Transaction (javax.transaction.Transaction)1