Search in sources :

Example 26 with ColumnFormatter

use of com.sun.enterprise.util.ColumnFormatter in project Payara by payara.

the class GetJmsNotifierConfiguration method listConfiguration.

@Override
protected String listConfiguration(JmsNotifierConfiguration configuration) {
    String[] headers = { "Enabled", "Context Factory Class", "Connection Factory Name", "Queue Name", "URL", "Username", "Password" };
    ColumnFormatter columnFormatter = new ColumnFormatter(headers);
    Object[] values = new Object[7];
    values[0] = configuration.getEnabled();
    values[1] = configuration.getContextFactoryClass();
    values[2] = configuration.getConnectionFactoryName();
    values[3] = configuration.getQueueName();
    values[4] = configuration.getUrl();
    values[5] = configuration.getUsername();
    values[6] = configuration.getPassword();
    columnFormatter.addRow(values);
    return columnFormatter.toString();
}
Also used : ColumnFormatter(com.sun.enterprise.util.ColumnFormatter)

Example 27 with ColumnFormatter

use of com.sun.enterprise.util.ColumnFormatter in project Payara by payara.

the class GetNewRelicNotifierConfiguration method listConfiguration.

@Override
protected String listConfiguration(NewRelicNotifierConfiguration configuration) {
    String[] headers = { "Enabled", "Key", "Account Id" };
    ColumnFormatter columnFormatter = new ColumnFormatter(headers);
    Object[] values = new Object[3];
    values[0] = configuration.getEnabled();
    values[1] = configuration.getKey();
    values[2] = configuration.getAccountId();
    columnFormatter.addRow(values);
    return columnFormatter.toString();
}
Also used : ColumnFormatter(com.sun.enterprise.util.ColumnFormatter)

Example 28 with ColumnFormatter

use of com.sun.enterprise.util.ColumnFormatter in project Payara by payara.

the class GetXmppNotifierConfiguration method listConfiguration.

@Override
protected String listConfiguration(XmppNotifierConfiguration configuration) {
    String[] headers = { "Enabled", "Host", "Port", "Service Name", "Username", "Password", "Security Disabled", "Room ID" };
    ColumnFormatter columnFormatter = new ColumnFormatter(headers);
    Object[] values = new Object[8];
    values[0] = configuration.getEnabled();
    values[1] = configuration.getHost();
    values[2] = configuration.getPort();
    values[3] = configuration.getServiceName();
    values[4] = configuration.getUsername();
    values[5] = configuration.getPassword();
    values[6] = configuration.getSecurityDisabled();
    values[7] = configuration.getRoomId();
    columnFormatter.addRow(values);
    return columnFormatter.toString();
}
Also used : ColumnFormatter(com.sun.enterprise.util.ColumnFormatter)

Example 29 with ColumnFormatter

use of com.sun.enterprise.util.ColumnFormatter in project Payara by payara.

the class GetCDIEventbusNotifierConfiguration method listConfiguration.

@Override
protected String listConfiguration(CDIEventbusNotifierConfiguration configuration) {
    String[] headers = { "Enabled", "LoopBack" };
    ColumnFormatter columnFormatter = new ColumnFormatter(headers);
    Object[] values = new Object[2];
    values[0] = configuration.getEnabled();
    values[1] = configuration.getLoopBack();
    columnFormatter.addRow(values);
    return columnFormatter.toString();
}
Also used : ColumnFormatter(com.sun.enterprise.util.ColumnFormatter)

Example 30 with ColumnFormatter

use of com.sun.enterprise.util.ColumnFormatter in project Payara by payara.

the class GetNotificationConfiguration method execute.

