Package anvil.server

Examples of anvil.server.OperationFailedException


  }
 

  public Citizen createCitizen(String username, String password, String[][] params) throws OperationFailedException
  {
    if (username == null) throw new OperationFailedException("Null username!");
    username = username.trim().toLowerCase();
    if (!checkEmail(username)) throw new OperationFailedException("Username isn't a valid email address!");
   
    PooledConnection connImpl = null;
    DirContext ctx = null;
 
    try {
      connImpl = _manager.acquire(_contextPool);
      ctx = (DirContext)connImpl.getConnection();
     
      Attributes at = new BasicAttributes();
      at.put("facsimileTelephoneNumber", password);
      at.put(objectClassAttr);
     
      Array others = new Array();
      if (params != null) {
        for (int i=0,l=params.length; i<l; i++) {
          String key = params[i][0];
          String val = params[i][1];
 
          if (LDAPCitizen.ATTRMAP_C.containsKey(key)) {
            at.put((String)LDAPCitizen.ATTRMAP_C.get(key), val);
            //System.err.println ("Save: OK attr: "+LDAPCitizen.ATTRMAP_C.get(key)+" = "+val);
          } else {
            others.put(Any.create(key), Any.create(val));
            //System.err.println ("Save: Unknown attr: "+LDAPCitizen.ATTRMAP_C.get(key)+" = "+val);
          }
        }
      }
     
      at.put("cn", username);
      if (at.get("sn") == null) {
        at.put("sn", username);
      }
      if (others.size() > 0) {
        try {
          String sothers = Serialization.serialize(null, others);
          at.put(LDAPCitizen.OTHERS_ATTR, sothers);
        } catch(IOException ioe) {
          throw new OperationFailedException("Data serialization failed: "+ioe);
        }
      }
     
      ctx.bind("uid="+username+",ou=users", null, at);
     
      //"refresh" root tribe
      if (_rootTribe != null) {
        _rootTribe.refreshCitizens();
      }

      return (Citizen)getCitizen(username);
     
    } catch (NameAlreadyBoundException e) {
      throw new OperationFailedException("User '"+username+"' already exists!");

    } catch (Exception e) {
      _zone.log().error("LDAPRealm.createCitizen(): "+e);
     
    } finally {
View Full Code Here


  }
 

  public void setRoot(Tribe tribe) throws OperationFailedException
  {
    throw new OperationFailedException("This implementation doesn't support setting of root tribe!");
  }
View Full Code Here

      for (int i=0, l=desc.size(); i<l; i++) {
        try {
          String[] permSt = parsePermission((String)desc.get(i));
          result.add( PolicyPreferences.createPermission(permSt) );
        } catch(Throwable t) {
          throw new OperationFailedException("LDAPRealm.loadPermissions(): "+t.getMessage());
        }
      }
    }
    return result;
  }
View Full Code Here

        _zone.log().error("--addPermissions() perm added: "+perm);
      }
      return storage;
 
    } catch (Exception e) {
      throw new OperationFailedException(e.getMessage());
     
    } finally {
      cleanupContext(connImpl);
    }
  }
View Full Code Here

        _zone.log().error("--removePermissions() kusee.."+altered);
      }
      return altered;
 
    } catch (Exception e) {
      throw new OperationFailedException(e.getMessage());
     
    } finally {
      cleanupContext(connImpl);
    }
  }
View Full Code Here

    try {
      impl = _manager.acquire(_poolname);
    } catch (NoConnectionPoolException e) {
      String msg = "Couldn't acquire connection: " + e;
      _zone.log().error(e);
      throw new OperationFailedException(msg);
     
    } catch (CannotReturnPooledConnectionException e) {
      String msg = "Couldn't acquire connection: " + e;
      _zone.log().error(e);
      throw new OperationFailedException(msg);
    }
   
    Connection conn = (Connection)impl.getConnection();
   
    try {
      /* conn.setAutoCommit(false) */
      Object rv = action.perform(conn);
      /* conn.commit(); */
      return rv;
   
    } catch (SQLException e) {
      try {
        /* conn.rollback(); */
        conn.close();
      } catch (Throwable t) {
      }
      _zone.log().error("SQL operation failed", e);
      throw new OperationFailedException(e.toString());
     
    } catch (OperationFailedException e) {
      try {
        /* conn.rollback(); */
        conn.close();
View Full Code Here

          return new DBTribe(DBRealm.this, id, set.getString(3));
        } else {
          return new DBCitizen(DBRealm.this, id, set.getString(3), set.getString(4));
        }
      } catch (SQLException e) {
        throw new OperationFailedException(e.toString());
      }
     
    } else {
      entity = (DBEntity)perform(
        new Action() {
View Full Code Here

                Permission perm = PolicyPreferences.createPermission(
                  new String[] { type, name, actions });
                addInitialPermission(perm);
              } catch (Throwable t) {
                _realm.log().error(t);
                throw new OperationFailedException("Invalid permission: "+t.toString());
              }
            }
            close(set);

            set = stmt.executeQuery("select name, isstring, value from attribute where id="+_id);
            while(set.next()) {
              String name = set.getString(1);
              if (set.getInt(2) != 0) {
                setInitialVariable(name, Any.create(set.getString(3)));
              } else {
                byte[] data = set.getBytes(3);
                try {
                  Any value = Serialization.unserialize(null, data, 0, data.length);
                  setInitialVariable(name, value);
                } catch (UnserializationException t) {
                  throw new OperationFailedException("Invalid permission: "+t.toString());
                }
              }
            }
            close(set);
           
View Full Code Here

        tribeFound = true;
      } catch (NameNotFoundException nnfe) {
        //not found
 
      } catch (Exception e) {
        throw new OperationFailedException("Creating of tribe failed", e);
       
      } finally {
        LDAPRealm.cleanupContext(connImpl);
      }
      if (!tribeFound) {     
View Full Code Here

  }


  public void addPermission(Permission perm) throws OperationFailedException {
    if (isRoot) {
      throw new OperationFailedException("addPermission operation isn't allowed for synthetic root tribe!");
    }
    permissions = realm.addPermission(perm, dn);
  }
View Full Code Here

TOP

Related Classes of anvil.server.OperationFailedException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.