Examples of ActionReport


Examples of org.glassfish.api.ActionReport

    final private LocalStringManagerImpl localStrings =
        new LocalStringManagerImpl(DisableMonitoring.class);

    public void execute(AdminCommandContext context) {

        ActionReport report = context.getActionReport();

        try {
            // BN: Famous Last Words:  This can't fail!!!  I'm handling anyways...
            ms = targetService.getConfig(target).getMonitoringService();
        }
        catch(Exception e) {
            report.setMessage(localStrings.getLocalString("target.service.exception",
                "Encountered exception trying to locate the MonitoringService element "
                + "in the target ({0}) configuration: {1}", target, e.getMessage()));
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            return;
        }

        try {
            if ((modules == null) || (modules.length() < 1)) {
                // check if it is already false
                boolean enabled = Boolean.parseBoolean(ms.getMonitoringEnabled());
                // set overall monitoring-enabled to false
                if (enabled) {
                    MonitoringConfig.setMonitoringEnabled(ms, "false", report);
                } else {
                    report.setMessage(
                        localStrings.getLocalString("disable.monitoring.alreadyfalse",
                        "monitoring-enabled is already set to false"));
                }
            } else {
                // for each module set monitoring level to OFF
                String[] strArr = modules.split(":");
                for (String moduleName: strArr) {
                    if (moduleName.length() > 0) {
                        MonitoringConfig.setMonitoringLevel(ms, moduleName, ContainerMonitoring.LEVEL_OFF, report);
                    }
                }
            }
            report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
        } catch (Exception e) {
            report.setMessage(localStrings.getLocalString("disable.monitoring.exception",
                "Encountered exception during disabling monitoring {0}", e.getMessage()));
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        }
    }
View Full Code Here

Examples of org.glassfish.api.ActionReport

    private Boolean dtrace;
    final private LocalStringManagerImpl localStrings =
            new LocalStringManagerImpl(EnableMonitoring.class);

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

        try {
            ms = targetService.getConfig(target).getMonitoringService();
        }
        catch (Exception e) {
            report.setMessage(localStrings.getLocalString("target.service.exception",
                    "Encountered exception trying to locate the MonitoringService element "
                    + "in the target ({0}) configuration: {1}", target, e.getMessage()));
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            return;
        }

        int pidInt = -1;

        try {
            if (pid != null)
                pidInt = Integer.parseInt(pid);
        }
        catch (Exception e) {
            pidInt = -1;
        }

        if (options == null)
            options = "";

         if (!AgentAttacher.attachAgent(pidInt, options)) {
            ActionReport.MessagePart part = report.getTopMessagePart().addChild();
            part.setMessage(localStrings.getLocalString("attach.agent.exception",
                    "Can't attach the agent to the JVM."));
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            return;
        }


        // following ordering is deliberate to facilitate config change
View Full Code Here

