Package org.any_openeai_enterprise.moa.objects.resources.v1_0

Examples of org.any_openeai_enterprise.moa.objects.resources.v1_0.LightweightPerson


        publishSyncError(eControlArea, errors, ele);
        return;
      }

      // Determine whether the user exists is the directory server.
      LightweightPerson lPerson = newEntUserPassword.getEnterpriseUser()
        .getLightweightPerson();
      String userName = "";
      if (lPerson.getName() != null) userName = lPerson.getName().getFirstName()
        + " " + lPerson.getName().getLastName();

      logger.debug("[" + getServiceName() + ".execute] Querying the directory to " +
        "determine if the user whose password has changed already exists " +
        "in the directory.");

      // Specify the search filter for the directory service query using
      // the employeeNumber.
      String filter = "employeeNumber=" + lPerson.getInstitutionalId();
      logger.debug("[" + getServiceName() + ".execute] Search filter is: " + filter);

      // Specify the providerUrl.
      String providerUrl = getUserDirectoryTreeBase();
      logger.debug("[" + getServiceName() + ".execute] providerUrl is: " +
        providerUrl);

      // Specify search controls that set the scope of the search.
      SearchControls cons = new SearchControls();
      cons.setSearchScope(SearchControls.ONELEVEL_SCOPE);
      String[] attrs = new String[1];
      attrs[0] = "uid";
      cons.setReturningAttributes(attrs);

      // Search for user entries that match the employeeNumber, retrieving
      // the uid.
      NamingEnumeration results = null;
      boolean userExists = false;
      try {
        logger.debug("[" + getServiceName() + ".execute] Querying the directory " +
          "server.");
        results = getDirContext().search(providerUrl, filter, cons);
        if (results != null && results.hasMore() == true) userExists = true;  
      }
      catch (NamingException ne) {
        // An error occurred querying the directory server to determine whether
        // the user exists. Log it, publich a error message, and return.
        String errMsg = "An error occurred querying the directory server to " +
          "determine whether the user exists.";
        logger.debug("[" + getServiceName() + ".execute] " + errMsg);
        Error error = new Error();
        error.setType("system");
        error.setErrorNumber("DirectoryServiceGateway-2002");
        error.setErrorDescription(errMsg);
        errors = new ArrayList();
        errors.add(error);
        publishSyncError(eControlArea, errors, ne);
        return;
      }

      // If there are no matching entries, the user does not exist. If the
      // createMissingUsers property is true, create the user with attribute
      // and password indicated in the new data of the message. If the
      // createMissingUsers property is false, publish a Sync.Error-Sync
      // indicating that the password cannot be set for this user, because
      // the user does not exist.
      if (userExists == false) {
        logger.info("[" + getServiceName() + ".execute] The user " + userName +
          "(" + lPerson.getInstitutionalId() +
          ") does not exist in the directory.");

        if (getCreateMissingUsers() == true) {
          // Create the user.
          // -- Build the attributes for the new directory entry.
          BasicAttributes attributes = buildDirectoryUser(newEntUserPassword);

          // -- Create the new subcontext for the entry.
          String dn = "uid=" + getEnterpriseId(newEntUserPassword
            .getEnterpriseUser()).getPrincipal() + "," +
            getUserDirectoryTreeBase();
          logger.debug("[" + getServiceName() + ".execute] dn for the new " +
            "directory context is: " + dn);
          try {
            logger.debug("[" + getServiceName() + ".execute] Creating directory " +
              "user with attributes: " + attributes.toString());
            Context result = getDirContext().createSubcontext(dn, attributes);
            logger.info("[" + getServiceName() + ".execute] Created directory " +
              "user.");
          }
          catch (NamingException ne) {
            // An error occurred creating the entry for the user in the
            // directory server. Log it, publich a error message, and return.
            String errMsg = "An error occurred creating the entry for the " +
              "user in the directory server.";
            logger.debug("[" + getServiceName() + ".execute] " + errMsg);
            Error error = new Error();
            error.setType("system");
            error.setErrorNumber("DirectoryServiceGateway-2002");
            error.setErrorDescription(errMsg);
            errors = new ArrayList();
            errors.add(error);
            publishSyncError(eControlArea, errors, ne);
            return;
          }
          return;
        }
        else {
          // The createMissingUsers property is false, so we will not create
          // the missing user.
          logger.info("[" + getServiceName() + ".execute] createMissingUsers is " +
            "false, so the missing user will not be created and the " +
            "cannot be set.");
          return;
        }
      }
      else {
        // Otherwise, the user already exists, so the user does not have to be
        // created. Log it and return.
        logger.info("[" + getServiceName() + ".execute] The directory user already "
            + "exists, so the user does not need to be created.");
        return;
      }
    }

    // Handle an EnterpriseUserPassword.Update-Sync
    if (messageAction.equalsIgnoreCase("Update")) {
      // Get the baseline state of the EnterpriseUserPassword and build an
      // EnterpriseUserPassword object.
      Element eBaselinePassword = inDoc.getRootElement().getChild("DataArea")
        .getChild("BaselineData").getChild("EnterpriseUserPassword");
      try
        currentEntUserPassword.buildObjectFromInput(eBaselinePassword);
      }
      catch (EnterpriseLayoutException ele) {
        // An error occurred building the EnterpriseUserPassword object from the
        // EnterpriseUserPassword element contained in the BaselineData element
        // of the message. Log it and publish a sync error message.
        Error error = new Error();
        error.setType("system");
        error.setErrorNumber("DirectoryServiceGateway-1001");
        error.setErrorDescription("An error occurred building the " +
          "EnterpriseUserPassword object from the EnterpriseUserPassword " +
          "element contained in the BaselineData element of the message. The " +
          "exception is: " + ele.getMessage());
        errors = new ArrayList();
        errors.add(error);
        publishSyncError(eControlArea, errors, ele);
        return;
      }

      // Get the new state of the EnterpriseUserPassword and build an
      // EnterpriseUserPassword object.
      Element eNewPassword = inDoc.getRootElement().getChild("DataArea")
        .getChild("NewData").getChild("EnterpriseUserPassword");
      try
        newEntUserPassword.buildObjectFromInput(eNewPassword);
      }
      catch (EnterpriseLayoutException ele) {
        // An error occurred building the EnterpriseUserPassword object from the
        // EnterpriseUserPassword element contained in the NewData element of
        // the message. Log it and publish a sync error message.
        Error error = new Error();
        error.setType("system");
        error.setErrorNumber("DirectoryServiceGateway-1002");
        error.setErrorDescription("An error occurred building the " +
          "EnterpriseUserPassword object from the EnterpriseUserPassword " +
          "element contained in the NewData element of the message. The " +
          "exception is: " + ele.getMessage());
        errors = new ArrayList();
        errors.add(error);
        publishSyncError(eControlArea, errors, ele);
        return;
      }

      // Determine whether the user exists is the directory server.
      LightweightPerson lPerson = newEntUserPassword.getEnterpriseUser()
        .getLightweightPerson();
      String userName = "";
      if (lPerson.getName() != null) userName = lPerson.getName().getFirstName()
        + " " + lPerson.getName().getLastName();

      logger.debug("[" + getServiceName() + ".execute] Querying the directory to " +
        "see if the user whose password has changed already exists in the " +
        "directory.");

      // Specify the search filter for the directory service query using
      // the uniqueMember and the uniquePermission built above.
      String filter = "employeeNumber=" + lPerson.getInstitutionalId();
      logger.debug("[" + getServiceName() + ".execute] Search filter is: " + filter);

      // Specify the providerUrl.
      String providerUrl = getUserDirectoryTreeBase();
      logger.debug("[" + getServiceName() + ".execute] providerUrl is: " +
        providerUrl);

      // Specify search controls that set the scope of the search.
      SearchControls cons = new SearchControls();
      cons.setSearchScope(SearchControls.ONELEVEL_SCOPE);
      String[] attrs = new String[1];
      attrs[0] = "uid";
      cons.setReturningAttributes(attrs);

      // Search for user entries that match the employeeNumber, retrieving
      // the uid.
      try {
        logger.debug("[" + getServiceName() + ".execute] Querying the directory " +
          "server.");
        NamingEnumeration results = getDirContext().search(providerUrl, filter,
          cons);

        // If there are no matching entries, publish a error message indicating
        // that the user does not exist.
        if (results == null || results.hasMore() == false) {
          Error error = new Error();
          error.setType("application");
          error.setErrorNumber("DirectoryServiceGateway-1005");
          error.setErrorDescription("No user " + userName + "(" +
            lPerson.getInstitutionalId() + ") exists in the directory. " +
            "Cannot reset the password for this user.");
          logger.fatal("[" + getServiceName() + ".execute] " +
            error.getErrorDescription());
          errors = new ArrayList();
          errors.add(error);
View Full Code Here


    throws EnterpriseConfigurationObjectException, EnterpriseFieldException,
         EnterpriseObjectCreateException, EnterpriseObjectQueryException, EnterpriseObjectUpdateException {
      EnterpriseUser eu = (EnterpriseUser)appConfig.getObject(ENTERPRISE_USER);
      logger.info("["+portletName+"] Got " + ENTERPRISE_USER + " from AppConfig, performing Query...");

      LightweightPerson lPerson = eu.newLightweightPerson();
    logger.info("["+portletName+"] Got LightweightPerson...");
    lPerson.setInstitutionalId(instID);
    logger.info("["+portletName+"] Set instid on lightweight person...");

    NetId netId = eu.newNetId();
    logger.info("["+portletName+"] Got NetId...");
    netId.setPrincipal(principal);
View Full Code Here

      EnterpriseUser eu =
        (EnterpriseUser)getAppConfig().getObject(queryObjectName);
      eu.getEnterpriseFields().setIgnoreValidation(true);
      LogService.log(LogService.INFO, "got EnterpriseUser...");

      LightweightPerson lPerson = eu.newLightweightPerson();
      lPerson.getEnterpriseFields().setIgnoreValidation(true);

      NetId netId = eu.newNetId();
      netId.setPrincipal(principal);
      netId.setDomain(domain);
      eu.addNetId(netId);

      if (instId != null && instId.length() > 0) {
        lPerson.setInstitutionalId(instId);
        Name name = lPerson.newName();
        name.setFirstName(firstName);
        name.setLastName(lastName);
        lPerson.setName(name);
        LogService.log(LogService.INFO, "set LightweightPerson on EnterpriseUser...");
        eu.setLightweightPerson(lPerson);

        JmsEnterpriseObject jeo = (JmsEnterpriseObject)getAppConfig().getObject(messageObjectName);
        LogService.log(LogService.INFO, "got " + messageObjectName + " from AppConfig, performing Query...");
View Full Code Here

    NetId netID = entUser.getNetId(0);
    String principal = netID.getPrincipal();
    String enterpriseID = null;

    try {
      LightweightPerson lightweightPerson = entUser.getLightweightPerson();
      enterpriseID = lightweightPerson.getInstitutionalId();
      BasicPerson basicPerson = getBasicPerson(enterpriseID);
      Name name = basicPerson.getName();
      String firstName = name.getFirstName();
      String lastName = name.getLastName();
      String middleName = name.getMiddleName();
View Full Code Here

   * @throws EnterpriseFieldException
   * @throws EnterpriseObjectQueryException
   */
  private BasicPerson getBasicPerson(String instId) throws EnterpriseConfigurationObjectException, EnterpriseFieldException, EnterpriseObjectQueryException {
       
    LightweightPerson lightPerson = (LightweightPerson) getAppConfig().getObject(LIGHTWEIGHT_PERSON);
    logger.debug("[" + getServiceName() + "] Got LightweightPerson...");

    lightPerson.setInstitutionalId(instId);
    logger.debug("[" + getServiceName() + "] Set instid on lightweight person...");

    BasicPerson basicPerson = (BasicPerson) getAppConfig().getObject(BASIC_PERSON);
    logger.debug("[" + getServiceName() + "] Got " + BASIC_PERSON + " from AppConfig, performing Query...");

View Full Code Here

   * @throws EnterpriseFieldException
   * @throws EnterpriseObjectQueryException
   */
  private BasicPerson getBasicPerson(String instId) throws EnterpriseConfigurationObjectException, EnterpriseFieldException, EnterpriseObjectQueryException {
       
    LightweightPerson lPerson =
          (LightweightPerson)appConfig.getObject(LIGHTWEIGHT_PERSON);
        logger.info("["+portletName+"] Got LightweightPerson...");

        lPerson.setInstitutionalId(instId);
        logger.info("["+portletName+"] Set instid on lightweight person...");
       
        BasicPerson aeo = (BasicPerson)appConfig.getObject(BASIC_PERSON);
        logger.info("["+portletName+"] Got " + BASIC_PERSON + " from AppConfig, performing Query...");

View Full Code Here

      NetId netId = eu.newNetId();
    logger.info("["+portletName+"] Got NetId...");
    netId.setPrincipal(principal);
    netId.setDomain(domain);

      LightweightPerson lPerson = eu.newLightweightPerson();
    logger.info("["+portletName+"] Got LightweightPerson...");
    lPerson.setInstitutionalId(instID);
    logger.info("["+portletName+"] Set instid on lightweight person...");
     
      eu.setLightweightPerson(lPerson);
      eu.addNetId(netId);
     
View Full Code Here

    try {
      InstitutionalIdentity instIdent = (InstitutionalIdentity)getAppConfig()
        .getObject("InstitutionalIdentity");
      UnknownPerson uPerson = (UnknownPerson)getAppConfig()
        .getObject("UnknownPerson");  
      Name aName = (Name)getAppConfig().getObject("Name");
    }
    catch (EnterpriseConfigurationObjectException eoce) {
      // An error occurred retrieving a required object from AppConfig. Log it
      // and throw an exception.
      String errMsg = "An error occurred retrieving a required object from " +
View Full Code Here

        errMsg);
      throw new I2sRepositoryException(errMsg);
    }

    // Get a configured Name object out of AppConfig.
    Name name = new Name();
    try {
      name = (Name)getAppConfig().getObject("Name");
    }
    catch (EnterpriseConfigurationObjectException eoce) {
      // An error occurred retrieving a Name object from AppConfig. Log it and
      // throw an exception.
      String errMsg = "An error occurred retrieving a Name object from " +
        "AppConfig. The exception is: " + eoce.getMessage();
      logger.fatal("[RdbmsI2sRepository.retrieveInstitutionalIdBySsn] " +
        errMsg);
      throw new I2sRepositoryException(errMsg);
    }
   
    // Initialize a query string to retrieve the InstitutionalIdentity.
    String getString1 = "SELECT INST_ID, FIRST_NAME, MIDDLE_NAME, LAST_NAME, " +
      "SSN, BIRTH_DATE, GENDER FROM T_INST_IDENT WHERE SSN = ? AND " +
      "TERMINATED_DATE IS NULL";
     
    try {
      PreparedStatement getStmt1 = conn.prepareStatement(getString1);
      getStmt1.clearParameters();
      getStmt1.setString(1, ssn);
      ResultSet r1 = getStmt1.executeQuery();
      if (r1.next()) {
        // The InstitutionalIdentity exists. Log a message and build the
        // InstitutionalIdentity object.
        logger.debug("[RdbmsI2sRepository.retrieveInstitutionalIdentityBySsn] "
          + "Found an InstitutionalIdentity in the database for SSN: " + ssn +
          ".");
        // Set the values of the Name object.
        try {
          name.setFirstName(r1.getString(2));
          name.setMiddleName(r1.getString(3));
          name.setLastName(r1.getString(4));
        }
        catch (EnterpriseFieldException efe) {
          // An error occurred setting field values for the Name. Log it,
          // close the statement, and throw an exception.
          String errMsg = "An error occurred seeting field values for the " +
View Full Code Here

        errMsg);
      throw new I2sRepositoryException(errMsg);
    }

    // Get a configured Name object out of AppConfig.
    Name name = new Name();
    try {
      name = (Name)getAppConfig().getObject("Name");
    }
    catch (EnterpriseConfigurationObjectException eoce) {
      // An error occurred retrieving a Name object from AppConfig. Log it and
      // throw an exception.
      String errMsg = "An error occurred retrieving a Name object from " +
        "AppConfig. The exception is: " + eoce.getMessage();
      logger.fatal("[RdbmsI2sRepository.retrieveInstitutionalIdByInstId] " +
        errMsg);
      throw new I2sRepositoryException(errMsg);
    }
   
    // Initialize a query string to retrieve the InstitutionalIdentity.
    String getString1 = "SELECT INST_ID, FIRST_NAME, MIDDLE_NAME, LAST_NAME, " +
      "SSN, BIRTH_DATE, GENDER FROM T_INST_IDENT WHERE INST_ID = ? AND " +
      "TERMINATED_DATE IS NULL";
     
    try {
      PreparedStatement getStmt1 = conn.prepareStatement(getString1);
      getStmt1.clearParameters();
      getStmt1.setString(1, instId);
      ResultSet r1 = getStmt1.executeQuery();
      if (r1.next()) {
        // The InstitutionalIdentity exists. Log a message and build the
        // InstitutionalIdentity object.
        logger.debug("[RdbmsI2sRepository.retrieveInstitutionalIdentityByInst" +
          "Id] Found an InstitutionalIdentity in the database for " +
          "InstitutionalId: " + instId + ".");
        // Set the values of the Name object.
        try {
          name.setFirstName(r1.getString(2));
          name.setMiddleName(r1.getString(3));
          name.setLastName(r1.getString(4));
        }
        catch (EnterpriseFieldException efe) {
          // An error occurred setting field values for the Name. Log it,
          // close the statement, and throw an exception.
          String errMsg = "An error occurred seeting field values for the " +
View Full Code Here

TOP

Related Classes of org.any_openeai_enterprise.moa.objects.resources.v1_0.LightweightPerson

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.