Exemple #1
0
  /**
   * Method for deleting the specific component manager.
   *
   * @param compMgrId RequestObject. ComponentManagerID to be deleted.
   * @return res ResponseObject. Body should be null.
   */
  private Response deleteComponentManager(final String compMgrId) {
    if (componentMgrsSet.contains(compMgrId)) {
      // delete Component
      for (Entry<String, String> e :
          new HashSet<Entry<String, String>>(mapCompAndCompMgr.entrySet())) {
        if (e.getValue().equals(compMgrId)) {
          deleteComponentFromComponentManager(compMgrId, e.getKey());
          componentStateList.remove(e.getKey());
          mapCompAndCompMgr.remove(e.getKey());
        }
      }

      ObjectProperty prev = getPropertyFromOtherComponent(compMgrId);
      if (prev != null) {
        componentManagerChanged(ComponentManagerChanged.Action.delete.name(), prev, null);
      }

      deleteFromCreatableComponentType(compMgrId);
      componentMgrsSet.remove(compMgrId);
      compMgrsObjProps.remove(compMgrId);

      log.info("Deleted ComponentManager Object ID:{}", compMgrId);
      return new Response(Response.OK, null);
    }
    return new Response(Response.OK, null);
  }
Exemple #2
0
  /**
   * Method for registering component manager.
   *
   * @param compMgrId ComponentManager ID.
   * @param body RequestObject. Body should be ComponentManager's objectProperty.
   * @return res ResponseObject. Body should be register objectProperty.
   */
  private Response putComponentManagers(final String compMngId, final ObjectProperty body) {
    // Register the componentManager ID into the HashSet.
    if (!componentMgrsSet.add(compMngId)) {
      // Registered already
      log.warn("ComponentManager is already registerd, ID:{}", compMngId);
      return new Response(Response.CONFLICT, "ComponentManager is already registerd");
    }
    body.setProperty(ObjectProperty.PropertyNames.OBJECT_ID, compMngId);

    this.eventSubscription.addFilter(compMngId, ObjectPropertyChanged.TYPE);
    try {
      this.applyEventSubscription();
    } catch (Exception e) {
      log.error("Recieved Message Exception.", e);
    }

    String componentTypes = body.getProperty(ObjectProperty.PropertyNames.COMPONENT_TYPES);
    if (componentTypes != null) {
      List<String> typeList = Arrays.asList(componentTypes.split(","));
      log.debug("use component_types {} about {} in request body.", typeList, body.getObjectId());

      componentManagerChanged(ComponentManagerChanged.Action.add.name(), null, body);

      updateCreatableComponentType(body.getObjectId(), typeList);
      componentMgrsSet.add(body.getObjectId());
      compMgrsObjProps.put(body.getObjectId(), body);
    } else {
      log.warn("ComponentTypes is not set request body, Comopnent ID:{}", body.getObjectId());
      return new Response(Response.BAD_REQUEST, null);
    }

    log.info("Registerd ComponentManager Object ID:{}", body.getObjectId());
    return new Response(Response.OK, body);
  }
Exemple #3
0
 private void updateComponentManager(final String id, final ObjectProperty body) {
   compMgrsObjProps.put(id, body);
   if (componentMgrsSet.add(id)) {
     log.warn("ComponentManager is not registerd, ID:{}", id);
     return;
   }
   String componentTypes = body.getProperty(ComponentManager2.ATTR_COMPTYPE);
   if (componentTypes == null) {
     log.warn("ComponentTypes is not set request body, Comopnent ID:{}", id);
     return;
   }
   List<String> typeList = Arrays.asList(componentTypes.split(","));
   log.debug("use component_types {} about {} in request body.", typeList, id);
   updateCreatableComponentType(id, typeList);
 }