@Override
public void execute(AdminCommandContext context) {
    Config config = targetUtil.getConfig(target);
    if (config == null) {
        context.getActionReport().setMessage("No such config named: " + target);
        context.getActionReport().setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    ActionReport mainActionReport = context.getActionReport();
    final NotificationServiceConfiguration notificationServiceConfiguration = config.getExtensionByType(NotificationServiceConfiguration.class);
    NotificationServiceConfiguration configuration = config.getExtensionByType(NotificationServiceConfiguration.class);
    List<ServiceHandle<BaseNotifierService>> allServiceHandles = habitat.getAllServiceHandles(BaseNotifierService.class);
    String[] headers = { "Enabled", "Notifier Enabled" };
    ColumnFormatter columnFormatter = new ColumnFormatter(headers);
    if (configuration.getNotifierConfigurationList().isEmpty()) {
        mainActionReport.setMessage("No notifier defined");
    } else {
        List<Class<NotifierConfiguration>> notifierConfigurationClassList = Lists.transform(configuration.getNotifierConfigurationList(), new Function<NotifierConfiguration, Class<NotifierConfiguration>>() {

            @Override
            public Class<NotifierConfiguration> apply(NotifierConfiguration input) {
                return resolveNotifierConfigurationClass(input);
            }
        });
        Properties extraProps = new Properties();
        for (ServiceHandle<BaseNotifierService> serviceHandle : allServiceHandles) {
            NotifierConfiguration notifierConfiguration = configuration.getNotifierConfigurationByType(serviceHandle.getService().getNotifierConfigType());
            if (notifierConfiguration != null) {
                ConfigView view = ConfigSupport.getImpl(notifierConfiguration);
                NotifierConfigurationType annotation = view.getProxyType().getAnnotation(NotifierConfigurationType.class);
                if (notifierConfigurationClassList.contains(view.<NotifierConfiguration>getProxyType())) {
                    Object[] values = new Object[2];
                    values[0] = notificationServiceConfiguration.getEnabled();
                    values[1] = notifierConfiguration.getEnabled();
                    columnFormatter.addRow(values);
                    Map<String, Object> map;
                    if (NotifierType.LOG.equals(annotation.type())) {
                        map = new HashMap<>(3);
                        map.put("enabled", values[0]);
                        map.put("notifierEnabled", values[1]);
                        LogNotifierConfiguration logNotifierConfiguration = (LogNotifierConfiguration) notifierConfiguration;
                        map.put("useSeparateLogFile", logNotifierConfiguration.getUseSeparateLogFile());
                    } else {
                        map = new HashMap<>(2);
                        map.put("enabled", values[0]);
                        map.put("notifierEnabled", values[1]);
                    }
                    extraProps.put("getNotificationConfiguration" + annotation.type(), map);
                }
            }
        }
        mainActionReport.setExtraProperties(extraProps);
        mainActionReport.setMessage(columnFormatter.toString());
    }
    mainActionReport.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
Also used : NotifierConfigurationType(fish.payara.nucleus.notification.configuration.NotifierConfigurationType) ConfigView(org.jvnet.hk2.config.ConfigView) Config(com.sun.enterprise.config.serverbeans.Config) NotifierConfiguration(fish.payara.nucleus.notification.configuration.NotifierConfiguration) LogNotifierConfiguration(fish.payara.nucleus.notification.log.LogNotifierConfiguration) ActionReport(org.glassfish.api.ActionReport) Properties(java.util.Properties) LogNotifierConfiguration(fish.payara.nucleus.notification.log.LogNotifierConfiguration) BaseNotifierService(fish.payara.nucleus.notification.service.BaseNotifierService) NotificationServiceConfiguration(fish.payara.nucleus.notification.configuration.NotificationServiceConfiguration) ServiceHandle(org.glassfish.hk2.api.ServiceHandle) ColumnFormatter(com.sun.enterprise.util.ColumnFormatter)

Aggregations

ColumnFormatter (com.sun.enterprise.util.ColumnFormatter)53 Properties (java.util.Properties)24 HashMap (java.util.HashMap)22 ActionReport (org.glassfish.api.ActionReport)22 Config (com.sun.enterprise.config.serverbeans.Config)21 ServiceHandle (org.glassfish.hk2.api.ServiceHandle)8 ArrayList (java.util.ArrayList)7 PayaraNotifier (fish.payara.internal.notification.PayaraNotifier)5 MonitoringService (com.sun.enterprise.config.serverbeans.MonitoringService)3 AMXConfiguration (fish.payara.admin.amx.config.AMXConfiguration)2 MonitoredAttribute (fish.payara.jmx.monitoring.configuration.MonitoredAttribute)2 MonitoringServiceConfiguration (fish.payara.jmx.monitoring.configuration.MonitoringServiceConfiguration)2 BaseHealthCheck (fish.payara.nucleus.healthcheck.preliminary.BaseHealthCheck)2 NotifierConfigurationType (fish.payara.nucleus.notification.configuration.NotifierConfigurationType)2 LogNotifierConfiguration (fish.payara.nucleus.notification.log.LogNotifierConfiguration)2 BaseNotifierService (fish.payara.nucleus.notification.service.BaseNotifierService)2 File (java.io.File)2 TaggedJobExecution (com.ibm.jbatch.spi.TaggedJobExecution)1 DomainConfig (com.sun.enterprise.admin.servermgmt.DomainConfig)1 DomainException (com.sun.enterprise.admin.servermgmt.DomainException)1