use of org.apache.axis2.databinding.types.URI in project wso2-synapse by wso2.
the class EndpointDeployerTest method testUpdate.
/**
* Test updating an endpoint
*
* @throws Exception
*/
@Test
public void testUpdate() throws Exception {
String inputXML = "<endpoint name = \"sampleEP\" xmlns=\"http://ws.apache.org/ns/synapse\">" + "<address uri=\"http://localhost:9000/services/SimpleStockQuoteService\" >" + "</address>" + "</endpoint>";
OMElement inputElement = AXIOMUtil.stringToOM(inputXML);
EndpointDeployer endpointDeployer = new EndpointDeployer();
SynapseConfiguration synapseConfiguration = new SynapseConfiguration();
AxisConfiguration axisConfiguration = synapseConfiguration.getAxisConfiguration();
ConfigurationContext cfgCtx = new ConfigurationContext(axisConfiguration);
SynapseEnvironment synapseEnvironment = new Axis2SynapseEnvironment(cfgCtx, synapseConfiguration);
axisConfiguration.addParameter(new Parameter(SynapseConstants.SYNAPSE_ENV, synapseEnvironment));
axisConfiguration.addParameter(new Parameter(SynapseConstants.SYNAPSE_CONFIG, synapseConfiguration));
cfgCtx.setAxisConfiguration(axisConfiguration);
endpointDeployer.init(cfgCtx);
endpointDeployer.deploySynapseArtifact(inputElement, "sampleFile", null);
String inputUpdateXML = "<endpoint name = \"sampleUpdatedEP\" xmlns=\"http://ws.apache.org/ns/synapse\">" + "<address uri=\"http://localhost:9000/services/SimpleStockQuoteService\" >" + "</address>" + "</endpoint>";
OMElement updatedElement = AXIOMUtil.stringToOM(inputUpdateXML);
String response = endpointDeployer.updateSynapseArtifact(updatedElement, "sampleUpdateFile", "sampleEP", null);
Assert.assertEquals("Endpoint not updated!", "sampleUpdatedEP", response);
}
use of org.apache.axis2.databinding.types.URI in project wso2-synapse by wso2.
the class TemplateDeployerTest method testUndeploy.
/**
* Test undeploying an endpoint
*
* @throws Exception
*/
@Test
public void testUndeploy() throws Exception {
String inputXML = "<template name = \"TestTemplate\" xmlns=\"http://ws.apache.org/ns/synapse\">" + " <endpoint name = \"sampleEP\" >" + " <address uri=\"http://localhost:9000/services/SimpleStockQuoteService\" >" + "</address>" + " </endpoint>" + " </template>";
OMElement inputElement = AXIOMUtil.stringToOM(inputXML);
TemplateDeployer templateDeployer = new TemplateDeployer();
SynapseConfiguration synapseConfiguration = new SynapseConfiguration();
AxisConfiguration axisConfiguration = synapseConfiguration.getAxisConfiguration();
ConfigurationContext cfgCtx = new ConfigurationContext(axisConfiguration);
SynapseEnvironment synapseEnvironment = new Axis2SynapseEnvironment(cfgCtx, synapseConfiguration);
axisConfiguration.addParameter(new Parameter(SynapseConstants.SYNAPSE_ENV, synapseEnvironment));
axisConfiguration.addParameter(new Parameter(SynapseConstants.SYNAPSE_CONFIG, synapseConfiguration));
cfgCtx.setAxisConfiguration(axisConfiguration);
templateDeployer.init(cfgCtx);
templateDeployer.deploySynapseArtifact(inputElement, "sampleFile", null);
Assert.assertNotNull("Endpoint template not deployed!", synapseConfiguration.getEndpointTemplate("TestTemplate"));
templateDeployer.undeploySynapseArtifact("TestTemplate");
Assert.assertNull("Endpoint template cannot be undeployed", synapseConfiguration.getEndpointTemplate("TestTemplate"));
}
use of org.apache.axis2.databinding.types.URI in project carbon-business-process by wso2.
the class TransformerUtil method convertAttachment.
/**
* Transform {@link Attachment} to (DTO) {@link TAttachment}
*
* @param attachment
* @return
*/
public static TAttachment convertAttachment(Attachment attachment) throws AttachmentMgtException {
TAttachment attachmentDTO = new TAttachment();
attachmentDTO.setId(attachment.getId());
attachmentDTO.setName(attachment.getName());
attachmentDTO.setCreatedBy(attachment.getCreatedBy());
Calendar cal = Calendar.getInstance();
cal.setTime(attachment.getCreatedTime());
attachmentDTO.setCreatedTime(cal);
attachmentDTO.setContentType(attachment.getContentType());
attachmentDTO.setContent(attachment.getContent());
try {
URI attachmentURI = new URI(attachment.getURL().toString());
attachmentDTO.setUrl(attachmentURI);
} catch (URI.MalformedURIException e) {
log.error(e.getLocalizedMessage(), e);
throw new AttachmentMgtException("Conversion of Attachment to TAttachment (DTO) failed due to reason : " + e.getLocalizedMessage(), e);
}
return attachmentDTO;
}
use of org.apache.axis2.databinding.types.URI in project carbon-business-process by wso2.
the class URLGeneratorUtil method getPermanentLink.
/**
* Generate the permanent link for the given attachment uri based on current system configurations like host, port
* eg - if {@code uniqueID} is abc123, then the resultant permanent link would {@code https://127.0.0.1:9443/context/abc123}
* So this url can be used to download the attachment
*
* @param uniqueID uri for the attachment
* @return downloadable url of the attachment
* @throws AttachmentMgtException
*/
public static URL getPermanentLink(URI uniqueID) throws AttachmentMgtException {
String scheme = CarbonConstants.HTTPS_TRANSPORT;
String host;
try {
host = NetworkUtils.getLocalHostname();
} catch (SocketException e) {
log.error(e.getMessage(), e);
throw new AttachmentMgtException(e.getLocalizedMessage(), e);
}
int port = 9443;
try {
ConfigurationContext serverConfigContext = AttachmentServerHolder.getInstance().getConfigurationContextService().getServerConfigContext();
port = CarbonUtils.getTransportProxyPort(serverConfigContext, scheme);
if (port == -1) {
port = CarbonUtils.getTransportPort(serverConfigContext, scheme);
}
} catch (Exception ex) {
log.warn("Using default port settings");
}
String webContext = ServerConfiguration.getInstance().getFirstProperty("WebContextRoot");
if (webContext == null || webContext.equals("/")) {
webContext = "";
}
String tenantDomain = String.valueOf(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
try {
tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain();
} catch (Throwable e) {
tenantDomain = null;
}
String url = null;
try {
String link = scheme + "://" + host + ":" + port + webContext + ((tenantDomain != null && !MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) ? "/" + MultitenantConstants.TENANT_AWARE_URL_PREFIX + "/" + tenantDomain : "") + AttachmentMgtConfigurationConstants.ATTACHMENT_DOWNLOAD_SERVELET_URL_PATTERN + "/" + uniqueID.toString();
return new URL(link);
} catch (MalformedURLException e) {
log.error(e.getMessage(), e);
throw new AttachmentMgtException(e.getLocalizedMessage(), e);
}
}
use of org.apache.axis2.databinding.types.URI in project carbon-business-process by wso2.
the class AxisServiceUtils method populateAxisService.
private static AxisService populateAxisService(BPELProcessProxy processProxy, AxisConfiguration axisConfiguration, WSDL11ToAxisServiceBuilder serviceBuilder) throws AxisFault {
ProcessConf pConf = processProxy.getProcessConfiguration();
AxisService axisService = serviceBuilder.populateService();
axisService.setParent(axisConfiguration);
axisService.setWsdlFound(true);
axisService.setCustomWsdl(true);
axisService.setClassLoader(axisConfiguration.getServiceClassLoader());
URL wsdlUrl = null;
for (File file : pConf.getFiles()) {
if (file.getAbsolutePath().indexOf(processProxy.getWsdlDefinition().getDocumentBaseURI()) > 0) {
try {
wsdlUrl = file.toURI().toURL();
} catch (MalformedURLException e) {
String errorMessage = "Cannot convert File URI to URL.";
handleException(pConf.getProcessId(), errorMessage, e);
}
}
}
if (wsdlUrl != null) {
axisService.setFileName(wsdlUrl);
}
Utils.setEndpointsToAllUsedBindings(axisService);
axisService.addParameter(new Parameter("useOriginalwsdl", "true"));
axisService.addParameter(new Parameter("modifyUserWSDLPortAddress", "true"));
axisService.addParameter(new Parameter("setEndpointsToAllUsedBindings", "true"));
/* Setting service type to use in service management*/
axisService.addParameter(ServerConstants.SERVICE_TYPE, "bpel");
/* Process ID as a service parameter to use with process try-it*/
axisService.addParameter(BPELConstants.PROCESS_ID, pConf.getProcessId());
/* Fix for losing of security configuration when updating BPEL package*/
axisService.addParameter(new Parameter(CarbonConstants.PRESERVE_SERVICE_HISTORY_PARAM, "true"));
return axisService;
}
Aggregations