Search in sources :

Example 26 with SeekBookError

use of org.talend.services.test.library._1_0.SeekBookError in project tesb-rt-se by Talend.

the class LibraryServerImpl method prepareException.

private SeekBookError prepareException(String message) {
    ExceptionType exception = new ExceptionType();
    exception.setOperation("seekBook");
    exception.setServiceName("LibraryService");
    exception.setExceptionText(message);
    ExceptionFrame frame = new ExceptionFrame();
    frame.getException().add(exception);
    return new SeekBookError("Book not found", frame);
}
Also used : ExceptionType(org.talend.types.test.generalobjects.errorhandling._1.ExceptionType) SeekBookError(org.talend.services.test.library._1_0.SeekBookError) ExceptionFrame(org.talend.types.test.generalobjects.errorhandling._1.ExceptionFrame)

Example 27 with SeekBookError

use of org.talend.services.test.library._1_0.SeekBookError in project tesb-rt-se by Talend.

the class LibraryServerImpl method seekBook.

@Override
public ListOfBooks seekBook(SearchFor body) throws SeekBookError {
    System.out.println("***************************************************************");
    System.out.println("*** seekBook request (Request-Response operation) is received *");
    System.out.println("***************************************************************");
    showSeekBookRequest(body);
    List<String> authorsLastNames = body.getAuthorLastName();
    if (authorsLastNames != null && authorsLastNames.size() > 0) {
        String authorsLastName = authorsLastNames.get(0);
        if (authorsLastName != null && authorsLastName.length() > 0 && (!"Icebear".equalsIgnoreCase(authorsLastName)) && (!"Morillo".equalsIgnoreCase(authorsLastName))) {
            SeekBookError e = prepareException("No book available from author " + authorsLastName);
            System.out.println("No book available from author " + authorsLastName);
            System.out.println("\nSending business fault (SeekBook error) with parameters:");
            Utils.showSeekBookError(e);
            throw e;
        }
    }
    ListOfBooks result = new ListOfBooks();
    if (authorsLastNames.contains("Icebear")) {
        BookType book = new BookType();
        result.getBook().add(book);
        PersonType author = new PersonType();
        book.getAuthor().add(author);
        author.setFirstName("Jack");
        author.setLastName("Icebear");
        Calendar dateOfBirth = new GregorianCalendar(101, Calendar.JANUARY, 2);
        author.setDateOfBirth(dateOfBirth.getTime());
        book.getTitle().add("Survival in the Arctic");
        book.getPublisher().add("Frosty Edition");
        book.setYearPublished("2010");
    }
    if (authorsLastNames.contains("Morillo")) {
        BookType book = new BookType();
        result.getBook().add(book);
        PersonType author = new PersonType();
        book.getAuthor().add(author);
        author.setFirstName("David A.");
        author.setLastName("Morillo");
        Calendar dateOfBirth = new GregorianCalendar(1970, Calendar.JANUARY, 1);
        author.setDateOfBirth(dateOfBirth.getTime());
        book.getTitle().add("The book about software");
        book.getPublisher().add("Frosty Edition");
        book.setYearPublished("2006");
    }
    System.out.println("Book(s) is found:");
    showSeekBookResponse(result);
    return result;
}
Also used : BookType(org.talend.types.demos.library.common._1.BookType) SeekBookError(org.talend.services.demos.library._1_0.SeekBookError) GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) PersonType(org.talend.types.demos.library.common._1.PersonType) ListOfBooks(org.talend.types.demos.library.common._1.ListOfBooks)

Aggregations

SeekBookError (org.talend.services.test.library._1_0.SeekBookError)23 ListOfBooks (org.talend.types.test.library.common._1.ListOfBooks)16 Library (org.talend.services.test.library._1_0.Library)8 Calendar (java.util.Calendar)7 GregorianCalendar (java.util.GregorianCalendar)7 ExceptionFrame (org.talend.types.test.generalobjects.errorhandling._1.ExceptionFrame)5 ExceptionType (org.talend.types.test.generalobjects.errorhandling._1.ExceptionType)5 BookType (org.talend.types.test.library.common._1.BookType)5 PersonType (org.talend.types.test.library.common._1.PersonType)5 SearchFor (org.talend.types.test.library.common._1.SearchFor)5 SeekBookError (org.talend.services.demos.library._1_0.SeekBookError)4 ListOfBooks (org.talend.types.demos.library.common._1.ListOfBooks)3 BookType (org.talend.types.demos.library.common._1.BookType)2 PersonType (org.talend.types.demos.library.common._1.PersonType)2 CallContext (org.talend.esb.mep.requestcallback.feature.CallContext)1 CallContextStore (org.talend.esb.mep.requestcallback.impl.callcontext.CallContextStore)1 LibraryConsumer (org.talend.services.demos.library._1_0.LibraryConsumer)1 ExceptionFrame (org.talend.types.demos.generalobjects.errorhandling._1.ExceptionFrame)1 ExceptionType (org.talend.types.demos.generalobjects.errorhandling._1.ExceptionType)1 SearchFor (org.talend.types.demos.library.common._1.SearchFor)1