OIM API to Search Audit Events

  1. package com.oimacademy.NeedEvaluate;
  2. import java.util.HashMap;
  3. import java.util.List;
  4. import java.util.Map;
  5. import com.connection.Platform;
  6. import oracle.iam.auditevent.api.AuditEventManager;
  7. import oracle.iam.auditevent.vo.AuditConstants;
  8. import oracle.iam.auditevent.vo.AuditEvent;
  9. import oracle.iam.platform.entitymgr.NoSuchEntityException;
  10. import oracle.iam.platform.entitymgr.exception.AccessDeniedException;
  11. import oracle.iam.platform.entitymgr.exception.EntitySearchException;
  12. import oracle.iam.platform.entitymgr.exception.ValidationFailedException;
  13. import oracle.iam.platform.entitymgr.spi.entity.Searchable;
  14. import oracle.iam.platform.entitymgr.vo.EntityConstants;
  15. public class AuditEventManagerSearch {
  16.  public static void main(String[] args) {
  17.   AuditEventManager auditEventManager = Platform.getService(AuditEventManager.class);
  18.   Map<String, Object> sorting = new HashMap<String, Object>();
  19.   sorting.put((String)EntityConstants.SORT_ATTR_NAME, AuditConstants.CONTAINED_ENTITY_TYPE);
  20.   sorting.put((String)EntityConstants.SORT_ORDER, Searchable.SortOrder.ASCENDING);
  21.   /*sorting.put((String)EntityConstants.START, Long.valueOf(1));
  22.   sorting.put((String)EntityConstants.END, Long.valueOf(50));*/
  23.   try {
  24.    List<AuditEvent> resultList = auditEventManager.search(null, null, sorting);
  25.    System.out.println(" Size- > "+resultList.size());
  26.    for(AuditEvent event :resultList ){
  27.     System.out.println("Entity Key -> "+event.getEntityId()+" Entity Type - > "+event.getContainedEntityType());
  28.    } 
  29.   } catch (EntitySearchException | NoSuchEntityException | ValidationFailedException | AccessDeniedException e) {
  30.    // TODO Auto-generated catch block
  31.    e.printStackTrace();
  32.   }
  33.  }
  34. }

No comments:

Post a Comment