use of org.wso2.ei.dashboard.core.rest.model.Artifacts in project carbon-business-process by wso2.
the class BPMNAppDeployer method deployArtifacts.
/**
* Check the artifact type and if it is a BPMN artifact, copy it to the BPMN deployment hot folder
*
* @param carbonApp - CarbonApplication instance to check for BPMN artifacts
* @param axisConfig - AxisConfiguration of the current tenant
*/
public void deployArtifacts(CarbonApplication carbonApp, AxisConfiguration axisConfig) throws DeploymentException {
List<Artifact.Dependency> artifacts = carbonApp.getAppConfig().getApplicationArtifact().getDependencies();
// loop through all dependencies
for (Artifact.Dependency dep : artifacts) {
Deployer deployer;
Artifact artifact = dep.getArtifact();
if (artifact == null) {
continue;
}
if (!isAccepted(artifact.getType())) {
log.warn("Can't deploy artifact : " + artifact.getName() + " of type : " + artifact.getType() + ". Required features are not installed in the system");
continue;
}
if (BPMN_TYPE.equals(artifact.getType())) {
deployer = AppDeployerUtils.getArtifactDeployer(axisConfig, BPMN_DIR, "bar");
} else {
continue;
}
List<CappFile> files = artifact.getFiles();
if (files.size() != 1) {
log.error("BPMN artifacts must have a single file to " + "be deployed. But " + files.size() + " files found.");
continue;
}
if (deployer != null) {
String fileName = artifact.getFiles().get(0).getName();
String artifactPath = artifact.getExtractedPath() + File.separator + fileName;
try {
deployer.deploy(new DeploymentFileData(new File(artifactPath), deployer));
artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_DEPLOYED);
File artifactFile = new File(artifactPath);
if (artifactFile.exists() && !artifactFile.delete()) {
log.warn("Couldn't delete App artifact file : " + artifactPath);
}
} catch (DeploymentException e) {
artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_FAILED);
throw e;
}
}
}
}
use of org.wso2.ei.dashboard.core.rest.model.Artifacts in project carbon-business-process by wso2.
the class BPELApplicationAdmin method getBPELAppData.
/**
* Gives a BPELAppMetadata object with all bpel packages deployed through the
* given app.
*
* @param appName - input app name
* @return - BPELAppMetadata object with found artifact info
* @throws Exception - error on retrieving metadata
*/
public BPELAppMetadata getBPELAppData(String appName) throws Exception {
BPELAppMetadata data = new BPELAppMetadata();
String tenantId = AppDeployerUtils.getTenantIdString(getAxisConfig());
// Check whether there is an application in the system from the given name
ArrayList<CarbonApplication> appList = BPELAppMgtServiceComponent.getAppManager().getCarbonApps(tenantId);
CarbonApplication currentApplication = null;
for (CarbonApplication application : appList) {
if (appName.equals(application.getAppNameWithVersion())) {
currentApplication = application;
break;
}
}
// If the app not found, throw an exception
if (currentApplication == null) {
String msg = "No Carbon Application found of the name : " + appName;
log.error(msg);
throw new Exception(msg);
}
// get all dependent artifacts of the cApp
List<Artifact.Dependency> deps = currentApplication.getAppConfig().getApplicationArtifact().getDependencies();
// we use the bpel backend admin service to get processes from a bpel package
BPELPackageManagementServiceSkeleton bpelAdmin = new BPELPackageManagementServiceSkeleton();
// package list to return
List<PackageMetadata> packageList = new ArrayList<PackageMetadata>();
String packageName;
String versionLessPackageName;
Artifact artifact;
for (Artifact.Dependency dep : deps) {
artifact = dep.getArtifact();
versionLessPackageName = artifact.getName() + "-" + artifact.getVersion();
packageName = versionLessPackageName + "-" + bpelAdmin.getLatestVersionInPackage(versionLessPackageName);
if (packageName == null) {
continue;
}
if (BPELAppDeployer.BPEL_TYPE.equals(artifact.getType())) {
PackageMetadata packageMetadata = new PackageMetadata();
packageMetadata.setPackageName(packageName);
// get the list of processes
List<String> processList = new ArrayList<String>();
PackageType packageType = bpelAdmin.listProcessesInPackage(packageName);
for (Version_type0 packageVersion : packageType.getVersions().getVersion()) {
if (packageVersion.getName().equals(packageName)) {
for (LimitedProcessInfoType process : packageVersion.getProcesses().getProcess()) {
processList.add(process.getPid());
}
}
}
String[] processes = new String[processList.size()];
packageMetadata.setProcessList(processList.toArray(processes));
packageList.add(packageMetadata);
}
}
// convert the List into an array
data.setPackages(packageList.toArray(new PackageMetadata[packageList.size()]));
return data;
}
use of org.wso2.ei.dashboard.core.rest.model.Artifacts in project carbon-business-process by wso2.
the class HumanTaskApplicationAdmin method getHumanTaskAppData.
/**
* Gives a HumanTaskAppMetadata object with all humantask packages deployed through the
* given app.
*
* @param appName - input app name
* @return - HumanTaskAppMetadata object with found artifact info
* @throws Exception - error on retrieving metadata
*/
public HumanTaskAppMetadata getHumanTaskAppData(String appName) throws Exception {
HumanTaskAppMetadata data = new HumanTaskAppMetadata();
String tenantId = AppDeployerUtils.getTenantIdString(getAxisConfig());
// Check whether there is an application in the system from the given name
ArrayList<CarbonApplication> appList = HumanTaskAppMgtServiceComponent.getAppManager().getCarbonApps(tenantId);
CarbonApplication currentApplication = null;
for (CarbonApplication application : appList) {
if (appName.equals(application.getAppNameWithVersion())) {
currentApplication = application;
break;
}
}
// If the app not found, throw an exception
if (currentApplication == null) {
String msg = "No Carbon Application found of the name : " + appName;
log.error(msg);
throw new Exception(msg);
}
// get all dependent artifacts of the cApp
List<Artifact.Dependency> deps = currentApplication.getAppConfig().getApplicationArtifact().getDependencies();
// we use the humantask backend admin service to get tasks from a humantask package
HumanTaskPackageManagementSkeleton humantaskAdmin = new HumanTaskPackageManagementSkeleton();
// package list to return
List<PackageMetadata> packageList = new ArrayList<PackageMetadata>();
String packageName;
for (Artifact.Dependency dep : deps) {
Artifact artifact = dep.getArtifact();
packageName = artifact.getRuntimeObjectName();
if (packageName == null) {
continue;
}
if (HumanTaskAppDeployer.HUMANTASK_TYPE.equals(artifact.getType())) {
PackageMetadata packageMetadata = new PackageMetadata();
packageMetadata.setPackageName(packageName);
// get the list of tasks
List<String> taskList = new ArrayList<String>();
Task_type0[] tasksInPackage = humantaskAdmin.listTasksInPackage(packageName);
for (Task_type0 taskInfo : tasksInPackage) {
taskList.add(taskInfo.getName());
}
String[] tasks = new String[taskList.size()];
packageMetadata.setTaskList(tasks);
packageList.add(packageMetadata);
}
}
// convert the List into an array
data.setPackages(packageList.toArray(new PackageMetadata[packageList.size()]));
return data;
}
use of org.wso2.ei.dashboard.core.rest.model.Artifacts in project carbon-business-process by wso2.
the class BPMNUploader method uploadService.
public void uploadService(UploadedFileItem[] fileItems) throws AxisFault {
// First lets filter for jar resources
ConfigurationContext configurationContext = getConfigContext();
String repo = configurationContext.getAxisConfiguration().getRepository().getPath();
if (CarbonUtils.isURL(repo)) {
throw new AxisFault("URL Repositories are not supported: " + repo);
}
// Writing the artifacts to the proper location
String bpmnDirectory = repo + File.separator + BPMNConstants.BPMN_REPO_NAME;
String bpmnTemp = CarbonUtils.getCarbonHome() + BPMNConstants.BPMN_PACKAGE_TEMP_DIRECTORY;
File bpmnTempDir = new File(bpmnTemp);
if (!bpmnTempDir.exists() && !bpmnTempDir.mkdirs()) {
throw new AxisFault("Fail to create the directory: " + bpmnTempDir.getAbsolutePath());
}
File bpmnDir = new File(bpmnDirectory);
if (!bpmnDir.exists() && !bpmnDir.mkdirs()) {
throw new AxisFault("Fail to create the directory: " + bpmnDir.getAbsolutePath());
}
for (UploadedFileItem uploadedFile : fileItems) {
String fileName = uploadedFile.getFileName();
if (fileName == null || fileName.equals("")) {
throw new AxisFault("Invalid file name. File name is not available");
}
if (uploadedFile.getFileType().equals(BPMNConstants.BPMN_PACKAGE_EXTENSION)) {
try {
writeResource(uploadedFile.getDataHandler(), bpmnTemp, fileName, bpmnDir);
} catch (IOException e) {
throw new AxisFault("IOError: Writing resource failed.", e);
}
} else {
throw new AxisFault("Invalid file type : " + uploadedFile.getFileType() + " ." + BPMNConstants.BPMN_PACKAGE_EXTENSION + " file type is expected");
}
}
}
use of org.wso2.ei.dashboard.core.rest.model.Artifacts in project carbon-business-process by wso2.
the class HumanTaskUploader method uploadHumanTask.
public void uploadHumanTask(UploadedFileItem[] fileItems) throws AxisFault {
// First lets filter for jar resources
ConfigurationContext configurationContext = getConfigContext();
String repo = configurationContext.getAxisConfiguration().getRepository().getPath();
if (CarbonUtils.isURL(repo)) {
throw new AxisFault("URL Repositories are not supported: " + repo);
}
// Writting the artifacts to the proper location
String humantaskDirectory = getHumanTaskLocation(repo);
String humantaskTemp = CarbonUtils.getCarbonHome() + File.separator + HumanTaskConstants.HUMANTASK_PACKAGE_TEMP_DIRECTORY;
File humantaskTempDir = new File(humantaskTemp);
if (!humantaskTempDir.exists() && !humantaskTempDir.mkdirs()) {
throw new AxisFault("Fail to create the directory: " + humantaskTempDir.getAbsolutePath());
}
File humantaskDir = new File(humantaskDirectory);
if (!humantaskDir.exists() && !humantaskDir.mkdirs()) {
throw new AxisFault("Fail to create the directory: " + humantaskDir.getAbsolutePath());
}
for (UploadedFileItem uploadedFile : fileItems) {
String fileName = uploadedFile.getFileName();
if (fileName == null || fileName.equals("")) {
throw new AxisFault("Invalid file name. File name is not available");
}
if (HumanTaskConstants.HUMANTASK_PACKAGE_EXTENSION.equals(uploadedFile.getFileType())) {
try {
writeResource(uploadedFile.getDataHandler(), humantaskTemp, fileName, humantaskDir);
} catch (IOException e) {
throw new AxisFault("IOError: Writing resource failed.", e);
}
} else {
throw new AxisFault("Invalid file type : " + uploadedFile.getFileType() + " ." + HumanTaskConstants.HUMANTASK_PACKAGE_EXTENSION + " file type is expected");
}
}
}
Aggregations