private void validateDeploymentProperties(Properties properties, DeploymentContext context) { String compatProp = properties.getProperty( DeploymentProperties.COMPATIBILITY); if (compatProp != null && !compatProp.equals("v2")) { // this only allowed value for property compatibility is v2 String warningMsg = localStrings.getLocalString("compat.value.not.supported", "{0} is not a supported value for compatibility property.", compatProp); ActionReport subReport = context.getActionReport().addSubActionsReport(); subReport.setActionExitCode(ActionReport.ExitCode.WARNING); subReport.setMessage(warningMsg); context.getLogger().log(Level.WARNING, warningMsg); } }
private void validateDeploymentProperties(Properties properties, DeploymentContext context) { String compatProp = properties.getProperty( DeploymentProperties.COMPATIBILITY); if (compatProp != null && !compatProp.equals("v2")) { // this only allowed value for property compatibility is v2 String warningMsg = localStrings.getLocalString("compat.value.not.supported", "{0} is not a supported value for compatibility property.", compatProp); ActionReport subReport = context.getActionReport().addSubActionsReport(); subReport.setActionExitCode(ActionReport.ExitCode.WARNING); subReport.setMessage(warningMsg); context.getLogger().log(Level.WARNING, warningMsg); } } }
/** * Indicate in the action report a warning message. */ private void warning(AdminCommandContext context, String msg) { ActionReport ar = context.getActionReport().addSubActionsReport(); ar.setActionExitCode(ActionReport.ExitCode.WARNING); ar.setMessage(msg); }
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(); 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) { report.setActionExitCode(ActionReport.ExitCode.FAILURE); report.setMessage(Strings.get("list.instances.badTarget", target)); return; } } StringBuilder sb = new StringBuilder(); 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); }
ActionReport report = context.getActionReport(); if ( ! reportErrorsInTopReport) { report = report.addSubActionsReport(); report.setActionExitCode(ExitCode.WARNING); } else {
private void validateKeepStateOption(DeploymentContext context, DeployCommandParameters params, Application app) { if ((params.keepstate != null && params.keepstate) || app.getKeepState()) { if (!isDASTarget(context, params)) { // for non-DAS target, and keepstate is set to true either // through deployment option or deployment descriptor // explicitly set the deployment option to false params.keepstate = false; String warningMsg = localStrings.getLocalString("not.support.keepstate.in.cluster", "Ignoring the keepstate setting: the keepstate option is only supported in developer profile and not cluster profile."); ActionReport subReport = context.getActionReport().addSubActionsReport(); subReport.setActionExitCode(ActionReport.ExitCode.WARNING); subReport.setMessage(warningMsg); context.getLogger().log(Level.WARNING, warningMsg); } } }
private static void handleRetrieveException(final Exception e, final AdminCommandContext context, final boolean reportErrorsInTopReport) { final String errorMsg = localStrings.getLocalString( "download.errDownloading", "Error while downloading generated files"); final Logger logger = context.getLogger(); logger.log(Level.SEVERE, errorMsg, e); ActionReport report = context.getActionReport(); if ( ! reportErrorsInTopReport) { report = report.addSubActionsReport(); report.setActionExitCode(ExitCode.WARNING); } else { report.setActionExitCode(ExitCode.FAILURE); } report.setMessage(errorMsg); report.setFailureCause(e); }
public void validateExecutorServiceLookupName(AdminCommandContext context, String targetName, String exeLookupName) { if ("concurrent/__defaultManagedExecutorService".equals(exeLookupName)) { return; } try { CommandRunner runner = serviceLocator.getService(CommandRunner.class); ActionReport subReport = context.getActionReport().addSubActionsReport(); CommandRunner.CommandInvocation inv = runner.getCommandInvocation("list-managed-executor-services", subReport, context.getSubject()); ParameterMap params = new ParameterMap(); params.add("target", targetName); inv.parameters(params); inv.execute(); Properties props = subReport.getExtraProperties(); if (props != null) { if (props.get("managedExecutorServices") != null) { List<HashMap<String, String>> map = (List<HashMap<String, String>>) props.get("managedExecutorServices"); for (HashMap<String, String> e : map) { if (e.get("name").equals(exeLookupName)) { return; } } } } throw new GlassFishBatchValidationException("No ExecutorService mapped to " + exeLookupName); } catch (Exception ex) { throw new GlassFishBatchValidationException("Exception during validation: ", ex); } }
public void validateDataSourceLookupName(AdminCommandContext context, String targetName, String dsLookupName) { try { CommandRunner runner = serviceLocator.getService(CommandRunner.class); ActionReport subReport = context.getActionReport().addSubActionsReport(); CommandRunner.CommandInvocation inv = runner.getCommandInvocation("list-jdbc-resources", subReport, context.getSubject()); ParameterMap params = new ParameterMap(); params.add("target", targetName); inv.parameters(params); inv.execute(); Properties props = subReport.getExtraProperties(); if (props != null) { if (props.get("jdbcResources") != null) { List<HashMap<String, String>> map = (List<HashMap<String, String>>) props.get("jdbcResources"); for (HashMap<String, String> e : map) { if (e.get("name").equals(dsLookupName)) { return; } } } } throw new GlassFishBatchValidationException("No DataSource mapped to " + dsLookupName); } catch (Exception ex) { throw new GlassFishBatchValidationException("Exception during validation: ", ex); } }
private Future<InstanceCommandResult> pingInstance() { try { ActionReport aReport = report.addSubActionsReport(); InstanceCommandResult aResult = new InstanceCommandResult(); ParameterMap map = new ParameterMap(); map.set("type", "terse"); InstanceCommandExecutor ice = new InstanceCommandExecutor(habitat, "__locations", FailurePolicy.Error, FailurePolicy.Error, svr, host, port, logger, map, aReport, aResult); return stateService.submitJob(svr, ice, aResult); /* String ret = rac.executeCommand(map).trim(); if (ret == null || (!ret.endsWith("/" + name))) return -1; running = true; String uptimeStr = rac.getAttributes().get("Uptime_value"); return Long.parseLong(uptimeStr); */ } catch (CommandException ex) { running = false; return null; } }
/** * Disable the enabled version of the application if it exists. This method * is used in versioning context. * * @param appName application's name * @param target an option supply from admin command, it's retained for * compatibility with other releases * @param report ActionReport, report object to send back to client. */ public void handleDisable(final String appName, final String target, final ActionReport report) throws VersioningDeploymentSyntaxException { // retrieve the currently enabled version of the application String enabledVersion = getEnabledVersion(appName, target); // invoke disable if the currently enabled version is not itself if (enabledVersion != null && !enabledVersion.equals(appName)) { final ParameterMap parameters = new ParameterMap(); parameters.add("DEFAULT", enabledVersion); parameters.add("target", target); ActionReport subReport = report.addSubActionsReport(); CommandRunner.CommandInvocation inv = commandRunner.getCommandInvocation("disable", subReport); inv.parameters(parameters).execute(); } }
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); } } }
context.getActionReport().addSubActionsReport().setMessage(key);
private void copyActionReportContent(ActionReport source, ActionReport dest) { if (source == null || dest == null) { return; } dest.setActionExitCode(source.getActionExitCode()); dest.setExtraProperties(source.getExtraProperties()); //No deep copy. Any change of source is unexpected copyMessagePart(source.getTopMessagePart(), dest.getTopMessagePart()); List<? extends ActionReport> subReports = source.getSubActionsReport(); if (subReports != null) { for (ActionReport subrep : subReports) { copyActionReportContent(subrep, dest.addSubActionsReport()); } } }
private ActionReport executeInternalCommand(AdminCommandContext context, String targetInstanceName) { String commandName = getCommandName(); ParameterMap params = new ParameterMap(); params.add("target", targetInstanceName); fillParameterMap(params); CommandRunner runner = serviceLocator.getService(CommandRunner.class); ActionReport subReport = context.getActionReport().addSubActionsReport(); CommandRunner.CommandInvocation inv = runner.getCommandInvocation(commandName, subReport, context.getSubject()); inv.parameters(params); inv.execute(); return subReport; }
private void displayAppScopedResources(String applicationName, ActionReport report, ActionReport.MessagePart part) { Application application = null; List<Application> applications = domain.getApplicationsInTarget(target); for (Application app : applications) { if (app.getName().equals(applicationName)) { application = app; } } if (application != null) { ActionReport subReport = report.addSubActionsReport(); CommandRunner.CommandInvocation inv = commandRunner.getCommandInvocation("_list-resources", subReport); final ParameterMap parameters = new ParameterMap(); parameters.add("appname", application.getName()); inv.parameters(parameters).execute(); ActionReport.MessagePart subPart = subReport.getTopMessagePart(); for (ActionReport.MessagePart cp: subPart.getChildren()) { ActionReport.MessagePart resourcesChildPart = part.addChild(); resourcesChildPart.setMessage(cp.getMessage()); } } }
commandParams.origin = DeployCommandParameters.Origin.load; ActionReport subReport = report.addSubActionsReport(); ReadableArchive archive = null;
private void displaySubComponents(String appName, ActionReport report, ActionReport.MessagePart part) { ActionReport subReport = report.addSubActionsReport(); CommandRunner.CommandInvocation inv = commandRunner.getCommandInvocation("list-sub-components", subReport); final ParameterMap parameters = new ParameterMap(); parameters.add("DEFAULT", appName); parameters.add("terse", "true"); parameters.add("resources", resources.toString()); inv.parameters(parameters).execute(); ActionReport.MessagePart subPart = subReport.getTopMessagePart(); for (ActionReport.MessagePart childPart: subPart.getChildren()) { ActionReport.MessagePart actualChildPart = part.addChild(); actualChildPart.setMessage(" " + childPart.getMessage()); for(ActionReport.MessagePart grandChildPart : childPart.getChildren()){ actualChildPart.addChild().setMessage(grandChildPart.getMessage()); } } }
ActionReport subReport = report.addSubActionsReport();