Example #1
0
 @Override
 public void addTemplate(CallingContext context, String name, String template, Boolean overwrite) {
   if (templates.containsKey(name) && !templates.get(name).isEmpty() && !overwrite) {
     log.info(Messages.getString("Admin.NoOverwriteTemplate") + name); // $NON-NLS-1$
   } else {
     log.info(
         Messages.getString("Admin.AddingTemplate")
             + name
             + Messages.getString("Admin.Value")
             + template); //$NON-NLS-1$ //$NON-NLS-2$
     templates.put(name, template);
   }
 }
Example #2
0
 @Override
 public String runTemplate(CallingContext context, String name, String params) {
   String template = templates.get(name);
   if (template == null) {
     log.info(
         "Null template execution - "
             + name
             + Messages.getString("Admin.NoExist")); // $NON-NLS-1$ //$NON-NLS-2$
     return null;
   }
   log.info(
       Messages.getString("Admin.RunTemplate")
           + template
           + Messages.getString("Admin.Params")
           + params); //$NON-NLS-1$ //$NON-NLS-2$
   String ret = TemplateF.parseTemplate(template, params);
   log.info(Messages.getString("Admin.TemplateOutput") + ret); // $NON-NLS-1$
   return ret;
 }
Example #3
0
  @Override
  public void addMetadata(CallingContext context, Map<String, String> values, Boolean overwrite) {
    if ((values == null) || values.isEmpty()) return;

    Map<String, String> metadata = context.getMetadata();
    if (metadata == null) metadata = new HashMap<String, String>();
    for (String key : values.keySet()) {
      if (!overwrite && metadata.containsKey(key)) {
        throw RaptureExceptionFactory.create(
            HttpURLConnection.HTTP_BAD_REQUEST, key + " exists and overwrite was disallowed");
      }
      metadata.put(key, values.get(key));
    }
    context.setMetadata(metadata);
    getEphemeralRepo()
        .addToStage(
            RaptureConstants.OFFICIAL_STAGE,
            "session/" + context.getContext(),
            JacksonUtil.jsonFromObject(context),
            false);
  }
Example #4
0
 @Override
 public String getTemplate(CallingContext context, String name) {
   return templates.get(name);
 }