use of org.wso2.ballerinalang.compiler.packaging.repo.Repo in project carbon-business-process by wso2.
the class BPMNDeployer method createTenantRepo.
/**
* @param configurationContext axis2 configurationContext
* @return bpmn repo file
* @throws BPSFault repo creation failure will result in this xception
*/
private File createTenantRepo(ConfigurationContext configurationContext) throws BPSFault {
String axisRepoPath = configurationContext.getAxisConfiguration().getRepository().getPath();
if (CarbonUtils.isURL(axisRepoPath)) {
String msg = "URL Repositories are not supported: " + axisRepoPath;
throw new BPSFault(msg);
}
File tenantsRepository = new File(axisRepoPath);
File bpmnRepo = new File(tenantsRepository, BPMNConstants.BPMN_REPO_NAME);
if (!bpmnRepo.exists()) {
boolean status = bpmnRepo.mkdir();
if (!status) {
String msg = "Failed to create BPMN repository folder " + bpmnRepo.getAbsolutePath() + ".";
throw new BPSFault(msg);
}
}
return bpmnRepo;
}
use of org.wso2.ballerinalang.compiler.packaging.repo.Repo 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");
}
}
}
use of org.wso2.ballerinalang.compiler.packaging.repo.Repo 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.ballerinalang.compiler.packaging.repo.Repo in project ballerina by ballerina-lang.
the class PackageLoader method genRepoHierarchy.
private RepoHierarchy genRepoHierarchy(Path sourceRoot) {
Path balHomeDir = HomeRepoUtils.createAndGetHomeReposPath();
Path projectHiddenDir = sourceRoot.resolve(".ballerina");
RepoHierarchyBuilder.RepoNode[] systemArr = loadSystemRepos();
Converter<Path> converter = sourceDirectory.getConverter();
Repo remote = new RemoteRepo(URI.create("https://staging.central.ballerina.io:9090/"));
Repo homeCacheRepo = new CacheRepo(balHomeDir);
Repo homeRepo = new ZipRepo(balHomeDir);
Repo projectCacheRepo = new CacheRepo(projectHiddenDir);
Repo projectRepo = new ZipRepo(projectHiddenDir);
RepoHierarchyBuilder.RepoNode homeCacheNode;
if (offline) {
homeCacheNode = node(homeCacheRepo, systemArr);
} else {
homeCacheNode = node(homeCacheRepo, node(remote, systemArr));
}
RepoHierarchyBuilder.RepoNode nonLocalRepos = node(projectRepo, node(projectCacheRepo, homeCacheNode), node(homeRepo, homeCacheNode));
RepoHierarchyBuilder.RepoNode fullRepoGraph;
if (converter != null) {
Repo programingSource = new ProgramingSourceRepo(converter);
Repo projectSource = new ProjectSourceRepo(converter);
fullRepoGraph = node(programingSource, node(projectSource, nonLocalRepos));
} else {
fullRepoGraph = nonLocalRepos;
}
return RepoHierarchyBuilder.build(fullRepoGraph);
}
use of org.wso2.ballerinalang.compiler.packaging.repo.Repo in project ballerina by ballerina-lang.
the class URIConverter method finalize.
public Stream<PackageSourceEntry> finalize(URI u, PackageID packageID) {
String orgName = packageID.getOrgName().getValue();
String pkgName = packageID.getName().getValue();
Path destDirPath = HomeRepoUtils.createAndGetHomeReposPath().resolve(Paths.get("repo", orgName, pkgName));
createDirectory(destDirPath);
try {
String fullPkgPath = orgName + "/" + pkgName;
executor.execute(pullBalxLocation, u.toString(), destDirPath.toString(), fullPkgPath, File.separator);
// TODO Simplify using ZipRepo
Patten pattern = new Patten(Patten.WILDCARD_DIR, Patten.path(pkgName + ".zip"), Patten.path("src"), Patten.WILDCARD_SOURCE);
return pattern.convertToSources(new ZipConverter(destDirPath), packageID);
} catch (Exception ignore) {
}
return Stream.of();
}
Aggregations