Examples of org.glassfish.api.ActionReport

                        context.getModuleArchiveHandlers().put(
                            moduleUri, handler);
                    }

                    if (handler!=null) {
                        ActionReport subReport =
                            context.getActionReport().addSubActionsReport();
                        // todo : this is a hack, once again,
                        // the handler is assuming a file:// url
                        ExtendedDeploymentContext subContext =
                            new DeploymentContextImpl(subReport,
View Full Code Here

Examples of org.glassfish.api.ActionReport

     *
     * @param context information
     */
    @Override
    public void execute(AdminCommandContext context) {
        final ActionReport report = context.getActionReport();

        if (jndiName == null) {
            report.setMessage(localStrings.getLocalString("delete.jms.resource.noJndiName",
                    "No JNDI name defined for JMS Resource."));
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            return;
        }
       
        jndiNameForConnectionPool = jndiName + JNDINAME_APPENDER;

        ActionReport subReport = report.addSubActionsReport();

        ConnectorResource cresource = null;
        Resource res = ConnectorsUtil.getResourceByName(domain.getResources(), ConnectorResource.class, jndiName);
        if (res instanceof ConnectorResource) {
            cresource = (ConnectorResource) res;
        }
        /* for (ConnectorResource cr : connResources) {
         if (cr.getJndiName().equals(jndiName))
         cresource = cr;
         } */
        if (cresource == null) {
            ParameterMap params = new ParameterMap();
            params.set("jndi_name", jndiName);
            params.set("DEFAULT", jndiName);
            params.set("target", target);
            commandRunner.getCommandInvocation("delete-admin-object", subReport, context.getSubject()).parameters(params).execute();

            if (ActionReport.ExitCode.FAILURE.equals(subReport.getActionExitCode())) {
                report.setMessage(localStrings.getLocalString("delete.jms.resource.cannotDeleteJMSAdminObject",
                        "Unable to Delete Admin Object."));
                report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                return;
            }
        } else {
            // Delete the connector resource and connector connection pool
            String defPoolName = jndiNameForConnectionPool;
            String poolName = cresource.getPoolName();
            if (poolName != null && poolName.equals(defPoolName)) {
                ParameterMap params = new ParameterMap();
                params.set("DEFAULT", jndiName);
                params.set("connector_resource_name", jndiName);
                params.set("target", target);
                commandRunner.getCommandInvocation("delete-connector-resource", subReport, context.getSubject()).parameters(params).execute();

                if (ActionReport.ExitCode.FAILURE.equals(subReport.getActionExitCode())) {
                    report.setMessage(localStrings.getLocalString("delete.jms.resource.cannotDeleteJMSResource",
                            "Unable to Delete Connector Resource."));
                    report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                    return;
                }


                params = new ParameterMap();
                params.set("poolname", jndiName);
                params.set("DEFAULT", jndiNameForConnectionPool);
                commandRunner.getCommandInvocation("delete-connector-connection-pool", subReport, context.getSubject()).parameters(params).execute();

                if (ActionReport.ExitCode.FAILURE.equals(subReport.getActionExitCode())) {
                    report.setMessage(localStrings.getLocalString("delete.jms.resource.cannotDeleteJMSPool",
                            "Unable to Delete Connector Connection Pool."));
                    report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                    return;
                }
                //clear the message set by the delete-connector-connection-pool command this is to prevent the 'connection pool deleted' message from displaying
                subReport.setMessage("");

            } else {
                // There is no connector pool with the default poolName.
                // However, no need to throw exception as the connector
                // resource might still be there. Try to delete the
                // connector-resource without touching the ref. as
                // ref. might have been deleted while deleting connector-connection-pool
                // as the ref. is the same.

                ParameterMap params = new ParameterMap();
                params.set("DEFAULT", jndiName);
                params.set("connector_resource_name", jndiName);
                params.set("target", target);
                commandRunner.getCommandInvocation("delete-connector-resource", subReport, context.getSubject()).parameters(params).execute();

                if (ActionReport.ExitCode.FAILURE.equals(subReport.getActionExitCode())) {
                    report.setMessage(localStrings.getLocalString("delete.jms.resource.cannotDeleteJMSResource",
                            "Unable to Delete Connector Resource."));
                    report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                    return;
                }
View Full Code Here

Examples of org.glassfish.api.ActionReport

    ServerContext serverContext;

    // com.sun.messaging.jms.server:type=Destination,subtype=Config,desttype=destinationType,name=destinationName
    @Override
    public void execute(AdminCommandContext context) {
        final ActionReport report = context.getActionReport();
        logger.entering(getClass().getName(), "__updateJmsPhysicalDestination", new Object[]{destName, destType});

        try {
            validateJMSDestName(destName);
            validateJMSDestType(destType);

            updateJMSDestination();
            report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
        } catch (Exception e) {
            report.setMessage(e.getMessage());
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            return;
        }
    }
View Full Code Here

Examples of org.glassfish.api.ActionReport

        *
        * @param context information
        */
    @Override
       public void execute(AdminCommandContext context) {
        final ActionReport report = context.getActionReport();
        ArrayList<Map<String,String>> list = new ArrayList<>();
        Properties extraProperties = new Properties();

        Collection adminObjectResourceList = domain.getResources().getResources(AdminObjectResource.class);
        Collection connectorResourcesList = domain.getResources().getResources(ConnectorResource.class);      

        Object [] connectorResources = connectorResourcesList.toArray();
        Object [] adminObjectResources = adminObjectResourceList.toArray();

        if (resourceType == null){
          try {
            //list all JMS resources
            for (Object r :  adminObjectResources) {
                AdminObjectResource adminObject = (AdminObjectResource) r;
                if (JMSRA.equals(adminObject.getResAdapter())) {
                    Map<String,String> m = new HashMap<>();
                    m.put("name", adminObject.getJndiName());
                    list.add(m);
                }
            }

            for (Object c: connectorResources) {
                ConnectorResource cr = (ConnectorResource) c;
                ConnectorConnectionPool cp = (ConnectorConnectionPool) ConnectorsUtil.getResourceByName(
                        domain.getResources(), ConnectorConnectionPool.class, cr.getPoolName());

                if (cp  != null && JMSRA.equals(cp.getResourceAdapterName())){
                    Map<String,String> m = new HashMap<>();
                    m.put("name", cr.getJndiName());
                    list.add(m);
                }
            }
        } catch (Exception e) {
            report.setMessage(localStrings.getLocalString("list.jms.resources.fail",
                    "Unable to list JMS Resources") + " " + e.getLocalizedMessage());
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            report.setFailureCause(e);
            return;
        }
      } else {
            switch (resourceType) {
                case TOPIC_CF:
                case QUEUE_CF:
                case UNIFIED_CF:
                    for (Object c : connectorResources) {
                       ConnectorResource cr = (ConnectorResource)c;
                       ConnectorConnectionPool cp = (ConnectorConnectionPool)
                               ConnectorsUtil.getResourceByName(domain.getResources(), ConnectorConnectionPool.class, cr.getPoolName());
                       if(cp != null && resourceType.equals(cp.getConnectionDefinitionName()) && JMSRA.equals(cp.getResourceAdapterName())) {
                            Map<String,String> m = new HashMap<>();
                            m.put("name", cr.getJndiName());
                            list.add(m);
                        }
                    }
                    break;
                case TOPIC:
                case QUEUE:
                    for (Object r : adminObjectResources) {
                        AdminObjectResource res = (AdminObjectResource)r;
                        if(resourceType.equals(res.getResType()) && JMSRA.equals(res.getResAdapter())) {
                            Map<String,String> m = new HashMap<>();
                            m.put("name", res.getJndiName());
                            list.add(m);
                        }
                    }
                    break;
            }
      }
        if (!list.isEmpty()) {
            List<Map<String,String>> resourceList =
                CommandTarget.DOMAIN.isValid(habitat, target) ? list : filterListForTarget(list);

            List<DefaultResourceProxy> drps = habitat.getAllServices(DefaultResourceProxy.class);
           
            for (Map<String,String> m : resourceList) {
                String jndiName = m.get("name");
                final ActionReport.MessagePart part = report.getTopMessagePart().addChild();
                part.setMessage(jndiName);
                String logicalName = DefaultResourceProxy.Util.getLogicalName(drps, jndiName);
                if (logicalName != null) {
                    m.put("logical-jndi-name", logicalName);
                }
            }
            extraProperties.put("jmsResources", resourceList);
        }
        report.setExtraProperties(extraProperties);
        report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
  }
View Full Code Here

Examples of org.glassfish.api.ActionReport

    ServerContext serverContext;

    // com.sun.messaging.jms.server:type=Destination,subtype=Config,desttype=destinationType,name=destinationName
    @Override
    public void execute(AdminCommandContext context) {
        final ActionReport report = context.getActionReport();
        logger.entering(getClass().getName(), "__getJmsPhysicalDestination",
                new Object[]{destName, destType});

        try {
            validateJMSDestName(destName);
            validateJMSDestType(destType);

            Map entity = getJMSDestination();
            Properties ep = new Properties();
            ep.put("entity", entity);
            report.setExtraProperties(ep);
            report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
        } catch (Exception e) {
            report.setMessage(e.getMessage());
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            return;
        }
    }
View Full Code Here

Examples of org.glassfish.api.ActionReport

     * 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();
        final String newMB = newMasterBroker;
        Server newMBServer = domain.getServerNamed(newMasterBroker);
        if (newMBServer == null) {
            report.setMessage(localStrings.getLocalString("change.master.broker.invalidServerName",
                            "Invalid server name specified. There is no server by this name"));
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            return;
        }
        Cluster cluster = newMBServer.getCluster();//domain.getClusterNamed(clusterName);

        if (cluster == null) {
            report.setMessage(localStrings.getLocalString("change.master.broker.invalidClusterName",
                            "The server specified is not associated with a cluster. The server assocaited with the master broker has to be a part of the cluster"));
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            return;
        }


        /*if(!cluster.getName().equals(newMBServer.getCluster().getName()))
        {
            report.setMessage(localStrings.getLocalString("configure.jms.cluster.invalidClusterName",
                            "{0} does not belong to the specified cluster", newMasterBroker));
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            return;
        } */

       Nodes nodes = domain.getNodes();
       config = domain.getConfigNamed(cluster.getConfigRef());
       JmsService jmsservice = config.getExtensionByType(JmsService.class);
       Server oldMBServer = null;
       //If Master broker has been set previously using this command, use that master broker as the old MB instance
       //Else use the first configured instance in the cluster list
       if(jmsservice.getMasterBroker() != null){
            oldMBServer = domain.getServerNamed(jmsservice.getMasterBroker());
       }else
       {
           List<Server> serverList = cluster.getInstances();
           //if(serverList == null || serverList.size() == 0){
             //report.setMessage(localStrings.getLocalString("change.master.broker.invalidCluster",
               //             "No servers configured in cluster {0}", clusterName));
            //report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            //return;
           //}
           oldMBServer = serverList.get(0);
       }

       String oldMasterBrokerPort = JmsRaUtil.getJMSPropertyValue(oldMBServer);
       if(oldMasterBrokerPort == null) {
        SystemProperty sp = config.getSystemProperty("JMS_PROVIDER_PORT");
        if(sp != null) oldMasterBrokerPort = sp.getValue();
       }
       if(oldMasterBrokerPort == null) oldMasterBrokerPort = getDefaultJmsHost(jmsservice).getPort();
       String oldMasterBrokerHost = nodes.getNode(oldMBServer.getNodeRef()).getNodeHost();

       String newMasterBrokerPort = JmsRaUtil.getJMSPropertyValue(newMBServer);
       if(newMasterBrokerPort == null) newMasterBrokerPort = getDefaultJmsHost(jmsservice).getPort();
       String newMasterBrokerHost = nodes.getNode(newMBServer.getNodeRef()).getNodeHost();


       String oldMasterBroker = oldMasterBrokerHost + ":" + oldMasterBrokerPort;
       String newMasterBroker = newMasterBrokerHost + ":" + newMasterBrokerPort;
      // System.out.println("1: IN deleteinstanceCheck supplimental oldMasterBroker = " + oldMasterBroker + " newmasterBroker " + newMasterBroker);
       try{
           CompositeData result = updateMasterBroker(oldMBServer.getName(), oldMasterBroker, newMasterBroker);
           boolean success = ((Boolean) result.get("Success")).booleanValue();
           if (!success) {
               int statusCode = ((Integer) result.get("StatusCode")).intValue();
               String detailMessage = (String) result.get("DetailMessage");
               String msg = " " + detailMessage;
               if (BrokerStatusCode.BAD_REQUEST.getCode() == statusCode || BrokerStatusCode.NOT_ALLOWED.getCode() == statusCode ||
                   BrokerStatusCode.UNAVAILABLE.getCode() == statusCode || BrokerStatusCode.PRECONDITION_FAILED.getCode() == statusCode) {
                   msg = localStrings.getLocalString("change.master.broker.errorMsg",
                                                     "{0}. But it didn't affect current master broker configuration.", msg);
               } else {
                   msg = msg + ". " + localStrings.getLocalString("change.master.broker.otherErrorMsg",
                                                                  "The cluster should be shutdown and configured with the new master broker then restarts.");
               }

               report.setMessage(localStrings.getLocalString("change.master.broker.CannotChangeMB",
                                                             "Unable to change master broker.{0}", msg));
               report.setActionExitCode(ActionReport.ExitCode.FAILURE);
               return;
            }
       }catch(Exception e){
                      report.setMessage(localStrings.getLocalString("change.master.broker.CannotChangeMB",
                                    "Unable to change master broker.{0}", ""));
                            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                        return;
                 }

        try {
            /*String setCommandStr = cluster.getConfigRef() + "." + "jms-service" + "." +"master-Broker";
            ParameterMap parameters = new ParameterMap();
            parameters.set(setCommandStr, newMB );

            ActionReport subReport = report.addSubActionsReport();
          commandRunner.getCommandInvocation("set", subReport, context.getSubject()).parameters(parameters).execute();

              if (ActionReport.ExitCode.FAILURE.equals(subReport.getActionExitCode())){
                    report.setMessage(localStrings.getLocalString("create.jms.resource.cannotCreateConnectionPool",
                            "Unable to create connection pool."));
                    report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                    return;
              }*/

            ConfigSupport.apply(new SingleConfigCode<JmsService>() {
                public Object run(JmsService param) throws PropertyVetoException, TransactionFailure {

                    param.setMasterBroker(newMB);
                    return param;
                  }
               }, jmsservice);
        } catch(Exception tfe) {
            report.setMessage(localStrings.getLocalString("change.master.broker.fail",
                            "Unable to update the domain.xml with the new master broker") +
                            " " + tfe.getLocalizedMessage());
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            report.setFailureCause(tfe);
        }
        report.setMessage(localStrings.getLocalString("change.master.broker.success",
                "Master broker change has executed successfully for Cluster {0}.", cluster.getName()));
        report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
    }
View Full Code Here

Examples of org.glassfish.api.ActionReport


    public void execute(AdminCommandContext context) {


        final ActionReport report = context.getActionReport();
        boolean isCluster = false;
        boolean isDas = false;
        boolean isInstance = false;
        StringBuffer successMsg = new StringBuffer();
        boolean success = false;
        boolean invalidLogLevels = false;
        boolean isConfig = false;
        String targetConfigName = "";

        Map<String, String> m = new HashMap<String, String>();
        try {
            for (final Object key : properties.keySet()) {
                final String logger_name = (String) key;
                final String level = (String) properties.get(logger_name);
                // that is is a valid level
                boolean vlvl = false;
                for (String s : validLevels) {
                    if (s.equals(level)) {
                        m.put(logger_name + ".level", level);
                        vlvl = true;
                        successMsg.append(localStrings.getLocalString(
                                "set.log.level.properties", "{0} package set with log level {1}.\n", logger_name, level));
                    }
                }
                if (!vlvl) {
                    report.setMessage(localStrings.getLocalString("set.log.level.invalid",
                            "Invalid logger level found {0}.  Valid levels are: SEVERE, WARNING, INFO, FINE, FINER, FINEST", level));
                    invalidLogLevels = true;
                    break;
                }
            }

            if (invalidLogLevels) {
                report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            } else {

                Config config = domain.getConfigNamed(target);
                if (config != null) {
                    targetConfigName = target;
                    isConfig = true;

                    Server targetServer = domain.getServerNamed(SystemPropertyConstants.DEFAULT_SERVER_INSTANCE_NAME);
                    if (targetServer != null && targetServer.getConfigRef().equals(target)) {
                        isDas = true;
                    }
                    targetServer = null;
                } else {
                    Server targetServer = domain.getServerNamed(target);

                    if (targetServer != null && targetServer.isDas()) {
                        isDas = true;
                    } else {
                        com.sun.enterprise.config.serverbeans.Cluster cluster = domain.getClusterNamed(target);
                        if (cluster != null) {
                            isCluster = true;
                            targetConfigName = cluster.getConfigRef();
                        } else if (targetServer != null) {
                            isInstance = true;
                            targetConfigName = targetServer.getConfigRef();
                        }
                    }

                    if (isInstance) {
                        Cluster clusterForInstance = targetServer.getCluster();
                        if (clusterForInstance != null) {
                            targetConfigName = clusterForInstance.getConfigRef();
                        }
                    }
                }

                if (isCluster || isInstance) {
                    loggingConfig.updateLoggingProperties(m, targetConfigName);
                    success = true;
                } else if (isDas) {
                    loggingConfig.updateLoggingProperties(m);
                    success = true;
                } else if (isConfig) {
                    // This loop is for the config which is not part of any target
                    loggingConfig.updateLoggingProperties(m, targetConfigName);
                    success = true;
                } else {
                    report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                    String msg = localStrings.getLocalString("invalid.target.sys.props",
                            "Invalid target: {0}. Valid default target is a server named ''server'' (default) or cluster name.", target);
                    report.setMessage(msg);
                    return;
                }

                if (success) {
                    successMsg.append(localStrings.getLocalString(
                            "set.log.level.success", "These logging levels are set for {0}.", target));
                    report.setMessage(successMsg.toString());
                    report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
                }
            }

        } catch (IOException e) {
            report.setMessage(localStrings.getLocalString("set.log.level.failed",
                    "Could not set logger levels for {0}.", target));
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        }
    }
View Full Code Here

Examples of org.glassfish.api.ActionReport

    final private static LocalStringManagerImpl localStrings = new LocalStringManagerImpl(SetLogLevel.class);

    public void execute(AdminCommandContext context) {

        final ActionReport report = context.getActionReport();
        boolean isCluster = false;
        boolean isDas = false;
        boolean isInstance = false;
        StringBuffer sbfSuccessMsg = new StringBuffer();
        boolean success = false;
        boolean invalidAttribute = false;
        boolean isConfig = false;
        String targetConfigName = "";

        Map<String, String> m = new HashMap<String, String>();
        try {
            for (final Object key : properties.keySet()) {
                final String att_name = (String) key;
                final String att_value = (String) properties.get(att_name);
                // that is is a valid level
                boolean vlAttribute = false;
                for (String attrName : validAttributes) {
                    if (attrName.equals(att_name)) {
                        m.put(att_name, att_value);
                        vlAttribute = true;
                        sbfSuccessMsg.append(localStrings.getLocalString(
                                "set.log.attribute.properties", "{0} logging attribute set with value {1}.\n", att_name, att_value));
                    }
                }

                if (!vlAttribute) {
                    report.setMessage(localStrings.getLocalString("set.log.attribute.invalid",
                            "Invalid logging attribute name found {0}.", att_name));
                    invalidAttribute = true;
                    break;
                }
            }

            if (invalidAttribute) {
                report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            } else {

                Config config = domain.getConfigNamed(target);
                if (config != null) {
                    targetConfigName = target;
                    isConfig = true;

                    Server targetServer = domain.getServerNamed(SystemPropertyConstants.DAS_SERVER_NAME);
                    if (targetServer != null && targetServer.getConfigRef().equals(target)) {
                        isDas = true;
                    }
                    targetServer = null;
                } else {
                    Server targetServer = domain.getServerNamed(target);

                    if (targetServer != null && targetServer.isDas()) {
                        isDas = true;
                    } else {
                        com.sun.enterprise.config.serverbeans.Cluster cluster = domain.getClusterNamed(target);
                        if (cluster != null) {
                            isCluster = true;
                            targetConfigName = cluster.getConfigRef();
                        } else if (targetServer != null) {
                            isInstance = true;
                            targetConfigName = targetServer.getConfigRef();
                        }
                    }

                    if (isInstance) {
                        Cluster clusterForInstance = targetServer.getCluster();
                        if (clusterForInstance != null) {
                            targetConfigName = clusterForInstance.getConfigRef();
                        }
                    }
                }

                if (isCluster || isInstance) {
                    loggingConfig.updateLoggingProperties(m, targetConfigName);
                    success = true;
                } else if (isDas) {
                    loggingConfig.updateLoggingProperties(m);
                    success = true;
                } else if (isConfig) {
                    // This loop is for the config which is not part of any target
                    loggingConfig.updateLoggingProperties(m, targetConfigName);
                    success = true;
                } else {
                    report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                    String msg = localStrings.getLocalString("invalid.target.sys.props",
                            "Invalid target: {0}. Valid default target is a server named ''server'' (default) or cluster name.", target);
                    report.setMessage(msg);
                    return;
                }

                if (success) {
                    sbfSuccessMsg.append(localStrings.getLocalString(
                            "set.log.attribute.success", "These logging attributes are set for {0}.", target));
                    report.setMessage(sbfSuccessMsg.toString());
                    report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
                        }
                    }

        } catch (IOException e) {
            report.setMessage(localStrings.getLocalString("set.log.attribute.failed",
                    "Could not set logging attributes for {0}.", target));
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.