use of org.glassfish.internal.api.Target in project Payara by payara.
the class CreateSsl method execute.
/**
* Executes the command with the command parameters passed as Properties where the keys are the paramter names and
* the values the parameter values
*
* @param context information
*/
@Override
public void execute(AdminCommandContext context) {
final ActionReport report = context.getActionReport();
Target targetUtil = habitat.getService(Target.class);
Config newConfig = targetUtil.getConfig(target);
if (newConfig != null) {
config = newConfig;
}
if (!"iiop-service".equals(type) && (listenerId == null)) {
report.setMessage(LOCAL_STRINGS.getLocalString("create.ssl.listenerid.missing", "Listener id needs to be specified"));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
SslConfigHandler configHandler = habitat.getService(SslConfigHandler.class, type);
if (configHandler != null) {
configHandler.create(this, report);
} else if ("jmx-connector".equals(type)) {
addSslToJMXConnector(config, report);
}
}
use of org.glassfish.internal.api.Target in project Payara by payara.
the class ClusterOperationUtil method replicateCommand.
/**
* Replicates a given command on the given list of targets, optionally gathering
* downloaded result payloads from the instance commands into a directory.
* <p>
* If intermediateDownloadDir is non-null, then any files returned from
* the instances in the payload of the HTTP response will be stored in a
* directory tree like this:
* <pre>
* ${intermediateDownloadDir}/
* ${instanceA}/
* file(s) returned from instance A
* ${instanceB}/
* file(s) returned from instance B
* ...
* </pre>
* where ${instanceA}, ${instanceB}, etc. are the names of the instances to
* which the command was replicated. This method does no further processing
* on the downloaded files but leaves that to the calling command.
*/
public static ActionReport.ExitCode replicateCommand(String commandName, FailurePolicy failPolicy, FailurePolicy offlinePolicy, FailurePolicy neverStartedPolicy, Collection<String> targetNames, AdminCommandContext context, ParameterMap parameters, ServiceLocator habitat, File intermediateDownloadDir) {
ActionReport.ExitCode result = ActionReport.ExitCode.SUCCESS;
Target targetService = habitat.getService(Target.class);
for (String t : targetNames) {
if (CommandTarget.DAS.isValid(habitat, t) || CommandTarget.DOMAIN.isValid(habitat, t))
continue;
parameters.set("target", t);
List<Server> instances = targetService.getInstances(t);
ActionReport.ExitCode returnValue = replicateCommand(commandName, failPolicy, offlinePolicy, neverStartedPolicy, instances, context, parameters, habitat, intermediateDownloadDir);
if (!returnValue.equals(ActionReport.ExitCode.SUCCESS)) {
result = returnValue;
}
}
return result;
}
use of org.glassfish.internal.api.Target in project Payara by payara.
the class DeleteResourceRef method execute.
/**
* Executes the command with the command parameters passed as Properties
* where the keys are the parameter names and the values the parameter values
*
* @param context information
*/
@Override
public void execute(AdminCommandContext context) {
final ActionReport report = context.getActionReport();
try {
deleteResourceRef();
if (refContainer instanceof Cluster) {
// delete ResourceRef for all instances of Cluster
Target tgt = habitat.getService(Target.class);
List<Server> instances = tgt.getInstances(target);
for (Server svr : instances) {
svr.deleteResourceRef(refName);
}
}
if (refContainer instanceof DeploymentGroup) {
// delete ResourceRef for all instances of Cluster
Target tgt = habitat.getService(Target.class);
List<Server> instances = tgt.getInstances(target);
for (Server svr : instances) {
svr.deleteResourceRef(refName);
}
}
} catch (Exception e) {
setFailureMessage(report, e);
return;
}
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
report.setMessage(LOCAL_STRINGS.getLocalString("delete.resource.ref.success", "resource-ref {0} deleted successfully from target {1}.", refName, target));
}
use of org.glassfish.internal.api.Target in project Payara by payara.
the class CreateResourceRef method execute.
/**
* Executes the command with the command parameters passed as Properties
* where the keys are the parameter names and the values the parameter values
*
* @param context information
*/
@Override
public void execute(AdminCommandContext context) {
final ActionReport report = context.getActionReport();
if (isResourceRefAlreadyPresent()) {
report.setMessage(LOCAL_STRINGS.getLocalString("create.resource.ref.existsAlready", "Resource ref {0} already exists for target {1}", refName, target));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
try {
createResourceRef();
// create new ResourceRef for all instances of Cluster, if it's a cluster
if (refContainer instanceof Cluster && isElegibleResource(refName)) {
Target tgt = locator.getService(Target.class);
List<Server> instances = tgt.getInstances(target);
for (Server server : instances) {
server.createResourceRef(enabled.toString(), refName);
}
}
// create new ResourceRef for all instances of DeploymentGroup, if it's a DeploymentGroup
if (refContainer instanceof DeploymentGroup && isElegibleResource(refName)) {
DeploymentGroup deploymentGroup = (DeploymentGroup) refContainer;
for (Server server : deploymentGroup.getInstances()) {
if (server.getResourceRef(refName) == null) {
server.createResourceRef(enabled.toString(), refName);
}
}
}
ActionReport.ExitCode ec = ActionReport.ExitCode.SUCCESS;
report.setMessage(LOCAL_STRINGS.getLocalString("create.resource.ref.success", "resource-ref {0} created successfully.", refName));
report.setActionExitCode(ec);
} catch (TransactionFailure tfe) {
report.setMessage(LOCAL_STRINGS.getLocalString("create.resource.ref.failed", "Resource ref {0} creation failed", refName));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(tfe);
}
}
Aggregations