use of org.glassfish.api.ActionReport in project Payara by payara.
the class CreateContextService 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
*/
public void execute(AdminCommandContext context) {
final ActionReport report = context.getActionReport();
HashMap attrList = new HashMap();
attrList.put(ResourceConstants.JNDI_NAME, jndiName);
attrList.put(ResourceConstants.CONTEXT_INFO_ENABLED, contextinfoenabled.toString());
attrList.put(ResourceConstants.CONTEXT_INFO, contextinfo);
attrList.put(ServerTags.DESCRIPTION, description);
attrList.put(ResourceConstants.ENABLED, enabled.toString());
ResourceStatus rs;
try {
rs = contextServiceMgr.create(domain.getResources(), attrList, properties, target);
} catch (Exception e) {
report.setMessage(localStrings.getLocalString("create.context.service.failed", "Context service {0} creation failed", jndiName));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(e);
return;
}
ActionReport.ExitCode ec = ActionReport.ExitCode.SUCCESS;
if (rs.getMessage() != null) {
report.setMessage(rs.getMessage());
}
if (rs.getStatus() == ResourceStatus.FAILURE) {
ec = ActionReport.ExitCode.FAILURE;
if (rs.getException() != null)
report.setFailureCause(rs.getException());
}
report.setActionExitCode(ec);
}
use of org.glassfish.api.ActionReport in project Payara by payara.
the class CreateManagedExecutorService 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
*/
public void execute(AdminCommandContext context) {
final ActionReport report = context.getActionReport();
HashMap attrList = new HashMap();
setAttributeList(attrList);
ResourceStatus rs;
try {
rs = managedExecutorServiceMgr.create(domain.getResources(), attrList, properties, target);
} catch (Exception e) {
report.setMessage(localStrings.getLocalString("create.managed.executor.service.failed", "Managed executor service {0} creation failed", jndiName));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(e);
return;
}
ActionReport.ExitCode ec = ActionReport.ExitCode.SUCCESS;
if (rs.getMessage() != null) {
report.setMessage(rs.getMessage());
}
if (rs.getStatus() == ResourceStatus.FAILURE) {
ec = ActionReport.ExitCode.FAILURE;
if (rs.getException() != null)
report.setFailureCause(rs.getException());
}
report.setActionExitCode(ec);
}
use of org.glassfish.api.ActionReport in project Payara by payara.
the class CreateManagedScheduledExecutorService 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
*/
public void execute(AdminCommandContext context) {
final ActionReport report = context.getActionReport();
HashMap attrList = new HashMap();
setAttributeList(attrList);
ResourceStatus rs;
try {
rs = managedScheduledExecutorServiceMgr.create(domain.getResources(), attrList, properties, target);
} catch (Exception e) {
report.setMessage(localStrings.getLocalString("create.managed.scheduled.executor.service.failed", "Managed scheduled executor service {0} creation failed", jndiName));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(e);
return;
}
ActionReport.ExitCode ec = ActionReport.ExitCode.SUCCESS;
if (rs.getMessage() != null) {
report.setMessage(rs.getMessage());
}
if (rs.getStatus() == ResourceStatus.FAILURE) {
ec = ActionReport.ExitCode.FAILURE;
if (rs.getException() != null)
report.setFailureCause(rs.getException());
}
report.setActionExitCode(ec);
}
use of org.glassfish.api.ActionReport in project Payara by payara.
the class SetBatchRuntimeConfiguration method validateDataSourceLookupName.
public void validateDataSourceLookupName(AdminCommandContext context, String targetName, String dsLookupName) {
try {
CommandRunner runner = serviceLocator.getService(CommandRunner.class);
ActionReport subReport = context.getActionReport().addSubActionsReport();
CommandRunner.CommandInvocation inv = runner.getCommandInvocation("list-jdbc-resources", subReport, context.getSubject());
ParameterMap params = new ParameterMap();
params.add("target", targetName);
inv.parameters(params);
inv.execute();
Properties props = subReport.getExtraProperties();
if (props != null) {
if (props.get("jdbcResources") != null) {
List<HashMap<String, String>> map = (List<HashMap<String, String>>) props.get("jdbcResources");
for (HashMap<String, String> e : map) {
if (e.get("name").equals(dsLookupName)) {
return;
}
}
}
}
throw new GlassFishBatchValidationException("No DataSource mapped to " + dsLookupName);
} catch (Exception ex) {
throw new GlassFishBatchValidationException("Exception during validation: ", ex);
}
}
use of org.glassfish.api.ActionReport in project Payara by payara.
the class SetBatchRuntimeConfiguration method validateExecutorServiceLookupName.
public void validateExecutorServiceLookupName(AdminCommandContext context, String targetName, String exeLookupName) {
if ("concurrent/__defaultManagedExecutorService".equals(exeLookupName)) {
return;
}
try {
CommandRunner runner = serviceLocator.getService(CommandRunner.class);
ActionReport subReport = context.getActionReport().addSubActionsReport();
CommandRunner.CommandInvocation inv = runner.getCommandInvocation("list-managed-executor-services", subReport, context.getSubject());
ParameterMap params = new ParameterMap();
params.add("target", targetName);
inv.parameters(params);
inv.execute();
Properties props = subReport.getExtraProperties();
if (props != null) {
if (props.get("managedExecutorServices") != null) {
List<HashMap<String, String>> map = (List<HashMap<String, String>>) props.get("managedExecutorServices");
for (HashMap<String, String> e : map) {
if (e.get("name").equals(exeLookupName)) {
return;
}
}
}
}
throw new GlassFishBatchValidationException("No ExecutorService mapped to " + exeLookupName);
} catch (Exception ex) {
throw new GlassFishBatchValidationException("Exception during validation: ", ex);
}
}
Aggregations