Search in sources :

Example 1 with ZendeskSupportConfiguration

use of fish.payara.appserver.zendesk.config.ZendeskSupportConfiguration in project Payara by payara.

the class GetZendeskSupportConfigurationCommand method execute.

@Override
public void execute(AdminCommandContext acc) {
    Config configNode = targetUtil.getConfig(config);
    ZendeskSupportConfiguration zendeskSupportConfiguration = configNode.getExtensionByType(ZendeskSupportConfiguration.class);
    ActionReport actionReport = acc.getActionReport();
    final String[] outputHeaders = { "Enabled", "Email Address" };
    ColumnFormatter columnFormatter = new ColumnFormatter(outputHeaders);
    Object[] outputValues = { zendeskSupportConfiguration.getEnabled(), zendeskSupportConfiguration.getEmailAddress() };
    columnFormatter.addRow(outputValues);
    actionReport.appendMessage(columnFormatter.toString());
    Map<String, Object> extraPropsMap = new HashMap<>();
    extraPropsMap.put("enabled", zendeskSupportConfiguration.getEnabled());
    extraPropsMap.put("emailAddress", zendeskSupportConfiguration.getEmailAddress());
    Properties extraProps = new Properties();
    extraProps.put("zendeskSupportConfiguration", extraPropsMap);
    actionReport.setExtraProperties(extraProps);
}
Also used : HashMap(java.util.HashMap) Config(com.sun.enterprise.config.serverbeans.Config) ZendeskSupportConfiguration(fish.payara.appserver.zendesk.config.ZendeskSupportConfiguration) ActionReport(org.glassfish.api.ActionReport) Properties(java.util.Properties) ColumnFormatter(com.sun.enterprise.util.ColumnFormatter)

Example 2 with ZendeskSupportConfiguration

use of fish.payara.appserver.zendesk.config.ZendeskSupportConfiguration in project Payara by payara.

the class SetZendeskSupportConfigurationCommand method execute.

@Override
public void execute(AdminCommandContext acc) {
    Config config = targetUtil.getConfig(target);
    ActionReport actionReport = acc.getActionReport();
    ZendeskSupportConfiguration zendeskSupportConfiguration = config.getExtensionByType(ZendeskSupportConfiguration.class);
    if (zendeskSupportConfiguration != null) {
        try {
            ConfigSupport.apply(new SingleConfigCode<ZendeskSupportConfiguration>() {

                @Override
                public Object run(ZendeskSupportConfiguration config) {
                    if (enabled != null) {
                        config.setEnabled(Boolean.toString(enabled));
                    }
                    if (!Strings.isNullOrEmpty(emailAddress)) {
                        config.setEmailAddress(emailAddress);
                    }
                    return null;
                }
            }, zendeskSupportConfiguration);
        } catch (TransactionFailure ex) {
            // Set failure
            actionReport.failure(Logger.getLogger(SetZendeskSupportConfigurationCommand.class.getName()), "Failed to update configuration", ex);
        }
    }
}
Also used : TransactionFailure(org.jvnet.hk2.config.TransactionFailure) Config(com.sun.enterprise.config.serverbeans.Config) ActionReport(org.glassfish.api.ActionReport) ZendeskSupportConfiguration(fish.payara.appserver.zendesk.config.ZendeskSupportConfiguration)

Aggregations

Config (com.sun.enterprise.config.serverbeans.Config)2 ZendeskSupportConfiguration (fish.payara.appserver.zendesk.config.ZendeskSupportConfiguration)2 ActionReport (org.glassfish.api.ActionReport)2 ColumnFormatter (com.sun.enterprise.util.ColumnFormatter)1 HashMap (java.util.HashMap)1 Properties (java.util.Properties)1 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)1