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;
}
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 + ".");
}
}
}
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.");
}
}
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());
}
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;
}
Aggregations