Package org.glassfish.api

Examples of org.glassfish.api.ActionReport$MessagePart


    @Param(name = "long", shortName = "l", optional = true)
    protected boolean useLongFormat;

    @Override
    public final void execute(AdminCommandContext context) {
        ActionReport actionReport = context.getActionReport();
        Properties extraProperties = actionReport.getExtraProperties();
        if (extraProperties == null) {
            extraProperties = new Properties();
            actionReport.setExtraProperties(extraProperties);
        }

        ActionReport subReport = null;
        if (targetUtil.isCluster(target)) {
            for (Server serverInst : targetUtil.getInstances(target)) {
                try {
                    subReport = executeInternalCommand(context, serverInst.getName());
                    break;
View Full Code Here


        String commandName = getCommandName();
        ParameterMap params = new ParameterMap();
        params.add("target", targetInstanceName);
        fillParameterMap(params);
        CommandRunner runner = serviceLocator.getService(CommandRunner.class);
        ActionReport subReport = context.getActionReport().addSubActionsReport();
        CommandRunner.CommandInvocation inv = runner.getCommandInvocation(commandName, subReport, context.getSubject());
        inv.parameters(params);
        inv.execute();

        return subReport;
View Full Code Here

    @Inject
    GlassFishBatchSecurityHelper glassFishBatchSecurityHelper;

    @Override
    public void execute(AdminCommandContext context) {
        ActionReport actionReport = context.getActionReport();
        Properties extraProperties = actionReport.getExtraProperties();
        if (extraProperties == null) {
            extraProperties = new Properties();
            actionReport.setExtraProperties(extraProperties);
        }

        try {
            calculateHeaders();
            helper.checkAndInitializeBatchRuntime();
            glassFishBatchSecurityHelper.markInvocationPrivilege(true);
            executeCommand(context, extraProperties);
            actionReport.setActionExitCode(ActionReport.ExitCode.SUCCESS);
        } catch (Exception ex) {
            logger.log(Level.FINE, "Exception during command ", ex);
            actionReport.setMessage(ex.getMessage());
            actionReport.setActionExitCode(ActionReport.ExitCode.FAILURE);
        } finally {
            glassFishBatchSecurityHelper.markInvocationPrivilege(false);
        }
    }
View Full Code Here

    @Inject
    ResourceRecoveryManager recoveryManager;

    public void execute(AdminCommandContext context) {
        final ActionReport report = context.getActionReport();

        if (_logger.isLoggable(Level.INFO)) {
            _logger.info("==> internal target: " + destinationServer + " ... server: " + serverToRecover);
        }

        String error = validate(destinationServer, false);
        if (error != null) {
            report.setMessage(error);
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            return;
        }

        try {
            boolean result;
            if (!(serverToRecover.equals(destinationServer))) {
                result = recoveryManager.recoverIncompleteTx(true, transactionLogDir);
            } else {
                result = recoveryManager.recoverIncompleteTx(false, null);
            }

            if (_logger.isLoggable(Level.INFO)) {
                _logger.info("==> recovery completed successfuly: " + result);
            }

            if (result)
                report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
            else
                throw new IllegalStateException();
        } catch (Exception e) {
            _logger.log(Level.WARNING, localStrings.getString("recover.transactions.failed"), e);
            report.setMessage(localStrings.getString("recover.transactions.failed"));
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            report.setFailureCause(e);
        }
    }
View Full Code Here

    @Inject
    CommandRunner runner;

    public void execute(AdminCommandContext context) {
        final ActionReport report = context.getActionReport();

        if (_logger.isLoggable(Level.INFO)) {
            _logger.info("==> original target: " + destinationServer + " ... server: " + serverToRecover);
        }

        String error = validate(destinationServer, true);
        if (error != null) {
            _logger.log(Level.WARNING, localStrings.getString("recover.transactions.failed") + " " + error);
            report.setMessage(error);
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            return;
        }

        //here we are only if parameters consistent
        if(destinationServer==null)
            destinationServer = serverToRecover;

        try {
            boolean result;
            CommandRunner.CommandInvocation inv = runner.getCommandInvocation(
                    "_recover-transactions-internal", report);

            final ParameterMap parameters = new ParameterMap();
            parameters.add("target", destinationServer);
            parameters.add("DEFAULT", serverToRecover);
            parameters.add("transactionlogdir", transactionLogDir);

            if (_logger.isLoggable(Level.INFO)) {
                _logger.info("==> calling _recover-transactions-internal with params: " + parameters);
            }

            inv.parameters(parameters).execute();

            if (_logger.isLoggable(Level.INFO)) {
                _logger.info("==> _recover-transactions-internal returned with: " + report.getActionExitCode());
            }

            // Exit code is set by _recover-transactions-internal

        } catch (Exception e) {
            _logger.log(Level.WARNING, localStrings.getString("recover.transactions.failed"), e);
            report.setMessage(localStrings.getString("recover.transactions.failed"));
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            report.setFailureCause(e);
        }
    }
View Full Code Here

     *
     * @param context information
     */
    public void execute(AdminCommandContext context) {

        final ActionReport report = context.getActionReport();

        try {
            Collection<ManagedExecutorService> managedExecutorServices = domain.getResources().getResources(ManagedExecutorService.class);
            for (ManagedExecutorService managedExecutorService : managedExecutorServices) {
                String jndiName = managedExecutorService.getJndiName();
                if(bindableResourcesHelper.resourceExists(jndiName, target)){
                    ActionReport.MessagePart part = report.getTopMessagePart().addChild();
                    part.setMessage(jndiName);
                }
            }
        } catch (Exception e) {
            report.setMessage(localStrings.getLocalString("list.managed.executor.service.failed", "List managed executor services failed"));
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            report.setFailureCause(e);
            return;
        }
        report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
    }
View Full Code Here

    @AccessRequired.To("create")
    private SecurityConfigurations secConfigs;
   
    @Override
    public boolean preAuthorization(AdminCommandContext context) {
        final ActionReport report = context.getActionReport();
        secConfigs = getSecurityConfigurations(report);
        return secConfigs != null;
    }
View Full Code Here

  /**
   * Execute the create-security-service admin command.
   */
  @Override
  public void execute(AdminCommandContext context) {
        final ActionReport report = context.getActionReport();

        // Setup the service type and configuration handler
        if (AUTHENTICATION.equalsIgnoreCase(serviceType)) {
            clazzServiceType = AuthenticationService.class;
            serviceConfigHandler = new AuthenticationConfigHandler();
        }
        else {
            report.setMessage("Invalid security service type specified: " + serviceType);
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            return;
        }
       
        // Add service configuration to the security configurations
        // TODO - Add validation logic required for base service configuration
        SecurityConfiguration config = null;
        try {
            config = (SecurityConfiguration) ConfigSupport.apply(new SingleConfigCode<SecurityConfigurations>() {
                @Override
                public Object run(SecurityConfigurations param) throws PropertyVetoException, TransactionFailure {
                    SecurityConfiguration svcConfig = param.createChild(clazzServiceType);
                    svcConfig.setName(serviceName);
                    svcConfig.setDefault(enableDefault);
                    param.getSecurityServices().add(svcConfig);
                    return svcConfig;
                }
            }, secConfigs);
        } catch (TransactionFailure transactionFailure) {
            report.setMessage("Unable to create security service: " + transactionFailure.getMessage());
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            report.setFailureCause(transactionFailure);
            return;
        }

        // Configure the specific service type settings
        // TODO - Add validation logic required for specific service configuration
View Full Code Here

    private String installDir = null;
    private String registerInstanceMessage = null;

    @Override
    public void execute(AdminCommandContext context) {
        ActionReport report = context.getActionReport();
        ctx = context;
        logger = context.getLogger();

        if (!env.isDas()) {
            String msg = Strings.get("notAllowed");
            logger.warning(msg);
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            report.setMessage(msg);
            return;
        }

        // Make sure Node is valid
        theNode = nodes.getNode(node);
        if (theNode == null) {
            String msg = Strings.get("noSuchNode", node);
            logger.warning(msg);
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            report.setMessage(msg);
            return;
        }

        if (lbEnabled != null && clusterName == null) {
            String msg = Strings.get("lbenabledNotForStandaloneInstance");
            logger.warning(msg);
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            report.setMessage(msg);
            return;
        }

        nodeHost = theNode.getNodeHost();
        nodeDir = theNode.getNodeDirAbsolute();
        installDir = theNode.getInstallDir();

        // First, update domain.xml by calling _register-instance
        CommandInvocation ci = cr.getCommandInvocation("_register-instance", report);
        ParameterMap map = new ParameterMap();
        map.add("node", node);
        map.add("config", configRef);
        map.add("cluster", clusterName);
        if (lbEnabled != null) {
            map.add("lbenabled", lbEnabled.toString());
        }
        if (!checkPorts) {
            map.add("checkports", "false");
        }
        if (StringUtils.ok(portBase)) {
            map.add("portbase", portBase);
        }
        map.add("systemproperties", systemProperties);
        map.add("DEFAULT", instance);
        ci.parameters(map);
        ci.execute();


        if (report.getActionExitCode() != ActionReport.ExitCode.SUCCESS
                && report.getActionExitCode() != ActionReport.ExitCode.WARNING) {
            // If we couldn't update domain.xml then stop!
            return;
        }

        registerInstanceMessage = report.getMessage();

        // if nodehost is localhost and installdir is null and config node, update config node
        // so installdir is product root. see register-instance above
        if (theNode.isLocal() && installDir == null) {
            ci = cr.getCommandInvocation("_update-node", report);
            map = new ParameterMap();
            map.add("installdir", "${com.sun.aas.productRoot}");
            map.add("type", "CONFIG");
            map.add("DEFAULT", theNode.getName());
            ci.parameters(map);
            ci.execute();


            if (report.getActionExitCode() != ActionReport.ExitCode.SUCCESS
                    && report.getActionExitCode() != ActionReport.ExitCode.WARNING) {
                // If we couldn't update domain.xml then stop!
                return;
            }
        }

        if (!validateDasOptions(context)) {
            report.setActionExitCode(ActionReport.ExitCode.WARNING);
            return;
        }

        // Then go create the instance filesystem on the node
        createInstanceFilesystem(context);
View Full Code Here

    private static final String DEFAULT_LB_XML_FILE_NAME =
            "loadbalancer.xml";

    @Override
    public void execute(AdminCommandContext context) {
        ActionReport report = context.getActionReport();
        try {
            String msg = process(context);
            report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
            report.setMessage(msg);
        } catch (Throwable t) {
            String msg = LbLogUtil.getStringManager().getString("ExportHttpLbConfigFailed", t.getMessage());
            LbLogUtil.getLogger().log(Level.WARNING, msg);
            if (LbLogUtil.getLogger().isLoggable(Level.FINE)) {
                LbLogUtil.getLogger().log(Level.FINE, "Exception when exporting http lb config", t);
            }
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            report.setMessage(t.getMessage());
            report.setFailureCause(t);
        }
    }
View Full Code Here

TOP

Related Classes of org.glassfish.api.ActionReport$MessagePart

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.