use of org.glassfish.api.admin.ParameterMap in project Payara by payara.
the class CreateJMSDestination method createJMSDestination.
// create-jmsdest
private void createJMSDestination(ActionReport report, final Subject subject) throws Exception {
MQJMXConnectorInfo mqInfo = getMQJMXConnectorInfo(target, config, serverContext, domain, connectorRuntime);
// MBeanServerConnection mbsc = getMBeanServerConnection(tgtName);
try {
MBeanServerConnection mbsc = mqInfo.getMQMBeanServerConnection();
ObjectName on = new ObjectName(DESTINATION_MANAGER_CONFIG_MBEAN_NAME);
String[] signature = null;
AttributeList destAttrs = null;
Object[] params = null;
if (force) {
signature = new String[] {};
params = new Object[] {};
ObjectName[] dests = (ObjectName[]) mbsc.invoke(on, "getDestinations", params, signature);
boolean destExists = false;
if (dests != null) {
String type = destType.equalsIgnoreCase(JMS_DEST_TYPE_TOPIC) ? "t" : "q";
for (ObjectName dest : dests) {
if (dest.toString().indexOf("desttype=" + type + ",name=" + ObjectName.quote(destName)) != -1) {
destExists = true;
break;
}
}
}
if (destExists) {
ActionReport deleteReport = report.addSubActionsReport();
ParameterMap parameters = new ParameterMap();
parameters.set("DEFAULT", destName);
parameters.set("destType", destType);
parameters.set("target", target);
commandRunner.getCommandInvocation("delete-jmsdest", deleteReport, subject).parameters(parameters).execute();
if (ActionReport.ExitCode.FAILURE.equals(deleteReport.getActionExitCode())) {
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
}
}
if (props != null) {
destAttrs = convertProp2Attrs(props);
}
if (destType.equalsIgnoreCase(JMS_DEST_TYPE_TOPIC)) {
destType = DESTINATION_TYPE_TOPIC;
} else if (destType.equalsIgnoreCase(JMS_DEST_TYPE_QUEUE)) {
destType = DESTINATION_TYPE_QUEUE;
}
if ((destAttrs == null) || (destAttrs.isEmpty())) {
signature = new String[] { "java.lang.String", "java.lang.String" };
params = new Object[] { destType, destName };
} else {
signature = new String[] { "java.lang.String", "java.lang.String", "javax.management.AttributeList" };
params = new Object[] { destType, destName, destAttrs };
}
mbsc.invoke(on, "create", params, signature);
report.setMessage(localStrings.getLocalString("create.jms.destination.success", "JMS Destination {0} created.", destName));
} catch (Exception e) {
logAndHandleException(e, "admin.mbeans.rmb.error_creating_jms_dest");
} finally {
try {
if (mqInfo != null) {
mqInfo.closeMQMBeanServerConnection();
}
} catch (Exception e) {
handleException(e);
}
}
}
use of org.glassfish.api.admin.ParameterMap in project Payara by payara.
the class CreateIiopListenerTest method tearDown.
@After
public void tearDown() throws TransactionFailure {
ConfigSupport.apply(new SingleConfigCode<IiopService>() {
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("iiop_1")) {
listenerList.remove(listener);
break;
}
}
return listenerList;
}
}, iiopService);
parameters = new ParameterMap();
}
use of org.glassfish.api.admin.ParameterMap in project Payara by payara.
the class ListIiopListenersTest method testExecuteSuccessListNoListener.
/**
* Test of execute method, of class ListIiopListener.
* list-iiop-listeners
*/
@Test
public void testExecuteSuccessListNoListener() {
parameters = new ParameterMap();
ListIiopListeners listCommand = services.getService(ListIiopListeners.class);
cr.getCommandInvocation("list-iiop-listeners", context.getActionReport(), adminSubject()).parameters(parameters).execute(listCommand);
CreateIiopListenerTest.checkActionReport(context.getActionReport());
List<MessagePart> list = context.getActionReport().getTopMessagePart().getChildren();
assertEquals(origNum, list.size());
List<String> listStr = new ArrayList<String>();
for (MessagePart mp : list) {
listStr.add(mp.getMessage());
}
assertFalse(listStr.contains("listener"));
}
use of org.glassfish.api.admin.ParameterMap 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.admin.ParameterMap in project Payara by payara.
the class SetRestMonitoringConfigurationCommand method messageSecurityProviderExists.
private boolean messageSecurityProviderExists(ActionReport subActionReport, Subject subject) {
boolean exists = false;
CommandInvocation invocation = commandRunner.getCommandInvocation("list-message-security-providers", subActionReport, subject, false);
ParameterMap parameters = new ParameterMap();
parameters.add("layer", "HttpServlet");
invocation.parameters(parameters).execute();
for (MessagePart message : subActionReport.getTopMessagePart().getChildren()) {
if (message.getMessage().equals(AUTH_MODULE_NAME)) {
exists = true;
break;
}
}
return exists;
}
Aggregations