protected Config getConfigForName(String targetName, ServiceLocator serviceLocator, Domain domain) { if (CommandTarget.CONFIG.isValid(serviceLocator, targetName)) { return domain.getConfigNamed(targetName); } if (CommandTarget.DAS.isValid(serviceLocator, targetName) || CommandTarget.STANDALONE_INSTANCE.isValid(serviceLocator, targetName)) { Server s = domain.getServerNamed(targetName); return s == null ? null : domain.getConfigNamed(s.getConfigRef()); } if (CommandTarget.CLUSTER.isValid(serviceLocator, targetName)) { Cluster cl = domain.getClusterNamed(targetName); return cl == null ? null : domain.getConfigNamed(cl.getConfigRef()); } return null; }
private boolean isResourceExists(String jndiName) { //resource-ref is created only for a BindableResource return domain.getResources().getResourceByName(BindableResource.class, jndiName) != null; } }
public static Config getConfigNamed(Domain d, String name) { if (d.getConfigs() == null || name == null) throw new IllegalArgumentException ("no <config> element"); List<Config> configs = d.getConfigs().getConfig(); for (Config c : configs) { if (name.equals(c.getName().trim())) { return c; } } return null; }
public PropertyResolver(Domain domain, String instanceName) { _domain = domain; _server = _domain.getServerNamed(instanceName); if (_server != null) { _config = _domain.getConfigNamed(_server.getConfigRef()); } else { _config = _domain.getConfigNamed(instanceName); } _cluster = _domain.getClusterForInstance(instanceName); }
private Config getConfigForName(String name) { if (domain.getConfigNamed(name) != null) return domain.getConfigNamed(name); if (domain.getServerNamed(name) != null) return domain.getServerNamed(name).getConfig(); return null; } }
/** * Returns config element that represents a given server * @param targetName the name of the target * @return Config element representing the server instance */ public Config getServerConfig(String targetName) { Server s = domain.getServerNamed(targetName); if(s == null) return null; return domain.getConfigNamed(s.getConfigRef()); }
/** * 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(); try { Collection<JdbcConnectionPool> connPools = domain.getResources().getResources(JdbcConnectionPool.class); for (JdbcConnectionPool pool : connPools) { final ActionReport.MessagePart part = report.getTopMessagePart().addChild(); part.setMessage(pool.getName()); } } catch (Exception e) { report.setMessage(localStrings.getLocalString("list.jdbc.connection.pools.failed", "List JDBC connection pools failed")); report.setActionExitCode(ActionReport.ExitCode.FAILURE); report.setFailureCause(e); return; } report.setActionExitCode(ActionReport.ExitCode.SUCCESS); } }
final ActionReport report = context.getActionReport(); Config targetConfig = domain.getConfigNamed(target); if (targetConfig != null) config = targetConfig; Server targetServer = domain.getServerNamed(target); config = domain.getConfigNamed(targetServer.getConfigRef()); com.sun.enterprise.config.serverbeans.Cluster cluster =domain.getClusterNamed(target); if (cluster!=null) { config = domain.getConfigNamed(cluster.getConfigRef()); JmsService jmsService = config.getExtensionByType(JmsService.class); report.setMessage(localStrings.getLocalString("list.jms.host.invalidTarget", "Invalid Target specified.")); report.setActionExitCode(ActionReport.ExitCode.FAILURE); return; final ActionReport.MessagePart part = report.getTopMessagePart().addChild(); part.setMessage(jmsName); report.setMessage(localStrings.getLocalString("list.jms.host.fail", "Unable to list JMS Hosts") + " " + e.getLocalizedMessage()); report.setActionExitCode(ActionReport.ExitCode.FAILURE);
final ActionReport report = context.getActionReport(); Server targetServer = domain.getServerNamed(target); config = domain.getConfigNamed(targetServer.getConfigRef()); com.sun.enterprise.config.serverbeans.Cluster cluster =domain.getClusterNamed(target); if (cluster!=null) { config = domain.getConfigNamed(cluster.getConfigRef()); JmsService jmsservice = config.getExtensionByType(JmsService.class); ActionReport subReport = report.addSubActionsReport(); createJMSResource(defaultJmsHost, subReport, tmpJMSResource, context.getSubject()); if (ActionReport.ExitCode.FAILURE.equals(subReport.getActionExitCode())){ report.setMessage(localStrings.getLocalString("jms-ping.cannotCreateJMSResource", "Unable to create a temporary Connection Factory to the JMS Host")); report.setActionExitCode(ActionReport.ExitCode.FAILURE); report.setActionExitCode(ActionReport.ExitCode.FAILURE); deleteJMSResource(subReport, tmpJMSResource, context.getSubject()); if (ActionReport.ExitCode.FAILURE.equals(subReport.getActionExitCode())){ report.setMessage(localStrings.getLocalString("jms-ping.cannotdeleteJMSResource",
@Override public void execute(AdminCommandContext context) { final ActionReport report = context.getActionReport(); Config tmp = null; try { tmp = configs.getConfigByName(target); } catch (Exception ex) { } if (tmp != null) { config = tmp; } if (tmp == null) { Server targetServer = domain.getServerNamed(target); 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()); } } final SecurityService securityService = config.getSecurityService(); List<JaccProvider> jaccProviders = securityService.getJaccProvider(); JaccProvider jprov = null; for (JaccProvider jaccProv : jaccProviders) { ActionReport.MessagePart part = report.getTopMessagePart().addChild(); part.setMessage(jaccProv.getName()); } report.setActionExitCode(ActionReport.ExitCode.SUCCESS); }
final ActionReport report = context.getActionReport(); Server targetServer = domain.getServerNamed(target); 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()); SecurityService securityService = config.getSecurityService(); for (AuthRealm authrealm : authrealms) { if (authrealm.getName().equals(authRealmName)) { report.setMessage(localStrings.getLocalString( "create.auth.realm.duplicatefound", "Authrealm named {0} exists. Cannot add duplicate AuthRealm.", authRealmName)); report.setActionExitCode(ActionReport.ExitCode.FAILURE); return; report.setMessage(localStrings.getLocalString("create.auth.realm.fail", "Creation of Authrealm {0} failed", authRealmName) + " " + e.getLocalizedMessage() );
public void execute(AdminCommandContext context) { final ActionReport report = context.getActionReport(); ActionReport.MessagePart part = report.getTopMessagePart(); Server server = domain.getServerNamed(target); if (server != null) { configName = server.getConfigRef(); } else { Cluster cluster = domain.getClusterNamed(target); if (cluster == null) { throw new Exception("No such target:" + target); configName = cluster.getConfigRef(); httpService = config.getHttpService(); report.setMessage(e.getMessage()); report.setActionExitCode(ActionReport.ExitCode.FAILURE); return;
final ActionReport report = context.getActionReport(); if (server.isResourceRefExists(refName)) { server.deleteResourceRef(refName); }else{ setResourceRefDoNotExistMessage(report); Cluster cluster = domain.getClusterNamed(target); if (cluster.isResourceRefExists(refName)) { cluster.deleteResourceRef(refName); }else{ setResourceRefDoNotExistMessage(report); List<Server> instances = tgt.getInstances(target); for (Server svr : instances) { svr.deleteResourceRef(refName); return; report.setActionExitCode(ActionReport.ExitCode.SUCCESS); report.setMessage(localStrings.getLocalString("delete.resource.ref.success", "resource-ref {0} deleted successfully.", refName));
public void execute(AdminCommandContext context) { ActionReport report = context.getActionReport(); report.setActionExitCode(ActionReport.ExitCode.SUCCESS); List<Config> configList = null; //Fix for issue 13356 list-configs doesn't take an operand //defaults to domain if (target.equals("domain" )) { Configs configs = domain.getConfigs(); configList = configs.getConfig(); } else { configList = createConfigList(); if (configList == null) { fail(Strings.get("list.instances.badTarget", target)); return; } } StringBuffer sb = new StringBuffer(); for (Config config : configList) { sb.append(config.getName()).append('\n'); } String output = sb.toString(); //Fix for isue 12885 report.addSubActionsReport().setMessage(output.substring(0,output.length()-1 )); report.setActionExitCode(ActionReport.ExitCode.SUCCESS); }
public void execute(AdminCommandContext context) { ActionReport report = context.getActionReport(); if (domain.getApplications().getApplication(appName) == null) { report.setActionExitCode(ActionReport.ExitCode.FAILURE); report.setMessage("No such application [" + appName + "] is deployed"); return; } ServiceDescription desc = orchestrator.getServiceDescription(appName, service); if (desc == null) { report.setMessage("Service by name [" + service + " ] does not exist for the given application [" + appName + " ]"); report.setActionExitCode(ActionReport.ExitCode.FAILURE); return; } Map<String, Object> descMap = getServiceDescriptionMap(desc); Properties extraProperties = new Properties(); extraProperties.put("list", descMap); report.setExtraProperties(extraProperties); report.setActionExitCode(ActionReport.ExitCode.SUCCESS); }
public Set<String> getTargetsReferringResourceRef(String refName) { Set<String> targets = new HashSet<String>(); List<Server> servers = domain.getServers().getServer(); for(Server server: servers){ if(server.getResourceRef(refName) != null){ if(server.getCluster() != null){ targets.add(server.getCluster().getName()); }else if(server.isDas()){ targets.add(SystemPropertyConstants.DAS_SERVER_NAME); }else if(server.isInstance()){ targets.add(server.getName()); } } } return targets; }
public static List<String> getAllTargets(Domain d) { List<String> targets = new ArrayList<String>(); // only add non-clustered servers as the cluster // targets will be separately added for (Server server : d.getServers().getServer()) { if (server.getCluster() == null) { targets.add(server.getName()); } } if (d.getClusters() != null) { for (Cluster cluster : d.getClusters().getCluster()) { targets.add(cluster.getName()); } } return targets; }
ServerPorts(Domain domain, Server theServer) { Cluster cluster = null; Config config = null; if (theServer.isInstance()) cluster = domain.getClusterForInstance(theServer.getName()); String configName = theServer.getConfigRef(); if (StringUtils.ok(configName)) config = domain.getConfigNamed(configName); initialize(cluster, config, domain, theServer); }
public void validateSpecifiedTarget(String target) { if (env.isDas()) { if (target == null) { // we only validate the specified target return; } Cluster cluster = domain.getClusterNamed(target); if (cluster != null) { if (cluster.isVirtual()) { throw new IllegalArgumentException(localStrings.getLocalString("cannot_specify_managed_target", "Cannot specify target {0} for the operation. Target {0} is a managed target.", target)); } } } }
public void execute(AdminCommandContext context) { final ActionReport report = context.getActionReport(); ActionReport.MessagePart part = report.getTopMessagePart(); List<String> targets = null; if (appName == null || appName.equals("*")) { targets = domain.getAllTargets(); } else { targets = domain.getAllReferencedTargetsForApplication(appName); } for (String target : targets) { ActionReport.MessagePart childPart = part.addChild(); childPart.setMessage(target); } } }