use of org.apache.axis2.addressing.metadata.ServiceName in project carbon-data by wso2.
the class DBDeployer method undeploy.
/**
* Undeploys a service.
*/
public void undeploy(String servicePath) throws DeploymentException {
try {
DataService dataService = this.getDataServiceByServicePath(servicePath);
if (dataService == null) {
/* must be a faulty service */
/* the faulty service should be removed at this point from the axis configuration.
otherwise the service would still be shown as a faulty service in the management
console UI since it queries and lists out the faulty services from the
axisConfiguration itself.
*/
this.axisConfig.removeFaultyService(servicePath);
return;
}
String serviceHierarchy = Utils.getServiceHierarchy(servicePath, this.repoDir);
if (serviceHierarchy == null) {
serviceHierarchy = "";
}
String serviceName = serviceHierarchy + dataService.getName();
/* In the context of dataservices one service group will only contain one dataservice.
* Hence assigning the service group as the service group name */
AxisServiceGroup serviceGroup = this.axisConfig.getServiceGroup(serviceName);
CarbonContext cCtx = CarbonContext.getThreadLocalCarbonContext();
if (serviceGroup == null) {
/* must be a faulty service */
this.axisConfig.removeFaultyService(servicePath);
for (String configID : dataService.getConfigs().keySet()) {
if (dataService.getConfig(configID).isODataEnabled()) {
removeODataHandler(cCtx.getTenantDomain(), dataService.getName() + configID);
}
}
} else {
/* cleanup data service */
for (String configID : dataService.getConfigs().keySet()) {
if (dataService.getConfig(configID).isODataEnabled()) {
removeODataHandler(cCtx.getTenantDomain(), dataService.getName() + configID);
}
}
dataService.cleanup();
this.axisConfig.removeService(serviceName);
/* if the service group is now empty, remove it as well */
if (!serviceGroup.getServices().hasNext()) {
/* when the service group is removed re-deployment causes problems */
this.axisConfig.removeServiceGroup(serviceGroup.getServiceGroupName());
}
}
if (log.isDebugEnabled()) {
log.debug(Messages.getMessage(DeploymentErrorMsgs.SERVICE_REMOVED, serviceName));
}
super.undeploy(servicePath);
} catch (Exception e) {
String msg = "Error in undeploying service";
log.error(msg, e);
throw new DeploymentException(msg, e);
}
}
use of org.apache.axis2.addressing.metadata.ServiceName in project carbon-data by wso2.
the class DataServiceAdmin method saveDataService.
/**
* Saves the data service in service repository.
* @param serviceName The name of the data service to be saved
* @param serviceHierarchy The hierarchical path of the service
* @param serviceContents The content of the service
* @throws AxisFault
*/
public void saveDataService(String serviceName, String serviceHierarchy, String serviceContents) throws AxisFault {
String dataServiceFilePath;
ConfigurationContext configCtx = this.getConfigContext();
AxisConfiguration axisConfig = configCtx.getAxisConfiguration();
AxisService axisService = DBUtils.getActiveAxisServiceAccordingToDataServiceGroup(axisConfig, serviceName);
// existing functionality
if (serviceName.contains("/")) {
String[] splitArray = serviceName.split("\\/");
if (splitArray.length >= 1) {
String fullServiceName = serviceName;
serviceName = splitArray[splitArray.length - 1];
serviceHierarchy = splitArray[splitArray.length - 2];
serviceContents = serviceContents.replace(fullServiceName, serviceName);
}
}
if (serviceHierarchy == null) {
serviceHierarchy = "";
}
if (axisService == null) {
/* new service */
String axis2RepoDirectory = axisConfig.getRepository().getPath();
String repoDirectory = (String) configCtx.getProperty(DBConstants.DB_SERVICE_REPO);
String fileExtension = this.getDataServiceFileExtension();
String dataServiceDirectory = axis2RepoDirectory + File.separator + repoDirectory + File.separator + serviceHierarchy;
dataServiceFilePath = dataServiceDirectory + File.separator + serviceName + "." + fileExtension;
/* create the directory, if it does not exist */
/*
Security Comment :
This dataServiceDirectory path is trustworthy, constructed dataServiceDirectory path cannot be access by the user.
*/
File directory = new File(dataServiceDirectory);
if (!directory.exists() && !directory.mkdirs()) {
throw new AxisFault("Cannot create directory: " + directory.getAbsolutePath());
}
} else {
dataServiceFilePath = ((DataService) axisService.getParameter(DBConstants.DATA_SERVICE_OBJECT).getValue()).getDsLocation();
AxisServiceGroup axisServiceGroup = axisService.getAxisServiceGroup();
axisServiceGroup.addParameter(CarbonConstants.KEEP_SERVICE_HISTORY_PARAM, Boolean.TRUE.toString());
axisServiceGroup.addParameter(CarbonConstants.PRESERVE_SERVICE_HISTORY_PARAM, Boolean.TRUE.toString());
axisService.addParameter(CarbonConstants.KEEP_SERVICE_HISTORY_PARAM, Boolean.TRUE.toString());
axisService.addParameter(CarbonConstants.PRESERVE_SERVICE_HISTORY_PARAM, Boolean.TRUE.toString());
}
serviceContents = DBUtils.prettifyXML(serviceContents);
/* save contents to .dbs file */
try {
/*
Security Comment :
This path is trustworthy, constructed file path cannot be access by the user.
*/
BufferedWriter out = new BufferedWriter(new FileWriter(dataServiceFilePath));
out.write(serviceContents);
out.close();
} catch (IOException e) {
log.error("Error while saving " + serviceName, e);
throw new AxisFault("Error occurred while writing the contents for the service config file for the new service " + serviceName, e);
}
}
use of org.apache.axis2.addressing.metadata.ServiceName in project carbon-data by wso2.
the class DSTask method checkServiceInit.
private boolean checkServiceInit() {
if (this.isServiceInit()) {
return true;
}
String serviceName = this.getProperties().get(DSTaskConstants.DATA_SERVICE_NAME);
String opName = this.getProperties().get(DSTaskConstants.DATA_SERVICE_OPERATION_NAME);
String tidProp = this.getProperties().get(TaskInfo.TENANT_ID_PROP);
if (tidProp == null) {
throw new RuntimeException("Cannot determine the tenant domain for the scheduled service: " + serviceName);
}
int tid = Integer.parseInt(tidProp);
AxisService axisService = DSTaskUtils.lookupAxisService(tid, serviceName);
if (axisService == null) {
return false;
}
if (axisService == null || !axisService.isActive()) {
return false;
}
String httpEPR = DSTaskUtils.extractHTTPEPR(axisService);
if (httpEPR == null) {
throw new RuntimeException("No HTTP endpoint found for service: " + serviceName + " for scheduling service calls");
}
this.getProperties().put(WebServiceCallTask.SERVICE_TARGET_EPR, httpEPR);
String mep;
if (DSTaskUtils.isInOutMEPInOperation(axisService, opName)) {
mep = WebServiceCallTask.SERVICE_MEP_IN_OUT;
} else {
mep = WebServiceCallTask.SERVICE_MEP_IN_ONLY;
}
this.getProperties().put(WebServiceCallTask.SERVICE_MEP, mep);
this.serviceInit = true;
super.init();
return this.isServiceInit();
}
use of org.apache.axis2.addressing.metadata.ServiceName in project carbon-data by wso2.
the class DataTaskContext method getDataService.
private DataService getDataService(String serviceName) {
AxisService axisService = DSTaskUtils.lookupAxisService(this.axisConfig, serviceName);
if (axisService == null) {
return null;
}
DataService dataService = (DataService) axisService.getParameterValue(DBConstants.DATA_SERVICE_OBJECT);
return dataService;
}
use of org.apache.axis2.addressing.metadata.ServiceName in project axis-axis2-java-core by apache.
the class AxisServiceBasedMultiLanguageEmitter method loadOperations.
/**
* Loads the operations
*
* @param doc
* @param rootElement
* @param mep
* @return boolean
*/
protected boolean loadOperations(Document doc, Element rootElement, String mep) {
Element methodElement;
String serviceName = makeJavaClassName(axisService.getName());
Iterator bindingOperations = this.axisBinding.getChildren();
boolean opsFound = false;
AxisBindingOperation axisBindingOperation = null;
AxisOperation axisOperation = null;
while (bindingOperations.hasNext()) {
axisBindingOperation = (AxisBindingOperation) bindingOperations.next();
axisOperation = axisBindingOperation.getAxisOperation();
// populate info holder with mep information. This will used in determining which
// message receiver to use, etc.,
String messageExchangePattern = axisOperation.getMessageExchangePattern();
if (infoHolder.get(messageExchangePattern) == null) {
infoHolder.put(messageExchangePattern, Boolean.TRUE);
}
if (mep == null) {
opsFound = true;
methodElement = generateMethodElement(doc, serviceName, axisBindingOperation);
rootElement.appendChild(methodElement);
} else {
if (mep.equals(axisOperation.getMessageExchangePattern())) {
// at this point we know it's true
opsFound = true;
methodElement = generateMethodElement(doc, serviceName, axisBindingOperation);
rootElement.appendChild(methodElement);
// ////////////////////
}
}
}
return opsFound;
}
Aggregations