use of org.glassfish.api.ActionReport in project Payara by payara.
the class DeleteIiopListener method execute.
/**
* Executes the command with the command parameters passed as Properties
* where the keys are the parameter names and the values the parameter values
*
* @param context information
*/
@Override
public void execute(AdminCommandContext context) {
final Target targetUtil = services.getService(Target.class);
final Config config = targetUtil.getConfig(target);
ActionReport report = context.getActionReport();
IiopService iiopService = config.getExtensionByType(IiopService.class);
if (!isIIOPListenerExists(iiopService)) {
report.setMessage(localStrings.getLocalString("delete.iiop.listener" + ".notexists", "IIOP Listener {0} does not exist.", listener_id));
report.setActionExitCode(ExitCode.FAILURE);
return;
}
try {
ConfigSupport.apply(new SingleConfigCode<IiopService>() {
@Override
public Object run(IiopService param) throws PropertyVetoException, TransactionFailure {
List<IiopListener> listenerList = param.getIiopListener();
for (IiopListener listener : listenerList) {
String currListenerId = listener.getId();
if (currListenerId != null && currListenerId.equals(listener_id)) {
listenerList.remove(listener);
break;
}
}
return listenerList;
}
}, iiopService);
report.setActionExitCode(ExitCode.SUCCESS);
} catch (TransactionFailure e) {
String actual = e.getMessage();
report.setMessage(localStrings.getLocalString("delete.iiop.listener.fail", "failed", listener_id, actual));
report.setActionExitCode(ExitCode.FAILURE);
report.setFailureCause(e);
}
}
use of org.glassfish.api.ActionReport in project Payara by payara.
the class CreateJMSHost 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();
Config targetConfig = domain.getConfigNamed(target);
if (targetConfig != null)
config = targetConfig;
Server targetServer = domain.getServerNamed(target);
// String configRef = targetServer.getConfigRef();
if (targetServer != null) {
config = domain.getConfigNamed(targetServer.getConfigRef());
}
com.sun.enterprise.config.serverbeans.Cluster cluster = domain.getClusterNamed(target);
if (cluster != null) {
config = domain.getConfigNamed(cluster.getConfigRef());
}
if (jmsHostName == null) {
report.setMessage(localStrings.getLocalString("create.jms.host.noJmsHost", "No JMS Host name specified."));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
JmsService jmsservice = config.getExtensionByType(JmsService.class);
// ensure we don't already have one of this name before creating it.
for (JmsHost jmsHost : jmsservice.getJmsHost()) {
if (jmsHostName.equals(jmsHost.getName())) {
if (force) {
ActionReport deleteReport = report.addSubActionsReport();
ParameterMap parameters = new ParameterMap();
parameters.set("DEFAULT", jmsHostName);
parameters.set("target", target);
commandRunner.getCommandInvocation("delete-jms-host", deleteReport, context.getSubject()).parameters(parameters).execute();
if (ActionReport.ExitCode.FAILURE.equals(deleteReport.getActionExitCode())) {
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
break;
} else {
report.setMessage(localStrings.getLocalString("create.jms.host.duplicate", "A JMS Host named {0} already exists.", jmsHostName));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
}
}
try {
ConfigSupport.apply(new SingleConfigCode<JmsService>() {
public Object run(JmsService param) throws PropertyVetoException, TransactionFailure {
// TODO: need a way to create a JmsHost instance
JmsHost jmsHost = param.createChild(JmsHost.class);
jmsHost.setAdminPassword(mqpassword);
jmsHost.setAdminUserName(mquser);
jmsHost.setName(jmsHostName);
jmsHost.setHost(mqhost);
jmsHost.setPort(mqport);
if (props != null) {
for (Map.Entry e : props.entrySet()) {
Property prop = jmsHost.createChild(Property.class);
prop.setName((String) e.getKey());
prop.setValue((String) e.getValue());
jmsHost.getProperty().add(prop);
}
}
param.getJmsHost().add(jmsHost);
return jmsHost;
}
}, jmsservice);
} catch (TransactionFailure tfe) {
report.setMessage(localStrings.getLocalString("create.jms.host.fail", "Unable to create jms host {0}.", jmsHostName) + " " + tfe.getLocalizedMessage());
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(tfe);
}
report.setMessage(localStrings.getLocalString("create.jms.host.success", "Jms Host {0} created.", jmsHostName));
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
use of org.glassfish.api.ActionReport in project Payara by payara.
the class DeleteJMSDestination method execute.
public void execute(AdminCommandContext context) {
final ActionReport report = context.getActionReport();
logger.entering(getClass().getName(), "deleteJMSDestination", new Object[] { destName, destType });
try {
validateJMSDestName(destName);
validateJMSDestType(destType);
} catch (IllegalArgumentException e) {
report.setMessage(e.getMessage());
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
try {
deleteJMSDestination(destName, destType, target);
return;
} catch (Exception e) {
logger.throwing(getClass().getName(), "deleteJMSDestination", e);
// e.printStackTrace();//handleException(e);
report.setMessage(localStrings.getLocalString("delete.jms.dest.noJmsDelete", "Delete JMS Destination failed. Please verify if the JMS Destination specified for deletion exists"));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
}
}
use of org.glassfish.api.ActionReport in project Payara by payara.
the class GetJmsPhysicalDestinationCommand method execute.
// 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;
}
}
use of org.glassfish.api.ActionReport in project Payara by payara.
the class GetDomainXMLCommand method execute.
@Override
public void execute(AdminCommandContext context) {
File configFile = new File(se.getConfigDirPath().getAbsolutePath() + "/domain.xml");
try (BufferedReader reader = new BufferedReader(new FileReader(configFile))) {
String all = "";
String line = reader.readLine();
while (line != null) {
all += line;
all += StringUtils.EOL;
line = reader.readLine();
}
ActionReport actionReport = context.getActionReport();
actionReport.appendMessage(all);
Map<String, Object> extraPropsMap = new HashMap<>();
extraPropsMap.put("domainxml", all);
Properties extraProps = new Properties();
extraProps.put("zendeskSupportConfiguration", extraPropsMap);
actionReport.setExtraProperties(extraProps);
} catch (FileNotFoundException ex) {
Logger.getLogger(GetDomainXMLCommand.class.getName()).log(Level.SEVERE, "domain.xml not found");
} catch (IOException ex) {
Logger.getLogger(GetDomainXMLCommand.class.getName()).log(Level.SEVERE, "Error reading domain.xml");
}
}
Aggregations