Search in sources :

Example 56 with ActionReport

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);
}
Also used : HashMap(java.util.HashMap) ResourceStatus(org.glassfish.resourcebase.resources.api.ResourceStatus) ActionReport(org.glassfish.api.ActionReport)

Example 57 with ActionReport

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);
}
Also used : HashMap(java.util.HashMap) ResourceStatus(org.glassfish.resourcebase.resources.api.ResourceStatus) ActionReport(org.glassfish.api.ActionReport)

Example 58 with ActionReport

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);
}
Also used : HashMap(java.util.HashMap) ResourceStatus(org.glassfish.resourcebase.resources.api.ResourceStatus) ActionReport(org.glassfish.api.ActionReport)

Example 59 with ActionReport

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);
    }
}
Also used : GlassFishBatchValidationException(org.glassfish.batch.spi.impl.GlassFishBatchValidationException) ActionReport(org.glassfish.api.ActionReport) GlassFishBatchValidationException(org.glassfish.batch.spi.impl.GlassFishBatchValidationException) NamingException(javax.naming.NamingException) PropertyVetoException(java.beans.PropertyVetoException) SQLException(java.sql.SQLException)

Example 60 with ActionReport

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);
    }
}
Also used : GlassFishBatchValidationException(org.glassfish.batch.spi.impl.GlassFishBatchValidationException) ActionReport(org.glassfish.api.ActionReport) GlassFishBatchValidationException(org.glassfish.batch.spi.impl.GlassFishBatchValidationException) NamingException(javax.naming.NamingException) PropertyVetoException(java.beans.PropertyVetoException) SQLException(java.sql.SQLException)

Aggregations

ActionReport (org.glassfish.api.ActionReport)508 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)86 Properties (java.util.Properties)83 Config (com.sun.enterprise.config.serverbeans.Config)73 PropertyVetoException (java.beans.PropertyVetoException)72 ParameterMap (org.glassfish.api.admin.ParameterMap)66 Logger (java.util.logging.Logger)56 IOException (java.io.IOException)47 ArrayList (java.util.ArrayList)47 HashMap (java.util.HashMap)43 File (java.io.File)41 CommandTarget (org.glassfish.config.support.CommandTarget)30 Target (org.glassfish.internal.api.Target)30 Map (java.util.Map)27 Server (com.sun.enterprise.config.serverbeans.Server)25 List (java.util.List)25 ServiceLocator (org.glassfish.hk2.api.ServiceLocator)24 CommandRunner (org.glassfish.api.admin.CommandRunner)23 ExtendedDeploymentContext (org.glassfish.internal.deployment.ExtendedDeploymentContext)23 DeployCommandParameters (org.glassfish.api.deployment.DeployCommandParameters)19