ALBPM Process API (PAPI)

fuego.papi
Class BatchOperationException

java.lang.Object
  extended byDefaultException
      extended byfuego.papi.BatchOperationException
Direct Known Subclasses:
ApplicationsNotAvailableException, AttachmentsNotAvailableException, FilterBatchOperationException, InstancesException, ProcessesNotAvailableException, TasksException, ViewsNotAvailableException

public abstract class BatchOperationException
extends DefaultException

Thrown when not all requested objects were retrieved or the executed operation was not performed correctly over every object.

The available objects can retrieved using getAvailableObjects and casting to the desired type, or useing the getAvailableXXX method of the appropriate subclass without casting, for example getAvailableInstances() in InstancesException.

To get the Exceptions per object, call getNotAvailableObjects, which returns a map with object Id as keys and Exceptions as values.
Example Usage:

          //get a ProcessServiceSession and a View.
          //get the instances, catching the BatchOperationException here, as we may still get a subset of instances
          InstanceInfo[] instances = new fuego.papi.InstanceInfo[0];
          try
          {
              instances = serviceSession.getInstancesByView((InstancesView) view);
          }
          catch (BatchOperationException e)
          {
              //if fail all, just print out the message, which contains all detail messages.
              if (e.failAll())
              {
                  System.out.println("Unable to retrieve any instances from the view " + e.getMessage());
                  return;
              }
              else
              {
                  //get the instances that we can retrieve, and print out any errors, but still continue.
                  instances = (InstanceInfo[]) e.getAvailableObjects();

                  //note that this could also be done by casting to an InstanceException,
                  // and then calling getAvailableInstances().
                  //getMessage(locale) from BatchOperationException concatenates all exceptions,
                  System.out.println("Batch Operation Exception when retrieving instances from the view " +
                  e.getMessage(Locale.getDefault()));

                  //to get the individual processes and exceptions, get the map of not available objects.
                  Map map = e.getNotAvailableObjects();
                  Iterator iter = map.entrySet().iterator();
                  while (iter.hasNext())
                  {
                      Map.Entry entry = (Map.Entry) iter.next();
                      String processId = (String) entry.getKey();
                      Throwable throwable = (Throwable) entry.getValue();
                      System.out.println("Failing processId = " + processId + "\n");
                      System.out.println("Exception class is " + throwable.getClass().getName() );
                      System.out.println(" and Exception message is " + throwable.getMessage());
                  }
              }
          }
 

See Also:
Serialized Form

Method Summary
 boolean failAll()
          Returns if the operation failed over every object.
 Object[] getAvailableObjects()
          Gets the valid returned values from the operation.
 String getMessage(Locale locale)
          Gets the message of the exception.
 Map getNotAvailableObjects()
          Gets the exception for each object which could not perform the corresponding operation.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getAvailableObjects

public Object[] getAvailableObjects()
Gets the valid returned values from the operation.

Returns:
array with the valid returned objects. null if there are not available objects.

getMessage

public String getMessage(Locale locale)
Gets the message of the exception.

The message is the composition of the user message, the administrative detail and the technical detail using the given locale. It also add the messages of the contained exceptions.

Parameters:
locale - desired locale
Returns:
the localized exception message
See Also:
#getMessage(), #getUserMessage(Locale), #getDetail(Locale), #getTechnicalDetail(Locale)

getNotAvailableObjects

public Map getNotAvailableObjects()
Gets the exception for each object which could not perform the corresponding operation.

Returns:
Map containig the exception for each object which could not perform the corresponding operation. The Map.key is the id of the object and the Map.value is the exception over it.

failAll

public boolean failAll()
Returns if the operation failed over every object.

Returns:
true if the operation failes over every object.

ALBPM Process API (PAPI)

© Copyright 1996/2005 Fuego Inc. All Rights Reserved