@Override
  public Resource create(Request request) throws IllegalActionOnResourceException {
    String pid = request.get(PID, String.class);
    String factoryPid = request.get(FACTORY_PID, String.class);
    Configuration configuration = null;
    String location = request.get(BUNDLE_LOCATION, String.class);
    if (location != null) {
      if (pid != null) {
        try {
          configuration = m_configAdmin.getConfiguration(pid, location);
        } catch (IOException e) {
          throw new IllegalActionOnResourceException(request, e.getMessage());
        }
      } else if (factoryPid != null) {
        try {
          configuration = m_configAdmin.createFactoryConfiguration(factoryPid, location);
        } catch (IOException e) {
          throw new IllegalActionOnResourceException(request, e.getMessage());
        }
      } else {
        throw new IllegalActionOnResourceException(
            request, "factory pid or pid parameter is mandatory");
      }

    } else {
      throw new IllegalActionOnResourceException(request, "location parameter is mandatory");
    }
    ConfigurationResource configurationResource = new ConfigurationResource(configuration);
    synchronized (m_configurationResourceMap) {
      m_configurationResourceMap.put(pid, configurationResource);
    }
    return configurationResource;
  }
Exemple #2
0
  public Resource create(Request request) {
    ZoneResource resource = null;

    Map<String, ?> newMap = request.parameters();
    if (newMap != null) {
      for (String key : newMap.keySet()) {
        if (key.equalsIgnoreCase("zone")) {
          Zone newZone = new Zone(newMap.get(key).toString());
          resource = new ZoneResource(newZone, this);
          m_zoneResourcesMap.put(newZone.name, resource);
        }
      }
    }
    return resource;
  }