Examples of Error


Examples of org.megatome.frame2.errors.Error

     * @param value3 Third value to insert into message
     * @see org.megatome.frame2.errors.Errors#add(String,Object,Object,Object)
     */
    public Error addIfUnique(final String key, final Object value1,
            final Object value2, final Object value3) {
        Error error = new ErrorImpl(key, value1, value2, value3);

        if (!contains(error)) {
            add(error);
        }

View Full Code Here

Examples of org.openeai.moa.objects.resources.Error

    Document inDoc = null;
    try { inDoc = initializeInput(messageNumber, aMessage); }
    catch (JMSException jmse) {
      // An error occurred creating the input document from the JMS message
      // passed in. Log it and publish a sync error.
      Error error = new Error();
      error.setErrorNumber("OpenEAI-2101");
      error.setErrorDescription("An error occurred creating the input " +
        "document from the JMS message passed in. The exception is: " +
        jmse.getMessage());
      logger.fatal("[BasicPersonSyncCommand.execute]" +
        error.getErrorDescription());
      return;
    }

    // Get the message metadata.
    Element eControlArea = getControlArea(inDoc.getRootElement());
    String messageCategory = eControlArea.getAttribute("messageCategory")
      .getValue();
    String messageObject = eControlArea.getAttribute("messageObject")
      .getValue();
    String messageRelease = eControlArea.getAttribute("messageRelease")
      .getValue();
    String messageAction = eControlArea.getAttribute("messageAction")
      .getValue();
    String messageType = eControlArea.getAttribute("messageType").getValue();

    logger.info("[BasicPersonSyncCommand.execute] Received a(n) " +
      messageCategory  + "." + messageObject + "." + messageAction + "-" +
      messageType + " (release " + messageRelease + ") message.");

    // Verify that this is a message we support.
    ArrayList errors = new ArrayList();
    if (messageObject.equalsIgnoreCase("BasicPerson") == false) {
      Error error = new Error();
      error.setType("application");
      error.setErrorNumber("OpenEAI-1002");
      error.setErrorDescription("Message object '" + messageObject +
        "' is not supported.");
      errors.add(error);
    }
    if (messageType.equalsIgnoreCase("Sync") == false) {
      Error error = new Error();
      error.setType("application");
      error.setErrorNumber("OpenEAI-1002");
      error.setErrorDescription("Message type '" + messageType + "' is not " +
        "supported.");
      errors.add(errors);
    }
    if (errors.size() > 0) {
      ListIterator iterator = errors.listIterator();
      while (iterator.hasNext()) {
        Error error = (Error)iterator.next();
        logger.fatal("[BasicPersonSyncCommand.execute] " +
          error.getErrorDescription());
      }
      publishSyncError(eControlArea, errors);
      return;
    }

    // Get two configured BasicPerson objects from AppConfig.
    BasicPerson currentBasicPerson = null;
    BasicPerson newBasicPerson = null;
    try {
      currentBasicPerson = (BasicPerson)getAppConfig().getObject("BasicPerson");
      newBasicPerson = (BasicPerson)getAppConfig().getObject("BasicPerson");
    }
    catch (EnterpriseConfigurationObjectException ecoe) {
      // An error occurred getting an object from AppConfig. Log it and
      // publish a sync error message.
      Error error = new Error();
      error.setType("application");
      error.setErrorNumber("OpenEAI-3001");
      error.setErrorDescription("An error occurred getting an object from " +
        "AppConfig. the exception is: " + ecoe.getMessage());
      errors = new ArrayList();
      errors.add(error);
      publishSyncError(eControlArea, errors, ecoe);
      return;
    }

    // Handle a BasicPerson.Update-Sync
    if (messageAction.equalsIgnoreCase("Update")) {
      // Get the baseline state of the BasicPerson and build a BasicPerson
      // object.
      Element eBaselinePerson = inDoc.getRootElement().getChild("DataArea")
        .getChild("BaselineData").getChild("BasicPerson");
      try
        currentBasicPerson.buildObjectFromInput(eBaselinePerson);
      }
      catch (EnterpriseLayoutException ele) {
        // An error occurred building the BasicPerson object from the
        // BasicPerson 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 BasicPerson "
          + "object from the BasicPerson 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 BasicPerson and build a BasicPerson
      // object.
      Element eNewPerson = inDoc.getRootElement().getChild("DataArea")
        .getChild("NewData").getChild("BasicPerson");
      try
        newBasicPerson.buildObjectFromInput(eNewPerson);
      }
      catch (EnterpriseLayoutException ele) {
        // An error occurred building the BasicPerson object from thw
        // BasicPerson 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 " +
          "BasicPerson object from the BasicPerson 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 in the portal database.
      String instId = currentBasicPerson.getInstitutionalId();
      PortalPerson portalPerson = null;
      try { portalPerson = retrievePortalPerson(instId); }
      catch (CommandException ce) {
        // An error occurred querying the portal database to determine whether
        // the user exists. Log it, publish a error message, and return.
        String errMsg = "An error occurred querying the portal database to " +
          "determine whether the user exists.";
        logger.debug("[PasswordSyncCommand.execute] " + errMsg);
        Error error = new Error();
        error.setType("system");
        error.setErrorNumber("UportalGateway-2001");
        error.setErrorDescription(errMsg);
        errors = new ArrayList();
        errors.add(error);
        publishSyncError(eControlArea, errors, ce);
        return;
      }

      // If there are no matching entries and the publishErrorsForMissingEntries
      // property is true, publish a error message indicating that the user does
      // not exist. Otherwise, log the fact that the user does not exist and
      // return.
      if (portalPerson == null) {
        if (getPublishErrorsForMissingEntries() == true) {
          // --- Publish the sync error.
          Error error = new Error();
          error.setType("application");
          error.setErrorNumber("UportalGateway-1005");
          error.setErrorDescription("No user with user ID " + instId +
            " exists in the portal. Cannot reset the password for this user.");
          logger.fatal("[BasicPersonSyncCommand.execute] " +
            error.getErrorDescription());
          errors = new ArrayList();
          errors.add(error);
          publishSyncError(eControlArea, errors);
          return;
        }
        else {
          // --- Just log it.
          logger.info("[BasicPersonSyncCommand.execute] No user with user ID " +
            instId + " exists in the portal. Cannot reset the password for " +
            "this user.");
          return;
        }
      }

      // Otherwise, the user already exists in the portal, so determine if their
      // name and e-mail have changed and, if so, update them.
      else {
        // Get the new first name, last name, and e-mail address.
        String newFirstName = newBasicPerson.getName().getFirstName();
        String newLastName = newBasicPerson.getName().getLastName();
        String email;
        List emailAddresses = newBasicPerson.getEmail();
        ListIterator li = emailAddresses.listIterator();
       
        switch (emailAddresses.size()) {
          // If there are no e-mail addresses in the list, set the value of the
          // e-mail address to null.
          case 0:
            email = null;
          break;

          // If there is one e-mail address in the list, that will become the
          // value of the e-mail address.
          case 1:
            Email emailAddress = (Email)li.next();
            email = emailAddress.getEmailAddress();
          break;

          // If there are multiple e-mail addresses in the list, uPortal can
          // store only one of them, so get any one that has the preferred
          // indicator set or take the first e-mail address in the list if
          // none are preferred.
          default:
            emailAddress = (Email)li.next();
            email = emailAddress.getEmailAddress();
            while (li.hasNext()) {
              emailAddress = (Email)li.next();
              if (emailAddress.getPreferred() != null &&
                  emailAddress.getPreferred().equalsIgnoreCase("Yes")) {

                  email = emailAddress.getEmailAddress();
              }
            }
          break;
        }

        // Determine whether the name or e-mail address has changed.
        PortalPerson newPortalPerson = new PortalPerson(portalPerson);
        newPortalPerson.setFirstName(newFirstName);
        newPortalPerson.setLastName(newLastName);
        newPortalPerson.setEmailAddress(email);

        // If there has been a change, update the person information. Otherwise
        // log the fact that no update is required.
        if (newPortalPerson.equals(portalPerson) == false) {
          logger.info("[BasicPersonSyncCommand.execute] Updating portal " +
            "person information for portal person " + portalPerson
            .getFirstName() + " " + portalPerson.getLastName() + ".");
          logger.debug("[BasicPersonSyncCommand.execute] current portal " +
            "person: " + portalPerson);
          logger.debug("[BasicPersonSyncCommand.execute] new portal " +
            "person: " + newPortalPerson);
          try { updatePortalPerson(portalPerson, newPortalPerson); }
          catch (CommandException ce) {
            // An error occurred accessing the portal database to update the
            // the portal user information. Log it, publish a error message,
            // and return.
            String errMsg = "An error occurred accessing the portal database " +
              "to update portal user information.";
            logger.debug("[BasicPersonSyncCommand.execute] " + errMsg);
            Error error = new Error();
            error.setType("system");
            error.setErrorNumber("UportalGateway-2001");
            error.setErrorDescription(errMsg);
            errors = new ArrayList();
            errors.add(error);
            publishSyncError(eControlArea, errors, ce);
            return;
          }
        }
        else {
          logger.info("[BasicPersonSyncCommand.execute] No change in relevant "
            + "information. No portal person information update required for " +
            "portal person " + portalPerson
            .getFirstName() + " " + portalPerson.getLastName() + " (userId=" +
            portalPerson.getUserId() + ", userName=" + portalPerson
            .getUserName() + ").");
        }
      }     
    }

    // Otherwise, the message is unsupported. Log it and publish a sync error.
    else {
      Error error = new Error();
      error.setType("application");
      error.setErrorNumber("OpenEAI-1002");
      error.setErrorDescription("Unsupported message action. This command only "
        + "supports an action of 'update'");
      errors = new ArrayList();
      errors.add(error);
      publishSyncError(eControlArea, errors);
      return;
View Full Code Here

Examples of org.springmodules.xt.examples.domain.Error

public class DomainUtils {
   
    public static BusinessException notificationErrorsToBusinessException(Notification notification) {
        BusinessException ex = new BusinessException();
        for (Message m : notification.getMessages(Message.Type.ERROR)) {
            Error error = new Error(m.getCode(), m.getDefaultMessage(), m.getPropertyName());
            ex.addError(error);
        }
        return ex;
    }
View Full Code Here

Examples of org.xrace.desjardins.reponse.Error

    {
      @Override
      public java.lang.Object getValue(java.lang.Object object)
          throws IllegalStateException
      {
        Error target = (Error) object;
        return target.getCode();
      }

      @Override
      public void setValue(java.lang.Object object, java.lang.Object value)
          throws IllegalStateException, IllegalArgumentException
      {
        try
        {
          Error target = (Error) object;
          target.setCode((java.lang.String) value);
        }
        catch (java.lang.Exception ex)
        {
          throw new IllegalStateException(ex.toString());
        }
      }

      @Override
      public java.lang.Object newInstance(java.lang.Object parent)
      {
        return null;
      }
    };
    desc.setSchemaType("string");
    desc.setHandler(handler);
    desc.setRequired(true);
    desc.setMultivalued(false);
    addFieldDescriptor(desc);
    addSequenceElement(desc);

    //-- validation code for: _code
    fieldValidator = new org.exolab.castor.xml.FieldValidator();
    fieldValidator.setMinOccurs(1);
    { //-- local scope
      org.exolab.castor.xml.validators.StringValidator typeValidator;
      typeValidator = new org.exolab.castor.xml.validators.StringValidator();
      fieldValidator.setValidator(typeValidator);
      typeValidator.setWhiteSpace("preserve");
    }
    desc.setValidator(fieldValidator);
    //-- _message
    desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(
        java.lang.String.class, "_message", "message",
        org.exolab.castor.xml.NodeType.Element);
    desc.setImmutable(true);
    handler = new org.exolab.castor.xml.XMLFieldHandler()
    {
      @Override
      public java.lang.Object getValue(java.lang.Object object)
          throws IllegalStateException
      {
        Error target = (Error) object;
        return target.getMessage();
      }

      @Override
      public void setValue(java.lang.Object object, java.lang.Object value)
          throws IllegalStateException, IllegalArgumentException
      {
        try
        {
          Error target = (Error) object;
          target.setMessage((java.lang.String) value);
        }
        catch (java.lang.Exception ex)
        {
          throw new IllegalStateException(ex.toString());
        }
View Full Code Here

Examples of play.data.validation.Error

        Book firstBook = Book.find("byIsbn", "1").first();
        firstBook.isbn = "2";
        ValidationResult res = Validation.current().valid(firstBook);
        assertFalse(res.ok);
        assertNotNull(Validation.errors(".isbn"));
        Error error = Validation.errors(".isbn").get(0);
        assertEquals("validation.unique", error.message());
    }
View Full Code Here

Examples of play.mvc.results.Error

      JsonObject contentElement = element.getAsJsonObject();
      String type = contentElement.get("type").getAsString();
      String source = contentElement.get("source").getAsString();
      Long id = contentElement.get("id") != null ? contentElement.get("id").getAsLong() : null;
      if(type==null) {
        Error error = new Error("Type field is empty.");
        error.apply(request, response);
        return;
      }
      Content.ContentType contentType = Content.ContentType.valueOf(type.toUpperCase());
      if(contentType == null) {
        Error error = new Error(type + " is not a correct type value.");
        error.apply(request, response);
        return;
      }
      if(source==null) {
        Error error = new Error("Source field is empty");
        error.apply(request, response);
        return;
      }
      // Se comenta esto para permitir contenido externo
      /*if(id==null) {
        Error error = new Error("Id field is empty");
        error.apply(request, response);
        return;
      }*/
     
      SharedContent sharedContent = new Message().new SharedContent();
      sharedContent.type = contentType;
      sharedContent.id = id;
      sharedContent.source = source;
      sharedContents.add(sharedContent);
    }
   
    ArrayList<User> receivers = new ArrayList<User>();
    for(JsonElement element : body.get("receivers").getAsJsonArray()) {
      JsonObject toElement = element.getAsJsonObject();
      Long userId = toElement.get("id").getAsLong();
      String firstName = toElement.get("firstName").getAsString();
      if(userId == null) {
        Error error = new Error("The id field of " + firstName + " is empty.");
        error.apply(request, response);
        return;
      }
      User to = User.findById(userId);
      if(to == null) {
        Error error = new Error(firstName + " is not a registered user.");
        error.apply(request, response);
        return;
      }
     
      receivers.add(to);
    }
View Full Code Here

Examples of yalp.data.validation.Error

        Book firstBook = Book.find("byIsbn", "1").first();
        firstBook.isbn = "2";
        ValidationResult res = Validation.current().valid(firstBook);
        assertFalse(res.ok);
        assertNotNull(Validation.errors(".isbn"));
        Error error = Validation.errors(".isbn").get(0);
        assertEquals("Must be unique", error.message());
    }
View Full Code Here

Examples of yalp.mvc.results.Error

     *
     * @param status The exact status code
     * @param reason The reason
     */
    protected static void error(int status, String reason) {
        throw new Error(status, reason);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.