Guest User

Untitled

a guest
Feb 18th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.90 KB | None | 0 0
  1. CodecRegistry pojoCodecRegistry = fromRegistries(MongoClient.getDefaultCodecRegistry(),
  2. fromProviders(PojoCodecProvider.builder().automatic(true).build()));
  3. MongoClient mongoClient = new MongoClient("a.b.c", 2345);
  4. MongoDatabase database =
  5. mongoClient.getDatabase("rester").withCodecRegistry(pojoCodecRegistry);
  6. MongoCollection<Record> collection = database.getCollection("cloudtrail",
  7. Record.class);
  8. Block<Record> printBlock = new Block<Record>() {
  9.  
  10. @Override
  11. public void apply(final Record person) {
  12. System.out.println(person);
  13. }
  14. };
  15.  
  16. collection.find().forEach(printBlock);
  17.  
  18. org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class de.hpi.aws.model.events.Record.
  19.  
  20. public class Record {
  21. private ObjectId Mongoid;
  22. @Id
  23. @GeneratedValue(strategy = GenerationType.IDENTITY)
  24. private long id;
  25. @JsonProperty("eventVersion")
  26. private String eventVersion;
  27. @JsonProperty("userIdentity")
  28. private UserIdentity userIdentity;
  29. @JsonProperty("eventTime")
  30. private String eventTime;
  31. @JsonProperty("eventSource")
  32. private String eventSource;
  33. @JsonProperty("eventName")
  34. private String eventName;
  35. @JsonProperty("awsRegion")
  36. private String awsRegion;
  37. @JsonProperty("sourceIPAddress")
  38. private String sourceIPAddress;
  39. @JsonProperty("userAgent")
  40. private String userAgent;
  41. @JsonProperty("requestParameters")
  42. private RequestParameters requestParameters;
  43. @JsonProperty("additionalEventData")
  44. private AdditionalEventData additionalEventData;
  45. @JsonProperty("requestID")
  46. private String requestID;
  47. @JsonProperty("eventID")
  48. private String eventID;
  49. @JsonProperty("resources")
  50. private List<Resource> resources = new ArrayList<Resource>();
  51. @JsonProperty("eventType")
  52. private String eventType;
  53. @JsonProperty("recipientAccountId")
  54. private String recipientAccountId;
  55. @JsonProperty("sharedEventID")
  56. private String sharedEventID;
  57.  
  58. /**
  59. * No args constructor for use in serialization
  60. *
  61. */
  62. public Record() {
  63. }
  64.  
  65.  
  66. public Record(String eventVersion, UserIdentity userIdentity, String
  67. eventTime, String eventSource, String eventName, String awsRegion, String
  68. sourceIPAddress, String userAgent, RequestParameters requestParameters,
  69. AdditionalEventData additionalEventData, String requestID, String eventID,
  70. List<Resource> resources, String eventType, String recipientAccountId,
  71. String sharedEventID) {
  72. super();
  73. this.eventVersion = eventVersion;
  74. this.userIdentity = userIdentity;
  75. this.eventTime = eventTime;
  76. this.eventSource = eventSource;
  77. this.eventName = eventName;
  78. this.awsRegion = awsRegion;
  79. this.sourceIPAddress = sourceIPAddress;
  80. this.userAgent = userAgent;
  81. this.requestParameters = requestParameters;
  82. this.additionalEventData = additionalEventData;
  83. this.requestID = requestID;
  84. this.eventID = eventID;
  85. this.resources = resources;
  86. this.eventType = eventType;
  87. this.recipientAccountId = recipientAccountId;
  88. this.sharedEventID = sharedEventID;
  89. }
  90.  
  91. /**
  92. * setters & getters
  93. *
  94. */
Add Comment
Please, Sign In to add comment