public void execute(AdminCommandContext context) { final ActionReport report = context.getActionReport(); report.setMessage(localStrings.getLocalString("admin.mbeans.rmb.invalid_jms_desttype", destType)); report.setActionExitCode(ActionReport.ExitCode.FAILURE); return; report.setExtraProperties(new Properties()); List<Map> jmsDestList = new ArrayList<Map>(); final ActionReport.MessagePart part = report.getTopMessagePart().addChild(); part.setMessage(destInfo.getDestinationName()); Map<String, String> destMap = new HashMap<String, String>(); destMap.put("name", destInfo.getDestinationName()); report.getExtraProperties().put("destinations", jmsDestList); report.setMessage(localStrings.getLocalString("list.jms.dest.fail", "Unable to list JMS Destinations. Please ensure that the Message Queue Brokers are running"));// + " " + e.getLocalizedMessage()); report.setActionExitCode(ActionReport.ExitCode.FAILURE);
private void noStatus(List<Server> serverList) { if (serverList.size() < 1) { report.setMessage(NONE); return; Properties extraProps = new Properties(); List instanceList = new ArrayList(); top.addProperty(name, ""); HashMap<String, Object> insDetails = new HashMap<String, Object>(); insDetails.put("name", name); extraProps.put("instanceList", instanceList); report.setMessage(sb.toString()); report.setExtraProperties(extraProps);
final ActionReport report = context.getActionReport(); report.setMessage(localStrings.getLocalString("FileNotFound", "The system cannot find the path specified: {0}", xmlFile.getName())); report.setActionExitCode(ActionReport.ExitCode.FAILURE); return; domain.getResources(), xmlFile, target, resourceFactory); final Iterator resultsIter = results.iterator(); report.getTopMessagePart().setChildrenType("Command"); boolean isSuccess = false; while (resultsIter.hasNext()) { final String msgToAdd = rs.getMessage(); if ((msgToAdd != null) && (!msgToAdd.equals(""))) { final ActionReport.MessagePart part = report.getTopMessagePart().addChild(); part.setMessage(msgToAdd); (isSuccess)?ActionReport.ExitCode.SUCCESS:ActionReport.ExitCode.FAILURE); if (!isSuccess) report.setMessage(localStrings.getLocalString("add.resources.failed", "add-resources <{0}> failed", xmlFile.getName())); report.setMessage(localStrings.getLocalString("add.resources.failed", "add-resources <{0}> failed", xmlFile.getName())); report.setActionExitCode(ActionReport.ExitCode.FAILURE);
final ActionReport report = context.getActionReport(); final Logger logger = context.getLogger(); } catch (VersioningWildcardException ex) { report.setMessage(localStrings.getLocalString("application.notreg", "Application {0} not registered", name)); report.setMessage(localStrings.getLocalString("ref.not.referenced.target","Application {0} is not referenced by target {1}", name, target)); Application app = applications.getApplication(appName); ApplicationRef applicationRef = domain.getApplicationRefInTarget(appName, target); if ( applicationRef != null ) { ActionReport.MessagePart childPart = part.addChild(); childPart.setMessage(localStrings.getLocalString("appref.already.exists", "Application reference {0} already exists in target {1}.", appName, target)); } else { appProps.putAll(contextProps); appProps.setProperty(ServerTags.LOCATION, location); if (domain.isCurrentInstanceMatchingTarget(target, appName, server.getName(), null)) { deployment.deploy(deployment.getSniffersFromApp(app), deploymentContext); } else {
ActionReport.MessagePart part = report.getTopMessagePart(); part.addProperty(DeploymentProperties.NAME, name); versioningService.handleDisable(name,target, report, context.getSubject()); } catch (VersioningSyntaxException e) { report.failure(logger, e.getMessage()); return; if (!force && versionFromSameDir != null) { report.failure(logger, VersioningUtils.LOCALSTRINGS.getLocalString( "versioning.deployment.dual.inplace", "GlassFish do not support versioning for directory deployment when using the same directory. The directory {0} is already assigned to the version {1}.", deploymentContext.getAppProps().putAll(undeployProps); properties = new Properties(); properties.putAll(property); archive.close(); } catch(IOException e) { logger.log(Level.FINE, localStrings.getLocalString( "errClosingArtifact", "Error while closing deployable artifact : ",
public void execute(AdminCommandContext context) { ActionReport report = context.getActionReport(); report.setActionExitCode(ActionReport.ExitCode.SUCCESS); ActionReport.MessagePart mp = report.getTopMessagePart(); Properties extraProperties = new Properties(); Map<String, Object> entity = new HashMap<String, Object>(); mp.setMessage(Boolean.toString(ucl.serverRequiresRestart())); entity.put("restartRequired", Boolean.toString(ucl.serverRequiresRestart())); List<String> unprocessedChanges = new ArrayList<String>(); for (UnprocessedChangeEvents es : ucl.getUnprocessedChangeEvents()) { for (UnprocessedChangeEvent e : es.getUnprocessed()) { if (why) { mp.addChild().setMessage(e.getReason()); } unprocessedChanges.add(e.getReason()); } } if (!unprocessedChanges.isEmpty()) { entity.put("unprocessedChanges", unprocessedChanges); } extraProperties.put("entity", entity); ((ActionReport) report).setExtraProperties(extraProperties); } }
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); report.setMessage(localStrings.getLocalString( "list.file.user.filerealmnotfound", "File realm {0} does not exist", authRealmName)); report.setActionExitCode(ActionReport.ExitCode.FAILURE); return; localStrings.getLocalString("list.file.user.keyfilenotfound", "There is no physical file associated with this file realm {0} ", authRealmName)); final ActionReport.MessagePart part = report.getTopMessagePart().addChild(); String userName = (String) users.nextElement(); part.setMessage(userName); Map userMap = new HashMap(); userMap.put("name", userName); Properties extraProperties = new Properties(); extraProperties.put("users", userList);
private void fillEndpoints(ActionReport report, Map<String, Map<String, Map<String, DeployedEndpointData>>> endpoints) { if (!endpoints.isEmpty()) { Properties extra = new Properties(); extra.putAll(endpoints); report.setExtraProperties(extra); ActionReport.MessagePart top = report.getTopMessagePart(); for(Map.Entry<String, Map<String, Map<String, DeployedEndpointData>>> app : endpoints.entrySet()) { ActionReport.MessagePart child = top.addChild(); child.setMessage("application:"+app.getKey()); for(Map.Entry<String, Map<String, DeployedEndpointData>> module : app.getValue().entrySet()) { child = child.addChild(); child.setMessage(" module:"+module.getKey()); for(Map.Entry<String, DeployedEndpointData> endpoint : module.getValue().entrySet()) { child = child.addChild(); child.setMessage(" endpoint:"+endpoint.getKey()); for(Map.Entry<String, String> endpointData : endpoint.getValue().getStaticAsMap().entrySet()) { child = child.addChild(); child.setMessage(" "+endpointData.getKey()+":"+endpointData.getValue()); } } } } } }
public static void fillActionReport(final ActionReport ar, final JSONObject json) throws JSONException { ar.setActionExitCode(ActionReport.ExitCode.valueOf(json.getString("exit_code"))); ar.setActionDescription(json.optString("command")); String failure = json.optString("failure_cause"); if (failure != null && !failure.isEmpty()) { ar.setFailureCause(new Exception(failure)); } ar.setExtraProperties((Properties) extractMap(json.optJSONObject("extraProperties"), new Properties())); ar.getTopMessagePart().setMessage(json.optString("top_message", json.optString("message"))); Properties props = (Properties) extractMap(json.optJSONObject("properties"), new Properties()); for (Map.Entry entry : props.entrySet()) { ar.getTopMessagePart().addProperty(String.valueOf(entry.getKey()), String.valueOf(entry.getValue())); } //Sub messages fillSubMessages(ar.getTopMessagePart(), json.optJSONArray("children")); //Sub action reports JSONArray subJsons = json.optJSONArray("subReports"); if (subJsons != null) { for (int i = 0; i < subJsons.length(); i++) { JSONObject subJson = subJsons.getJSONObject(i); fillActionReport(ar.addSubActionsReport(), subJson); } } }
private static void fillSubMessages(final ActionReport.MessagePart mp, final JSONArray json) throws JSONException { if (json == null) { return; } for (int i = 0; i < json.length(); i++) { JSONObject subJson = json.getJSONObject(i); MessagePart child = mp.addChild(); child.setMessage(subJson.optString("message")); Properties props = (Properties) extractMap(subJson.optJSONObject("properties"), new Properties()); for (Map.Entry entry : props.entrySet()) { child.addProperty(String.valueOf(entry.getKey()), String.valueOf(entry.getValue())); } fillSubMessages(child, subJson.optJSONArray("children")); } }
@Override public void execute(AdminCommandContext context) { report = context.getActionReport(); report.setActionExitCode(SUCCESS); top = report.getTopMessagePart(); logger = context.getLogger(); javaEnabledOnCmd = Boolean.parseBoolean(ctx.getArguments().getProperty("-debug")); javaConfig = config.getJavaConfig(); jpdaEnabled = javaEnabledOnCmd || Boolean.parseBoolean(javaConfig.getDebugEnabled()); int debugPort = parsePort(javaConfig.getDebugOptions()); top.addProperty("debug", Boolean.toString(jpdaEnabled)); top.addProperty("debugPort", Integer.toString(debugPort)); final OperatingSystemMXBean osBean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); top.addProperty("os.arch", osBean.getArch()); top.addProperty("os.name", osBean.getName()); top.addProperty("os.version", osBean.getVersion()); top.addProperty("availableProcessorsCount", "" + osBean.getAvailableProcessors()); top.addProperty("totalPhysicalMemorySize", "" + jm.invoke(osBean)); top.addProperty("startTimeMillis", "" + rmxb.getStartTime()); top.addProperty("pid", "" + rmxb.getName()); checkDtrace(); setDasName(); top.addProperty("java.vm.name", System.getProperty("java.vm.name")); setRestartable(); reportMessage.append(Strings.get("runtime.info.debug", jpdaEnabled ? "enabled" : "not enabled")); report.setMessage(reportMessage.toString());
|| (res.getReport().getActionExitCode() != ActionReport.ExitCode.SUCCESS)) { uptime = -1; state = NOT_RUNNING; Properties props = res.getReport().getTopMessagePart().getProps(); String uptimeStr = props.getProperty("Uptime"); String pidstr = props.getProperty("Pid"); String restartstr = props.getProperty("Restart-Required");
private void writePart(Element actionReport, MessagePart part, String childType) { Document d = actionReport.getOwnerDocument(); Element messagePart = d.createElement("message-part"); actionReport.appendChild(messagePart); if (childType != null) { messagePart.setAttribute("type", childType); } for (Map.Entry prop : part.getProps().entrySet()) { Element p = d.createElement("property"); messagePart.appendChild(p); p.setAttribute("name", prop.getKey().toString()); p.setAttribute("value", prop.getValue().toString()); } messagePart.setAttribute("message", part.getMessage()); for (MessagePart subPart : part.getChildren()) writeSubPart(messagePart, subPart, subPart.getChildrenType()); }
getCombinedMessages(this, sb); attr.putValue("message", sb.toString()); if (part.getProps().size() > 0) { String keys = null; for (Map.Entry entry : part.getProps().entrySet()) { String key = fixKey(entry.getKey().toString()); keys = (keys == null ? key : keys + ";" + key); if (part.getChildren().size() > 0) { attr.putValue("children-type", part.getChildrenType()); attr.putValue("use-main-children-attribute", "true"); StringBuilder keys = null; for (MessagePart child : part.getChildren()) { String cm = child.getMessage(); if (cm != null) { try {
@Override public Collection<String> getDeployedApplications() throws GlassFishException { try { CommandExecutorImpl executer = habitat.getComponent(CommandExecutorImpl.class); ActionReport report = executer.executeCommand("list-components"); Properties props = report.getTopMessagePart().getProps(); return new ArrayList<String>(props.stringPropertyNames()); } catch (Exception e) { throw new GlassFishException(e); } }
private boolean superSimple(MessagePart part) { // this is mainly here for backward compatability for when this Reporter // only wrote out the main message. List<MessagePart> list = part.getChildren(); Properties props = part.getProps(); boolean hasChildren = (list != null && !list.isEmpty()); boolean hasProps = (props != null && props.size() > 0); // return true if we are very very simple! return !hasProps && !hasChildren; }
logger.fine(adminStrings.getLocalString("dynamicreconfiguration.diagnostics.delegatedcommand", "This command is a delegated command. Dynamic reconfiguration will be bypassed")); InjectionResolver<Param> injectionTarget = inv.report().getTopMessagePart().addProperty("MANPAGE", manPage); } else { report.getTopMessagePart().addProperty( AdminCommandResponse.GENERATED_HELP, "true"); getHelp(command, report); report.getTopMessagePart().addChild(); childPart.setMessage(getUsageText(model)); return; if ( ! commandSecurityChecker.authorize(context.getSubject(), env, command, context)) { report.setMessage(adminStrings.getLocalString("commandrunner.noauth", "User is not authorized for this command")); return; && (domain.getServerNamed(targetName) == null) if (!StringUtils.ok(report.getTopMessagePart().getMessage())) { report.getTopMessagePart().addChild(); childPart.setMessage(getUsageText(model)); return;
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); 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);
@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); }
public void execute(AdminCommandContext context) { final ActionReport report = context.getActionReport(); final Logger logger = context.getLogger(); ActionReport.MessagePart part = report.getTopMessagePart(); matchedVersions = versioningService.getMatchedVersions(name, target); } catch (VersioningException e) { report.failure(logger, e.getMessage()); return; report.setMessage(localStrings.getLocalString("ref.not.referenced.target","Application {0} is not referenced by target {1}", name, target)); report.setActionExitCode(ActionReport.ExitCode.FAILURE); return; if (domain.isAppEnabledInTarget(appName, target)) { status = "enabled"; ActionReport.MessagePart childPart = part.addChild(); String message = localStrings.getLocalString("component.status","Status of {0} is {1}.", appName, status); childPart.setMessage(message); childPart.addProperty(DeploymentProperties.STATE, status); report.setActionExitCode(ActionReport.ExitCode.SUCCESS);