Ejemplo n.º 1
0
  /*
   * (non-Javadoc)
   * @see jp.go.nict.langrid.p2pgridbasis.dao#updateData(jp.go.nict.langrid.p2pgridbasis.data.Data)
   */
  public synchronized boolean updateDataTarget(Data data)
      throws UnmatchedDataTypeException, DataDaoException {
    logger.debug("[user] :" + data.getId());
    if (data.getClass().equals(UserData.class) == false) {
      throw new UnmatchedDataTypeException(UserData.class.toString(), data.getClass().toString());
    }

    if (data.getAttributes().getKeys().contains("IsDeleted")
        && data.getAttributes().getValue("IsDeleted").equals("true")) {
      logger.debug("Delete");
      boolean updated = false;
      try {
        UserData userData = (UserData) data;
        User user = userData.getUser();
        removeEntityListener();
        dao.deleteUser(user.getGridId(), user.getUserId());
        updated = true;
        setEntityListener();
        getController().baseSummaryAdd(data);
      } catch (ParseException e) {
        throw new DataDaoException(e);
      } catch (UserNotFoundException e) {
        //
        //
        try {
          getController().baseSummaryAdd(data);
        } catch (ControllerException e1) {
          e1.printStackTrace();
        }
      } catch (DaoException e) {
        throw new DataDaoException(e);
      } catch (ControllerException e) {
        throw new DataDaoException(e);
      }
      return updated;
    }

    User user = null;
    try {
      UserData userData = (UserData) data;
      user = userData.getUser();
      removeEntityListener();
      if (dao.isUserExist(user.getGridId(), user.getUserId())) {
        logger.debug("UpDate");
        daoContext.updateEntity(user);
      } else {
        logger.debug("New");
        dao.addUser(user);
      }
      setEntityListener();
      getController().baseSummaryAdd(data);
      return true;
    } catch (ParseException e) {
      throw new DataDaoException(e);
    } catch (DaoException e) {
      throw new DataDaoException(e);
    } catch (ControllerException e) {
      throw new DataDaoException(e);
    }
  }
Ejemplo n.º 2
0
 protected void doRemove(Serializable id) {
   try {
     UserPK pk = (UserPK) id;
     getController().revoke(UserData.getDataID(null, pk));
     logger.debug("revoked[User(id=" + id + ")]");
   } catch (ControllerException e) {
     logger.error("failed to revoke instance.", e);
   } catch (DataNotFoundException e) {
     logger.error("failed to find data.", e);
   }
 }