use of org.jvnet.hk2.config.Element in project Payara by payara.
the class CreateSsl method addSslToJMXConnector.
private void addSslToJMXConnector(Config config, ActionReport report) {
AdminService adminService = config.getAdminService();
// ensure we have the specified listener
JmxConnector jmxConnector = null;
for (JmxConnector jmxConn : adminService.getJmxConnector()) {
if (jmxConn.getName().equals(listenerId)) {
jmxConnector = jmxConn;
}
}
if (jmxConnector == null) {
report.setMessage(localStrings.getLocalString("create.ssl.jmx.notfound", "JMX Connector named {0} to which this ssl element is " + "being added does not exist.", listenerId));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
if (jmxConnector.getSsl() != null) {
report.setMessage(localStrings.getLocalString("create.ssl.jmx.alreadyExists", "IIOP Listener named {0} to which this ssl element is " + "being added already has an ssl element.", listenerId));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
try {
ConfigSupport.apply(new SingleConfigCode<JmxConnector>() {
@Override
public Object run(JmxConnector param) throws PropertyVetoException, TransactionFailure {
Ssl newSsl = param.createChild(Ssl.class);
populateSslElement(newSsl);
param.setSsl(newSsl);
return newSsl;
}
}, jmxConnector);
} catch (TransactionFailure e) {
reportError(report, e);
}
reportSuccess(report);
}
use of org.jvnet.hk2.config.Element in project Payara by payara.
the class DeleteSsl 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
*/
public void execute(AdminCommandContext context) {
ActionReport report = context.getActionReport();
Target targetUtil = habitat.getService(Target.class);
Config newConfig = targetUtil.getConfig(target);
if (newConfig != null) {
config = newConfig;
}
if (!type.equals("iiop-service")) {
if (listenerId == null) {
report.setMessage(localStrings.getLocalString("create.ssl.listenerid.missing", "Listener id needs to be specified"));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
}
try {
SslConfigHandler sslConfigHandler = habitat.getService(SslConfigHandler.class, type);
if (sslConfigHandler != null) {
sslConfigHandler.delete(this, report);
} else if ("jmx-connector".equals(type)) {
JmxConnector jmxConnector = null;
for (JmxConnector listener : config.getAdminService().getJmxConnector()) {
if (listener.getName().equals(listenerId)) {
jmxConnector = listener;
}
}
if (jmxConnector == null) {
report.setMessage(localStrings.getLocalString("delete.ssl.jmx.connector.notfound", "Iiop Listener named {0} not found", listenerId));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
if (jmxConnector.getSsl() == null) {
report.setMessage(localStrings.getLocalString("delete.ssl.element.doesnotexist", "Ssl element does " + "not exist for Listener named {0}", listenerId));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
ConfigSupport.apply(new SingleConfigCode<JmxConnector>() {
public Object run(JmxConnector param) throws PropertyVetoException {
param.setSsl(null);
return null;
}
}, jmxConnector);
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
} catch (TransactionFailure e) {
reportError(report, e);
}
}
use of org.jvnet.hk2.config.Element in project Payara by payara.
the class ResourceUtil method getResourceLinks.
public static Map<String, String> getResourceLinks(List<Dom> proxyList, UriInfo uriInfo) {
Map<String, String> links = new TreeMap<String, String>();
Collections.sort(proxyList, new DomConfigurator());
for (Dom proxy : proxyList) {
// for each element
try {
links.put(getKey(proxy), getElementLink(uriInfo, getKey(proxy)));
} catch (Exception e) {
throw new RuntimeException(e);
}
}
return links;
}
use of org.jvnet.hk2.config.Element in project Payara by payara.
the class ResourceUtil method getResourceLinks.
public static Map<String, String> getResourceLinks(Dom dom, UriInfo uriInfo, boolean canShowDeprecated) {
Map<String, String> links = new TreeMap<String, String>();
for (String elementName : dom.model.getElementNames()) {
// for each element
if (elementName.equals("*")) {
ConfigModel.Node node = (ConfigModel.Node) dom.model.getElement(elementName);
ConfigModel childModel = node.getModel();
List<ConfigModel> lcm = getRealChildConfigModels(childModel, dom.document);
Collections.sort(lcm, new ConfigModelComparator());
if (lcm != null) {
for (ConfigModel cmodel : lcm) {
if ((!isDeprecated(cmodel) || canShowDeprecated)) {
links.put(cmodel.getTagName(), ProviderUtil.getElementLink(uriInfo, cmodel.getTagName()));
}
}
}
} else {
ConfigModel.Property childElement = dom.model.getElement(elementName);
boolean deprec = false;
if (childElement instanceof ConfigModel.Node) {
ConfigModel.Node node = (ConfigModel.Node) childElement;
deprec = isDeprecated(node.getModel());
}
for (String annotation : childElement.getAnnotations()) {
if (annotation.equals(Deprecated.class.getName())) {
deprec = true;
}
}
if ((!deprec || canShowDeprecated)) {
links.put(elementName, ProviderUtil.getElementLink(uriInfo, elementName));
}
}
}
String beanName = getUnqualifiedTypeName(dom.model.targetTypeName);
for (CommandResourceMetaData cmd : CommandResourceMetaData.getCustomResourceMapping(beanName)) {
links.put(cmd.resourcePath, ProviderUtil.getElementLink(uriInfo, cmd.resourcePath));
}
return links;
}
use of org.jvnet.hk2.config.Element in project Payara by payara.
the class ConfigBeanJMXSupport method descriptor.
public static DescriptorSupport descriptor(final Element e) {
final DescriptorSupport d = new DescriptorSupport();
d.setField(DESC_KIND, Element.class.getName());
d.setField(DESC_KEY, e.key());
d.setField(DESC_REQUIRED, e.required());
d.setField(DESC_REFERENCE, e.reference());
d.setField(DESC_VARIABLE_EXPANSION, e.variableExpansion());
return d;
}
Aggregations