예제 #1
0
  public AdminApiImpl(Kernel raptureKernel) {
    super(raptureKernel);
    // Update templates from the command line (Environment and Defines)
    for (Map.Entry<String, String> entry : System.getenv().entrySet()) {
      if (entry.getKey().startsWith(TEMPLATE)) {
        String templateName = entry.getKey().substring(TEMPLATE.length() + 1);
        templates.put(templateName, entry.getValue());
      }
    }

    Enumeration<Object> e = System.getProperties().keys();
    while (e.hasMoreElements()) {
      String name = e.nextElement().toString();
      if (name.startsWith(TEMPLATE)) {
        String templateName = name.substring(TEMPLATE.length() + 1);
        templates.put(templateName, System.getProperty(name));
      }
    }
  }
예제 #2
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);
   }
 }
예제 #3
0
 @Override
 public Map<String, String> getSystemProperties(CallingContext context, List<String> keys) {
   Map<String, String> ret = new TreeMap<String, String>();
   if (keys.isEmpty()) {
     ret.putAll(System.getenv());
     Properties p = System.getProperties();
     for (Map.Entry<Object, Object> prop : p.entrySet()) {
       ret.put(prop.getKey().toString(), prop.getValue().toString());
     }
   } else {
     for (String k : keys) {
       String val = System.getenv(k);
       if (val != null) {
         ret.put(k, System.getenv(k));
       } else {
         String prop = System.getProperty(k);
         if (prop != null) {
           ret.put(k, prop);
         }
       }
     }
   }
   return ret;
 }
예제 #4
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);
  }