throw new XPathException(this, EXPathErrorCode.EXPDY003, "Permission denied. You need to be a member " +
"of the dba group to use repo:deploy/undeploy");
String pkgName = args[0].getStringValue();
try {
Deployment deployment = new Deployment(context.getBroker());
String target;
if (isCalledAs("deploy")) {
String userTarget = null;
if (getArgumentCount() == 2)
userTarget = args[1].getStringValue();
target = deployment.deploy(pkgName, context.getRepository(), userTarget);
} else if (isCalledAs("install-and-deploy")) {
String version = null;
String repoURI;
if (getArgumentCount() == 3) {
version = args[1].getStringValue();
repoURI = args[2].getStringValue();
} else {
repoURI = args[1].getStringValue();
}
target = installAndDeploy(pkgName, version, repoURI);
} else if (isCalledAs("install-and-deploy-from-db")) {
String repoURI = null;
if (getArgumentCount() == 2)
repoURI = args[1].getStringValue();
target = installAndDeployFromDb(pkgName, repoURI);
} else
target = deployment.undeploy(pkgName, context.getRepository());
return statusReport(target);
} catch (PackageException e) {
throw new XPathException(this, EXPathErrorCode.EXPDY001, e.getMessage());
} catch (IOException e) {
throw new XPathException(this, ErrorCodes.FOER0000, "Caught IO error while deploying expath archive");