Exemple #1
0
  public void addPermission(
      int typeObject, int idObject, IResponsible responsible, int typePermission)
      throws ISPACException {

    // Si el permisos es de lectura y ya tenemos dado de alta el de edición
    // no se insertará
    if (!(existsPermission(typeObject, idObject, responsible.getUID(), typePermission))) {

      try {

        PermissionDAO permission = new PermissionDAO(mDbCnt);
        permission.createNew(mDbCnt);

        permission.set("TP_OBJ", typeObject);
        permission.set("ID_OBJ", idObject);
        permission.set("ID_RESP", responsible.getUID());
        // Guardar el nombre del responsable para no consultarlo cada
        // vez que se muestra
        permission.set("RESP_NAME", responsible.getRespName());
        permission.set("PERMISO", typePermission);

        permission.store(mDbCnt);
        // Si todo ha sido correcto se hace commit de la transacción

      } catch (ISPACException e) {
        logger.error("Error en SecurityMgr:addPermission" + e);
        throw e;
      }
    }
  }
Exemple #2
0
  public IItemCollection getPermissions(int typeObject, int idObject, int[] typePermissions)
      throws ISPACException {
    CollectionDAO coldao =
        PermissionDAO.getPermissions(mDbCnt, typeObject, idObject, typePermissions);

    List list = new ArrayList();
    while (coldao.next()) {

      ObjectDAO permission = coldao.value();
      String respName = permission.getString("RESP_NAME");
      if (StringUtils.isBlank(respName)) {

        String idResp = permission.getString("ID_RESP");
        IResponsible responsible = null;

        try {
          responsible = getResp(idResp);
          // } catch (ISPACException ie) {
        } catch (Exception ie) {
          // java.lang.NumberFormatException
          // si el ID_RESP no es un UID y es el nombre del responsable
        }

        /*
        if (responsible != null) {

        	// Establecer el nombre del responsable
        	permission.set("RESP_NAME", responsible.getRespName());
        	permission.store(mDbCnt);
        } else {
        	// Eliminar el permiso asociado al responsable que ya no existe
        	// permission.delete(mDbCnt);
        	// No eliminar sino no incluirlo en la lista
        	permission = null;
        }
        */

        if (responsible != null) {
          // Establecer el nombre del responsable
          permission.set("RESP_NAME", responsible.getRespName());
          permission.store(mDbCnt);
        }
        /*else {
        	// Establecer el ID como nombre del responsable
        	permission.set("RESP_NAME", idResp);
        }
        permission.store(mDbCnt);
        */
      }

      if (permission != null) {
        list.add(permission);
      }
    }

    return new ListCollection(list);
  }
Exemple #3
0
  public IItemCollection getPermissionsResp(int typeObject, int idObject, String uid)
      throws ISPACException {

    CollectionDAO coldao = PermissionDAO.getPermissions(mDbCnt, typeObject, idObject, uid);
    return coldao.disconnect();
  }
Exemple #4
0
 public boolean existsPermission(int typeObject, int idObject, String resp, int typePermission)
     throws ISPACException {
   return PermissionDAO.existPermission(mDbCnt, typeObject, idObject, resp, typePermission);
 }
Exemple #5
0
 public boolean existPermissions(IProcess process, String resp, int[] typePermissions)
     throws ISPACException {
   return PermissionDAO.existPermissions(mDbCnt, process, resp, typePermissions);
 }
Exemple #6
0
 public boolean existPermissions(IStage stage, String resp, int[] typePermissions)
     throws ISPACException {
   return PermissionDAO.existPermissions(mDbCnt, stage, resp, typePermissions);
 }
Exemple #7
0
 public boolean existPermissions(ITask task, String resp, int[] typePermissions)
     throws ISPACException {
   return PermissionDAO.existPermissions(mDbCnt, task, resp, typePermissions);
 }
Exemple #8
0
 /**
  * Comprueba si alguno de los elementos de la cadena de responsabilidad que tiene el permiso de
  * edición no se debe a una supervisión en modo consulta
  *
  * @return
  */
 public boolean existPermissionEditNotFollowSupervision(
     IProcess process, String cadenaResponsabilidad, IResponsible resp) throws ISPACException {
   return PermissionDAO.existPermissionEditNotFollowSupervision(
       mDbCnt, process, cadenaResponsabilidad, getUidsResponsible(resp));
 }
Exemple #9
0
 public Map getPermissions(EntityDAO entity, String resp) throws ISPACException {
   CollectionDAO collDAO = PermissionDAO.getPermissions(mDbCnt, entity, resp);
   return collDAO.toMap(PermissionDAO.FIELD_PERMISION_TYPE);
 }