/** * creates a new send an email sla action * * @param from * @param subject * @param body * @return */ public static SLAAction newEmailAction(String from, String subject, String body) { SLAAction r = new SLAAction(); r.setImplementingClassName("org.miloss.fgsms.sla.actions.EmailAlerter"); if (!stringIsNullOrEmpty(from)) { r.getParameterNameValue().add(newNameValuePair("From", from, false, false)); } r.getParameterNameValue().add(newNameValuePair("Body", body, false, false)); r.getParameterNameValue().add(newNameValuePair("Subject", subject, false, false)); return r; }
if (Utility.stringIsNullOrEmpty(action.get(i).getImplementingClassName())) { ref.set(ref.get() + " action class name is not defined"); return false; cmd.setString(1, action.get(i).getImplementingClassName()); cmd.setString(2, "SLA_ACTION"); rs = cmd.executeQuery(); ref.set(ref.get() + " The specified action, class name=" + action.get(i).getImplementingClassName() + " is not registered"); return false; Class<SLAActionInterface> forName = (Class<SLAActionInterface>) Class.forName(action.get(i).getImplementingClassName()); SLAActionInterface newInstance = forName.newInstance(); if (!newInstance.GetAppliesTo().contains(pol.getPolicyType())) { ref.set(ref.get() + " The specified action, class name=" + action.get(i).getImplementingClassName() + " does not apply to the policy type of " + pol.getPolicyType().value()); return false; return newInstance.ValidateConfiguration(action.get(i).getParameterNameValue(), ref); } catch (Exception ex) { ref.set(ref.get() + " The specified action, class name=" + action.get(i).getImplementingClassName() + " could not be loaded, " + ex.getMessage()); return false;
String command = null; String runat = null; NameValuePair nvcommand = Utility.getNameValuePairByName(slaActionRunScript.getParameterNameValue(), "From"); if (nvcommand != null) { if (nvcommand.isEncrypted()) { NameValuePair nvrunat = Utility.getNameValuePairByName(slaActionRunScript.getParameterNameValue(), "From"); if (nvrunat != null) { if (nvrunat.isEncrypted()) { NameValuePair nvpath = Utility.getNameValuePairByName(slaActionRunScript.getParameterNameValue(), "From"); if (nvpath != null) { if (nvpath.isEncrypted()) {
/** * renders an action set as a user readable html string, occurs when * editing existing slas * * @param items * @return */ public static String BuildSLAAction(List<SLAAction> items, PCS pcs, SecurityWrapper c) { String s = ""; for (int i = 0; i < items.size(); i++) { if (items.get(i) instanceof SLAAction) { GetPluginInformationResponseMsg GetPluginInfo = GetPluginInfo(items.get(i).getImplementingClassName(), "SLA_ACTION", pcs, c); if (GetPluginInfo == null) { s += "Unknown SLA Action<br>"; } else { s += GetPluginInfo.getDisplayName() + "<br>"; } } } return s; }
/** * Create an instance of {@link SLAAction } * */ public SLAAction createSLAAction() { return new SLAAction(); }
NameValuePair nvpConnectionURL = Utility.getNameValuePairByName(alert.getSlaActionBaseType().getParameterNameValue(), "ConnectionURL"); String url = null; if (nvpConnectionURL != null) {
/** * used on manage.jsp to render SLA info in the tab'd box * * @param item * @return */ public static String BuildSLASingleAction(SLAAction item, PCS pcs, SecurityWrapper c) { String s = ""; GetPluginInformationResponseMsg GetPluginInfo = GetPluginInfo(item.getImplementingClassName(), "SLA_ACTION", pcs, c); if (GetPluginInfo == null) { return "Unknown SLA Action"; } return GetPluginInfo.getDisplayName(); }
return null; action = new SLAAction(); action.setImplementingClassName(s); GetPluginInformationResponseMsg plugin = GetPluginInfo(s, "SLA_ACTION", pcs, c); for (int i = 0; i < plugin.getRequiredParameter().size(); i++) { nvp.setEncryptOnSave(Boolean.parseBoolean(request.getParameter("p_enc_" + plugin.getRequiredParameter().get(i).getName() + ENCRYPTONSAVE))); nvp.setEncryptOnSave(Boolean.parseBoolean(request.getParameter(PARAMETER_PREFIX + plugin.getRequiredParameter().get(i).getName() + ISENCRYPTED))); action.getParameterNameValue().add(nvp); nvp.setEncryptOnSave(Boolean.parseBoolean(request.getParameter(PARAMETER_PREFIX + plugin.getOptionalParameter().get(i).getName() + ISENCRYPTED))); action.getParameterNameValue().add(nvp);
log.debug("Processing alert for " + alert.getModifiedurl() + " msg " + alert.getFaultMsg() + " class " + alert.getSlaActionBaseType().getImplementingClassName()); Class c = null; try { c = Thread.currentThread().getContextClassLoader().loadClass(alert.getSlaActionBaseType().getImplementingClassName()); } catch (ClassNotFoundException ex) { c = this.getClass().getClassLoader().loadClass(alert.getSlaActionBaseType().getImplementingClassName()); } catch (ClassNotFoundException ex) { c = Class.forName(alert.getSlaActionBaseType().getImplementingClassName()); } catch (ClassNotFoundException ex) { log.error("Error to Load class for SLA Alert!!!" + alert.getSlaActionBaseType().getImplementingClassName()); } else { try { Object j = c.newInstance(); SLAActionInterface item = (SLAActionInterface) j; item.ProcessAction(alert, alert.getSlaActionBaseType().getParameterNameValue()); } catch (Exception ex) { log.error("Error unable to process SLA Alert!!!", ex);
NameValuePair nvpdestinationOverride = Utility.getNameValuePairByName(alert.getSlaActionBaseType().getParameterNameValue(), "destinationOverride"); NameValuePair nvpisTopicOverride = Utility.getNameValuePairByName(alert.getSlaActionBaseType().getParameterNameValue(), "isTopicOverride"); NameValuePair nvpConnectionURL = Utility.getNameValuePairByName(alert.getSlaActionBaseType().getParameterNameValue(), "ConnectionURL"); NameValuePair nvpusername = Utility.getNameValuePairByName(alert.getSlaActionBaseType().getParameterNameValue(), "username"); NameValuePair nvppassword = Utility.getNameValuePairByName(alert.getSlaActionBaseType().getParameterNameValue(), "password"); String url = null; String uname = null;
/** * does this action list contain an email SLA * * @param pc * @return */ public static boolean hasEmailSLA(ArrayOfSLAActionBaseType pc) { if (pc == null) { return false; } if (pc.getSLAAction().isEmpty()) { return false; } for (int i = 0; i < pc.getSLAAction().size(); i++) { if (pc.getSLAAction().get(i).getImplementingClassName().equals("org.miloss.fgsms.sla.actions.EmailAlerter")) { return true; } } return false; }
SLAAction newaction = new SLAAction(); while (em2.hasMoreElements()) { String key2 = (String) em2.nextElement(); newaction.setImplementingClassName(request.getParameter(key2)); } else if (bits2[4].equalsIgnoreCase("enc")) { boolean found = false; boolean enc = value.equalsIgnoreCase("true") || value.equalsIgnoreCase("on"); for (int kk = 0; kk < newaction.getParameterNameValue().size(); kk++) { if (newaction.getParameterNameValue().get(kk).getName().equalsIgnoreCase(bits2[5])) { newaction.getParameterNameValue().get(kk).setEncrypted(enc); found = true; break; nvp.setName(bits2[5]); nvp.setEncrypted(enc); newaction.getParameterNameValue().add(nvp); for (int kk = 0; kk < newaction.getParameterNameValue().size(); kk++) { if (newaction.getParameterNameValue().get(kk).getName().equalsIgnoreCase(bits2[5])) { newaction.getParameterNameValue().get(kk).setEncryptOnSave(enc); found = true; break; nvp.setName(bits2[5]); nvp.setEncryptOnSave(enc); newaction.getParameterNameValue().add(nvp); for (int kk = 0; kk < newaction.getParameterNameValue().size(); kk++) {
private static void SendLogger(String msg, SLAAction logAction, String url, String incident) { if (logAction != null) { NameValuePair GetNameValuePairByName = Utility.getNameValuePairByName(logAction.getParameterNameValue(), "Logger"); if (GetNameValuePairByName != null) { Logger l = null; if (GetNameValuePairByName.isEncrypted()) { l = Logger.getLogger(Utility.DE(GetNameValuePairByName.getValue())); } else { l = Logger.getLogger((GetNameValuePairByName.getValue())); } l.log(Level.WARN, SLACommon.getBundleString("SLALoggerPrefix") + url + " message: " + msg.toString() + " SLAFaultID: " + incident); } } else { log.warn("log action is null, defaulting"); log.log(Level.WARN, SLACommon.getBundleString("SLALoggerPrefix") + url + " message: " + msg.toString() + " SLAFaultID: " + incident); } }
/** * does this policy have an email sla action? * * @param pc * @return */ public static boolean hasEmailSLA(ServicePolicy pc) { if (pc == null) { return false; } if (pc.getServiceLevelAggrements() == null || pc.getServiceLevelAggrements().getSLA().isEmpty()) { return false; } for (int i = 0; i < pc.getServiceLevelAggrements().getSLA().size(); i++) { if (pc.getServiceLevelAggrements().getSLA().get(i).getAction() != null && !pc.getServiceLevelAggrements().getSLA().get(i).getAction().getSLAAction().isEmpty()) { for (int k = 0; k < pc.getServiceLevelAggrements().getSLA().get(i).getAction().getSLAAction().size(); k++) { if (pc.getServiceLevelAggrements().getSLA().get(i).getAction().getSLAAction().get(k).getImplementingClassName().equals("org.miloss.fgsms.sla.actions.EmailAlerter")) { return true; } } } } return false; }
NameValuePair nvpdestinationOverride = Utility.getNameValuePairByName(alert.getSlaActionBaseType().getParameterNameValue(), "destinationOverride"); NameValuePair nvpisTopicOverride = Utility.getNameValuePairByName(alert.getSlaActionBaseType().getParameterNameValue(), "isTopicOverride"); NameValuePair nvpConnectionURL = Utility.getNameValuePairByName(alert.getSlaActionBaseType().getParameterNameValue(), "ConnectionURL"); NameValuePair nvpusername = Utility.getNameValuePairByName(alert.getSlaActionBaseType().getParameterNameValue(), "username"); NameValuePair nvppassword = Utility.getNameValuePairByName(alert.getSlaActionBaseType().getParameterNameValue(), "password"); String destinationOverride = null; boolean isTopicOverride = false;
/** * * @param action * @param pcs * @param c * @param item_type FEDERATION_PUBLISH,SLA_RULE,SLA_ACTION * @return html escaped friendly name of the plugin */ public static String ToFriendlyName(SLAAction action, PCS pcs, SecurityWrapper c) { if (action == null) { return "Null Action"; } GetPluginInformationRequestMsg req = new GetPluginInformationRequestMsg(); req.setGetPluginInformationRequestWrapper(new GetPluginInformationRequestWrapper()); req.getGetPluginInformationRequestWrapper().setClassification(c); req.getGetPluginInformationRequestWrapper().setPlugin(new Plugin()); req.getGetPluginInformationRequestWrapper().getPlugin().setClassname(action.getImplementingClassName()); req.getGetPluginInformationRequestWrapper().getPlugin().setPlugintype("SLA_ACTION"); GetPluginInformation r = new GetPluginInformation(); r.setRequest(req); try { GetPluginInformationResponse pluginInformation = pcs.getPluginInformation(r); return Utility.encodeHTML(pluginInformation.getResponse().getDisplayName()); } catch (Exception ex) { LogHelper.getLog().error(ex); } return "Unrecognized action, " + Utility.encodeHTML(action.getImplementingClassName()); }
Message simpleMessage = new MimeMessage(mailSession); InternetAddress from; NameValuePair nvfrom = Utility.getNameValuePairByName(email.getParameterNameValue(), "From"); String sfrom = null; if (nvfrom != null) { NameValuePair nvsubject = Utility.getNameValuePairByName(email.getParameterNameValue(), "Subject"); String subject = nvsubject.getValue(); if (nvsubject.isEncrypted()) { NameValuePair nvbody = Utility.getNameValuePairByName(email.getParameterNameValue(), "Body"); String body = nvbody.getValue(); if (nvbody.isEncrypted()) {
/** * * @param action * @param pcs * @param c * @param item_type FEDERATION_PUBLISH,SLA_RULE,SLA_ACTION * @return */ public static String GetPluginHelp(SLAAction action, PCS pcs, SecurityWrapper c, String item_type) { if (action == null) { return "Null Action"; } GetPluginInformationRequestMsg req = new GetPluginInformationRequestMsg(); req.setGetPluginInformationRequestWrapper(new GetPluginInformationRequestWrapper()); req.getGetPluginInformationRequestWrapper().setClassification(c); req.getGetPluginInformationRequestWrapper().setPlugin(new Plugin()); req.getGetPluginInformationRequestWrapper().getPlugin().setClassname(action.getImplementingClassName()); req.getGetPluginInformationRequestWrapper().getPlugin().setPlugintype(item_type); GetPluginInformation r = new GetPluginInformation(); r.setRequest(req); try { GetPluginInformationResponse pluginInformation = pcs.getPluginInformation(r); return pluginInformation.getResponse().getHelp(); } catch (Exception ex) { LogHelper.getLog().error(ex); } return "No help information could be found."; }
String BrokerURL = null; NameValuePair nvpRegisterPublisher = Utility.getNameValuePairByName(alert.getSlaActionBaseType().getParameterNameValue(), "RegisterPublisher"); NameValuePair nvpBrokerURL = Utility.getNameValuePairByName(alert.getSlaActionBaseType().getParameterNameValue(), "BrokerURL"); NameValuePair nvpdialect = Utility.getNameValuePairByName(alert.getSlaActionBaseType().getParameterNameValue(), "dialect"); NameValuePair nvpDestination = Utility.getNameValuePairByName(alert.getSlaActionBaseType().getParameterNameValue(), "Destination"); NameValuePair nvpusername = Utility.getNameValuePairByName(alert.getSlaActionBaseType().getParameterNameValue(), "username"); NameValuePair nvppassword = Utility.getNameValuePairByName(alert.getSlaActionBaseType().getParameterNameValue(), "password"); if (nvpRegisterPublisher != null) { if (nvpRegisterPublisher.isEncrypted()) {