use of org.ow2.proactive_grid_cloud_portal.cli.CLIException in project scheduling by ow2-proactive.
the class PackageDownloader method transformGithubURLToSvnURL.
/**
* This method transforms a github url to an svn-compatible url in order to allow svn operations on github repositories.
* @param githubUrl
* @return
*/
private String transformGithubURLToSvnURL(String githubUrl) {
String svnUrl;
// convert a github repository archive Url to a github repositor Url
githubUrl = githubUrl.replaceAll("/archive/[^\\s/]+\\.zip$", "");
Pattern pattern = Pattern.compile(REGX_GITHUB_REPO_CONTENT);
Matcher matcher = pattern.matcher(githubUrl);
if (githubUrl.matches(REGX_GITHUB_REPO_CONTENT) && matcher.find()) {
if (matcher.group(4) != null && matcher.group(4).matches("(tree/[^\\s/]+)")) {
svnUrl = githubUrl.replace(matcher.group(4), "trunk/");
} else {
svnUrl = matcher.group(1).concat("/trunk");
}
// remove wwww. from svn URL otherwise it doesn't work
if (matcher.group(2) != null) {
svnUrl = svnUrl.replace(matcher.group(2), "");
}
return svnUrl;
} else {
logger.warn(githubUrl + " is not a valid github URL.");
throw new CLIException(REASON_INVALID_ARGUMENTS, String.format("'%s' is not a valid github URL.", githubUrl));
}
}
use of org.ow2.proactive_grid_cloud_portal.cli.CLIException in project scheduling by ow2-proactive.
the class PackageDownloader method downloadPackage.
/**
* This method downloads a package from a remote location. <br>
* It supports the following types of urls:
* <ul>
* <li>Direct-download zip urls</li>
* <li>Exposed web directories (supports only tomcat directory listings for the moment)</li>
* <li>Entire Github repositories given by their http links or downloadable archive format</li>
* <li>Sub-directories within a github repository</li>
* <li>Supports forwarded URLS as in shortened bitly urls, etc </li>
* </ul>
* @param packageUrl
* @return
* @throws IOException
* @throws URISyntaxException
*/
public String downloadPackage(String packageUrl) {
// Get the real URL in case it is a shortened one (via bit.ly, etc)
URL url;
try {
url = getRealURLIfForwarded(new URL(createNormalizeURL(packageUrl)));
checkReachableURL(url);
if (isGithubURL(url.toString())) {
return downloadPackageFromGithub(url.toString());
} else {
return downloadPackageFromWeb(url);
}
} catch (IOException e) {
logger.warn(packageUrl + " is not a reachable package URL.");
throw new CLIException(REASON_INVALID_ARGUMENTS, String.format("'%s' is not a reachable package URL.", packageUrl));
} catch (URISyntaxException e) {
logger.warn(packageUrl + " is not a reachable package URL.");
throw new CLIException(REASON_INVALID_ARGUMENTS, String.format("'%s' is not a valid valid package URL.", packageUrl));
} catch (SVNException e) {
// This exception can only be raised if transformGithubURLtoSvnURL doesn't work properly anymore.
// In that case, the method needs to be revised.
// If a non-existing github url (repo or else) is given, an IOException
logger.warn(packageUrl + " cannot be downloaded from github.com");
throw new CLIException(REASON_INVALID_ARGUMENTS, String.format("'%s' cannot be downloaded from github.com", packageUrl));
}
}
use of org.ow2.proactive_grid_cloud_portal.cli.CLIException in project scheduling by ow2-proactive.
the class PauseCommand method execute.
@Override
public void execute(ApplicationContext currentContext) throws CLIException {
SchedulerRestInterface scheduler = currentContext.getRestClient().getScheduler();
try {
boolean success = scheduler.pauseScheduler(currentContext.getSessionId());
resultStack(currentContext).push(success);
if (success) {
writeLine(currentContext, "Scheduler successfully paused.");
} else {
writeLine(currentContext, "Cannot pause scheduler.");
}
} catch (Exception e) {
handleError("An error occurred while attempting to pause scheduler:", e, currentContext);
}
}
use of org.ow2.proactive_grid_cloud_portal.cli.CLIException in project scheduling by ow2-proactive.
the class RestartInErrorTaskCommand method execute.
@Override
public void execute(ApplicationContext currentContext) throws CLIException {
SchedulerRestInterface scheduler = currentContext.getRestClient().getScheduler();
try {
boolean result = scheduler.restartInErrorTask(currentContext.getSessionId(), jobId, taskId);
handleResult(currentContext, result);
} catch (Exception e) {
handleError(String.format("An error occurred while attempting to restart %s:", task()), e, currentContext);
}
}
use of org.ow2.proactive_grid_cloud_portal.cli.CLIException in project scheduling by ow2-proactive.
the class RestartRunningTaskCommand method execute.
@Override
public void execute(ApplicationContext currentContext) throws CLIException {
SchedulerRestInterface scheduler = currentContext.getRestClient().getScheduler();
try {
boolean result = scheduler.restartTask(currentContext.getSessionId(), jobId, taskId);
handleResult(currentContext, result);
} catch (Exception e) {
handleError(String.format("An error occurred while attempting to restart %s:", task()), e, currentContext);
}
}
Aggregations