001package com.box.sdk; 002 003import com.eclipsesource.json.Json; 004import com.eclipsesource.json.JsonObject; 005import com.eclipsesource.json.JsonValue; 006import java.text.ParseException; 007import java.util.Date; 008import java.util.HashMap; 009import java.util.Map; 010 011/** Represents an event that was fired off by the Box events API. */ 012@BoxResourceType("event") 013public class BoxEvent extends BoxResource { 014 private BoxResource.Info sourceInfo; 015 private BoxEvent.EventType eventType; 016 private String typeName; 017 private JsonObject sourceJSON; 018 private Date createdAt; 019 private String ipAddress; 020 private JsonObject additionalDetails; 021 private BoxCollaborator.Info accessibleBy; 022 private BoxUser.Info createdBy; 023 private String sessionID; 024 private BoxUser.Info actionBy; 025 026 /** 027 * Constructs a BoxEvent from a JSON string. 028 * 029 * @param api the API connection to be used by the file. 030 * @param json the JSON encoded event. 031 */ 032 public BoxEvent(BoxAPIConnection api, String json) { 033 this(api, Json.parse(json).asObject()); 034 } 035 036 BoxEvent(BoxAPIConnection api, JsonObject jsonObject) { 037 super(api, jsonObject.get("event_id").asString()); 038 039 for (JsonObject.Member member : jsonObject) { 040 if (member.getValue().isNull()) { 041 continue; 042 } 043 044 this.parseJsonMember(member); 045 } 046 } 047 048 /** 049 * Gets info about the source of this event. 050 * 051 * <p>Note that there is a bug in the enterprise event stream where certain event sources don't 052 * correctly map to a BoxResource.Info. In the case where the event source JSON cannot be mapped 053 * to a BoxResource.Info, you can use the {@link #getSourceJSON} method to access the raw JSON 054 * representation of the event source. 055 * 056 * @return info about the source of this event. 057 */ 058 public BoxResource.Info getSourceInfo() { 059 return this.sourceInfo; 060 } 061 062 /** 063 * Gets the raw JSON object containing information about the source of this event. 064 * 065 * <p>This method can be used to work around bugs in the enterprise events API where some 066 * enterprise event sources don't correctly map to a BoxResource.Info. In this case, this method 067 * can be used to access the raw JSON directly. 068 * 069 * @return the JSON representation of the source of this event. 070 */ 071 public JsonObject getSourceJSON() { 072 return this.sourceJSON; 073 } 074 075 /** 076 * Gets the type of this event. 077 * 078 * @return the type of this event. 079 */ 080 public BoxEvent.EventType getEventType() { 081 return this.eventType; 082 } 083 084 /** 085 * Gets the type name as String. Every BoxEvent will have typeName, some will have eventType set 086 * to specific value and some will have eventType = UNKNOWN. 087 * 088 * @return the name of the type of this event. 089 */ 090 public String getTypeName() { 091 return this.typeName; 092 } 093 094 /** 095 * Gets the time that this event was created. 096 * 097 * @return the time that this event was created. 098 */ 099 public Date getCreatedAt() { 100 return this.createdAt; 101 } 102 103 /** 104 * Gets the IP address of the user that triggered this event. 105 * 106 * @return the IP address of the user that triggered this event. 107 */ 108 public String getIPAddress() { 109 return this.ipAddress; 110 } 111 112 /** 113 * Gets a JSON object containing additional details about this event. 114 * 115 * <p>The fields and data within the returned JSON object will vary depending on the type of the 116 * event. 117 * 118 * @return a JSON object containing additional details about this event. 119 */ 120 public JsonObject getAdditionalDetails() { 121 return this.additionalDetails; 122 } 123 124 /** 125 * Gets info about the collaborator who was given access to a folder within the current 126 * enterprise. 127 * 128 * <p>This field is only populated when the event is related to a collaboration that occurred 129 * within an enterprise. 130 * 131 * @return info about the collaborator who was given access to a folder within the current 132 * enterprise. 133 */ 134 public BoxCollaborator.Info getAccessibleBy() { 135 return this.accessibleBy; 136 } 137 138 /** 139 * Gets info about the user that triggered this event. 140 * 141 * @return info about the user that triggered this event. 142 */ 143 public BoxUser.Info getCreatedBy() { 144 return this.createdBy; 145 } 146 147 /** 148 * Gets the session ID of the user that triggered this event. 149 * 150 * @return the session ID of the user that triggered this event. 151 */ 152 public String getSessionID() { 153 return this.sessionID; 154 } 155 156 /** 157 * Gets the user that performed the action for this event. 158 * 159 * @return info about the user that performed that action for this event. 160 */ 161 public BoxUser.Info getActionBy() { 162 return this.actionBy; 163 } 164 165 void parseJsonMember(JsonObject.Member member) { 166 JsonValue value = member.getValue(); 167 if (value.isNull()) { 168 return; 169 } 170 171 String memberName = member.getName(); 172 switch (memberName) { 173 case "source": 174 // Parsing the source might fail due to a bug in the enterprise event stream where the API 175 // returns 176 // JSON that doesn't correctly map to a BoxResource.Info. If this happens, we set the 177 // sourceInfo to null 178 // and expect the caller to use the getSourceJSON() method instead. 179 try { 180 this.sourceInfo = BoxResource.parseInfo(this.getAPI(), value.asObject()); 181 } catch (Exception e) { 182 this.sourceInfo = null; 183 } 184 this.sourceJSON = JsonObject.unmodifiableObject(value.asObject()); 185 break; 186 case "event_type": 187 String stringValue = value.asString(); 188 this.typeName = stringValue; 189 this.eventType = EventType.lookupByValue(stringValue); 190 if (this.eventType == null) { 191 this.eventType = EventType.UNKNOWN; 192 } 193 break; 194 case "created_at": 195 try { 196 this.createdAt = BoxDateFormat.parse(value.asString()); 197 } catch (ParseException e) { 198 assert false : "A ParseException indicates a bug in the SDK."; 199 } 200 break; 201 case "ip_address": 202 this.ipAddress = value.asString(); 203 break; 204 case "additional_details": 205 this.additionalDetails = value.asObject(); 206 break; 207 case "accessible_by": 208 this.accessibleBy = 209 (BoxCollaborator.Info) BoxResource.parseInfo(this.getAPI(), value.asObject()); 210 break; 211 case "created_by": 212 this.createdBy = (BoxUser.Info) BoxResource.parseInfo(this.getAPI(), value.asObject()); 213 break; 214 case "session_id": 215 this.sessionID = value.asString(); 216 break; 217 case "action_by": 218 this.actionBy = (BoxUser.Info) BoxResource.parseInfo(this.getAPI(), value.asObject()); 219 break; 220 default: 221 break; 222 } 223 } 224 225 /** Enumerates the possible types for an event. */ 226 public enum EventType { 227 /** The type of the event is unknown. */ 228 UNKNOWN("UNKNOWN"), 229 230 /** An file or folder was created. */ 231 ITEM_CREATE("ITEM_CREATE"), 232 233 /** An file or folder was uploaded. */ 234 ITEM_UPLOAD("ITEM_UPLOAD"), 235 236 /** A comment was created on a folder, file, or other comment. */ 237 COMMENT_CREATE("COMMENT_CREATE"), 238 239 /** A comment was deleted on a folder, file, or other comment. */ 240 COMMENT_DELETE("COMMENT_DELETE"), 241 242 /** An file or folder was downloaded. */ 243 ITEM_DOWNLOAD("ITEM_DOWNLOAD"), 244 245 /** A file was previewed. */ 246 ITEM_PREVIEW("ITEM_PREVIEW"), 247 248 /** A file or folder was moved. */ 249 ITEM_MOVE("ITEM_MOVE"), 250 251 /** A file or folder was copied. */ 252 ITEM_COPY("ITEM_COPY"), 253 254 /** A task was assigned. */ 255 TASK_ASSIGNMENT_CREATE("TASK_ASSIGNMENT_CREATE"), 256 257 /** A task was assignment was completed. */ 258 TASK_ASSIGNMENT_COMPLETE("TASK_ASSIGNMENT_COMPLETE"), 259 260 /** A task was assignment was updated. */ 261 TASK_ASSIGNMENT_UPDATE("TASK_ASSIGNMENT_UPDATE"), 262 263 /** A task was created. */ 264 TASK_CREATE("TASK_CREATE"), 265 266 /** A file was locked. */ 267 LOCK_CREATE("LOCK_CREATE"), 268 269 /** A file was unlocked. */ 270 LOCK_DESTROY("LOCK_DESTROY"), 271 272 /** A file or folder was deleted. */ 273 ITEM_TRASH("ITEM_TRASH"), 274 275 /** A file or folder was recovered from the trash. */ 276 ITEM_UNDELETE_VIA_TRASH("ITEM_UNDELETE_VIA_TRASH"), 277 278 /** A collaborator was added to a folder. */ 279 COLLAB_ADD_COLLABORATOR("COLLAB_ADD_COLLABORATOR"), 280 281 /** A collaborator's role was change in a folder. */ 282 COLLAB_ROLE_CHANGE("COLLAB_ROLE_CHANGE"), 283 284 /** A collaborator was invited to a folder. */ 285 COLLAB_INVITE_COLLABORATOR("COLLAB_INVITE_COLLABORATOR"), 286 287 /** A collaborator was removed from a folder. */ 288 COLLAB_REMOVE_COLLABORATOR("COLLAB_REMOVE_COLLABORATOR"), 289 290 /** A folder was marked for sync. */ 291 ITEM_SYNC("ITEM_SYNC"), 292 293 /** A folder was un-marked for sync. */ 294 ITEM_UNSYNC("ITEM_UNSYNC"), 295 296 /** A file or folder was renamed. */ 297 ITEM_RENAME("ITEM_RENAME"), 298 299 /** A file or folder was enabled for sharing. */ 300 ITEM_SHARED_CREATE("ITEM_SHARED_CREATE"), 301 302 /** A file or folder was disabled for sharing. */ 303 ITEM_SHARED_UNSHARE("ITEM_SHARED_UNSHARE"), 304 305 /** A folder was shared. */ 306 ITEM_SHARED("ITEM_SHARED"), 307 308 /** A previous version of a file was promoted to the current version. */ 309 ITEM_MAKE_CURRENT_VERSION("ITEM_MAKE_CURRENT_VERSION"), 310 311 /** A tag was added to a file or folder. */ 312 TAG_ITEM_CREATE("TAG_ITEM_CREATE"), 313 314 /** 2 factor authentication enabled by user. */ 315 ENABLE_TWO_FACTOR_AUTH("ENABLE_TWO_FACTOR_AUTH"), 316 317 /** Free user accepts invitation to become a managed user. */ 318 ADMIN_INVITE_ACCEPT("MASTER_INVITE_ACCEPT"), 319 320 /** Free user rejects invitation to become a managed user. */ 321 ADMIN_INVITE_REJECT("MASTER_INVITE_REJECT"), 322 323 /** Granted Box access to account. */ 324 ACCESS_GRANTED("ACCESS_GRANTED"), 325 326 /** Revoke Box access to account. */ 327 ACCESS_REVOKED("ACCESS_REVOKED"), 328 329 /** A user logged in from a new device. */ 330 ADD_LOGIN_ACTIVITY_DEVICE("ADD_LOGIN_ACTIVITY_DEVICE"), 331 332 /** A user session associated with an app was invalidated. */ 333 REMOVE_LOGIN_ACTIVITY_DEVICE("REMOVE_LOGIN_ACTIVITY_DEVICE"), 334 335 /** An admin role changed for a user. */ 336 CHANGE_ADMIN_ROLE("CHANGE_ADMIN_ROLE"), 337 338 /** A user was added to a group. This is an enterprise-only event. */ 339 GROUP_ADD_USER("GROUP_ADD_USER"), 340 341 /** A user was created. This is an enterprise-only event. */ 342 NEW_USER("NEW_USER"), 343 344 /** A group was created. This is an enterprise-only event. */ 345 GROUP_CREATION("GROUP_CREATION"), 346 347 /** A group was deleted. This is an enterprise-only event. */ 348 GROUP_DELETION("GROUP_DELETION"), 349 350 /** A user was deleted. This is an enterprise-only event. */ 351 DELETE_USER("DELETE_USER"), 352 353 /** A group was edited. This is an enterprise-only event. */ 354 GROUP_EDITED("GROUP_EDITED"), 355 356 /** A user was edited. This is an enterprise-only event. */ 357 EDIT_USER("EDIT_USER"), 358 359 /** A group was granted access to a folder. This is an enterprise-only event. */ 360 GROUP_ADD_FOLDER("GROUP_ADD_FOLDER"), 361 362 /** A group was granted access to a file. This is an enterprise-only event. */ 363 GROUP_ADD_FILE("GROUP_ADD_FILE"), 364 365 /** A user was removed from a group. This is an enterprise-only event. */ 366 GROUP_REMOVE_USER("GROUP_REMOVE_USER"), 367 368 /** A group had its access to a folder removed. This is an enterprise-only event. */ 369 GROUP_REMOVE_FOLDER("GROUP_REMOVE_FOLDER"), 370 371 /** A group had its access to a file removed. This is an enterprise-only event. */ 372 GROUP_REMOVE_FILE("GROUP_REMOVE_FILE"), 373 374 /** An administrator logged in. This is an enterprise-only event. */ 375 ADMIN_LOGIN("ADMIN_LOGIN"), 376 377 /** A device was associated with a user. This is an enterprise-only event. */ 378 ADD_DEVICE_ASSOCIATION("ADD_DEVICE_ASSOCIATION"), 379 380 /** There was a failed login attempt. This is an enterprise-only event. */ 381 FAILED_LOGIN("FAILED_LOGIN"), 382 383 /** There was a successful login. This is an enterprise-only event. */ 384 LOGIN("LOGIN"), 385 386 /** A user's OAuth2 access token was refreshed. This is an enterprise-only event. */ 387 USER_AUTHENTICATE_OAUTH2_TOKEN_REFRESH("USER_AUTHENTICATE_OAUTH2_TOKEN_REFRESH"), 388 389 /** A device was disassociated with a user. This is an enterprise-only event. */ 390 REMOVE_DEVICE_ASSOCIATION("REMOVE_DEVICE_ASSOCIATION"), 391 392 /** A user agreed to the terms of service. This is an enterprise-only event. */ 393 TERMS_OF_SERVICE_AGREE("TERMS_OF_SERVICE_AGREE"), 394 395 /** A user rejected the terms of service. This is an enterprise-only event. */ 396 TERMS_OF_SERVICE_REJECT("TERMS_OF_SERVICE_REJECT"), 397 398 /** 399 * Virus found on a file. Event is only received by enterprises that have opted in to be 400 * notified. This is an enterprise-only event. 401 */ 402 FILE_MARKED_MALICIOUS("FILE_MARKED_MALICIOUS"), 403 404 /** An item was copied. This is an enterprise-only event. */ 405 COPY("COPY"), 406 407 /** An item was deleted. This is an enterprise-only event. */ 408 DELETE("DELETE"), 409 410 /** An item was downloaded. This is an enterprise-only event. */ 411 DOWNLOAD("DOWNLOAD"), 412 413 /** An item was edited. This is an enterprise-only event. */ 414 EDIT("EDIT"), 415 416 /** An item was locked. This is an enterprise-only event. */ 417 LOCK("LOCK"), 418 419 /** An item was moved. This is an enterprise-only event. */ 420 MOVE("MOVE"), 421 422 /** An item was previewed. This is an enterprise-only event. */ 423 PREVIEW("PREVIEW"), 424 425 /** An item was renamed. This is an enterprise-only event. */ 426 RENAME("RENAME"), 427 428 /** An item was set to be auto-deleted. This is an enterprise-only event. */ 429 STORAGE_EXPIRATION("STORAGE_EXPIRATION"), 430 431 /** An item was undeleted. This is an enterprise-only event. */ 432 UNDELETE("UNDELETE"), 433 434 /** An item was unlocked. This is an enterprise-only event. */ 435 UNLOCK("UNLOCK"), 436 437 /** An item was uploaded. This is an enterprise-only event. */ 438 UPLOAD("UPLOAD"), 439 440 /** An shared link was created for an item. This is an enterprise-only event. */ 441 SHARE("SHARE"), 442 443 /** The shared link for an item was updated. This is an enterprise-only event. */ 444 ITEM_SHARED_UPDATE("ITEM_SHARED_UPDATE"), 445 446 /** The expiration time for a shared link was extended. This is an enterprise-only event. */ 447 UPDATE_SHARE_EXPIRATION("UPDATE_SHARE_EXPIRATION"), 448 449 /** The expiration time was set for a shared link. This is an enterprise-only event. */ 450 SHARE_EXPIRATION("SHARE_EXPIRATION"), 451 452 /** 453 * The shared link for an item was REMOVE_DEVICE_ASSOCIATION. This is an enterprise-only event. 454 */ 455 UNSHARE("UNSHARE"), 456 457 /** A user accepted a collaboration invite. This is an enterprise-only event. */ 458 COLLABORATION_ACCEPT("COLLABORATION_ACCEPT"), 459 460 /** A user's collaboration role was changed. This is an enterprise-only event. */ 461 COLLABORATION_ROLE_CHANGE("COLLABORATION_ROLE_CHANGE"), 462 463 /** The expiration time for a collaboration was extended. This is an enterprise-only event. */ 464 UPDATE_COLLABORATION_EXPIRATION("UPDATE_COLLABORATION_EXPIRATION"), 465 466 /** A collaboration was removed from a folder. This is an enterprise-only event. */ 467 COLLABORATION_REMOVE("COLLABORATION_REMOVE"), 468 469 /** A user was invited to collaborate on a folder. This is an enterprise-only event. */ 470 COLLABORATION_INVITE("COLLABORATION_INVITE"), 471 472 /** An expiration time was set for a collaboration. This is an enterprise-only event. */ 473 COLLABORATION_EXPIRATION("COLLABORATION_EXPIRATION"), 474 475 /** Creation of metadata instance. This is an enterprise-only event. */ 476 METADATA_INSTANCE_CREATE("METADATA_INSTANCE_CREATE"), 477 478 /** Update of metadata instance. This is an enterprise-only event. */ 479 METADATA_INSTANCE_UPDATE("METADATA_INSTANCE_UPDATE"), 480 481 /** Deletion of metadata instance. This is an enterprise-only event. */ 482 METADATA_INSTANCE_DELETE("METADATA_INSTANCE_DELETE"), 483 484 /** Content Workflow upload policy violation. This is an enterprise-only event. */ 485 CONTENT_WORKFLOW_UPLOAD_POLICY_VIOLATION("CONTENT_WORKFLOW_UPLOAD_POLICY_VIOLATION"), 486 487 /** Edit the permissions on a folder. This is an enterprise-only-event. */ 488 CHANGE_FOLDER_PERMISSION("CHANGE_FOLDER_PERMISSION"), 489 490 /** A task assignment is deleted. This is an enterprise-only event. */ 491 TASK_ASSIGNMENT_DELETE("TASK_ASSIGNMENT_DELETE"), 492 493 /** Retention is removed. This is an enterprise-only event. */ 494 DATA_RETENTION_REMOVE_RETENTION("DATA_RETENTION_REMOVE_RETENTION"), 495 496 /** Retention is created. This is an enterprise-only event. */ 497 DATA_RETENTION_CREATE_RETENTION("DATA_RETENTION_CREATE_RETENTION"), 498 499 /** A retention policy assignment is added. This is an enterprise-only event. */ 500 RETENTION_POLICY_ASSIGNMENT_ADD("RETENTION_POLICY_ASSIGNMENT_ADD"), 501 502 /** A legal hold assignment is created. This is an enterprise-only event. */ 503 LEGAL_HOLD_ASSIGNMENT_CREATE("LEGAL_HOLD_ASSIGNMENT_CREATE"), 504 505 /** A legal hold assignment is deleted. This is an enterprise-only event. */ 506 LEGAL_HOLD_ASSIGNMENT_DELETE("LEGAL_HOLD_ASSIGNMENT_DELETE"), 507 508 /** A legal hold policy is deleted. This is an enterprise-only event. */ 509 LEGAL_HOLD_POLICY_DELETE("LEGAL_HOLD_POLICY_DELETE"), 510 511 /** There is a sharing policy violation. This is an enterprise-only event. */ 512 CONTENT_WORKFLOW_SHARING_POLICY_VIOLATION("CONTENT_WORKFLOW_SHARING_POLICY_VIOLATION"), 513 514 /** An application public key is added. This is an enterprise-only event. */ 515 APPLICATION_PUBLIC_KEY_ADDED("APPLICATION_PUBLIC_KEY_ADDED"), 516 517 /** An application public key is deleted. This is an enterprise-only event. */ 518 APPLICATION_PUBLIC_KEY_DELETED("APPLICATION_PUBLIC_KEY_DELETED"), 519 520 /** A content policy is added. This is an enterprise-only event. */ 521 CONTENT_WORKFLOW_POLICY_ADD("CONTENT_WORKFLOW_POLICY_ADD"), 522 523 /** An automation is added. This is an enterprise-only event. */ 524 CONTENT_WORKFLOW_AUTOMATION_ADD("CONTENT_WORKFLOW_AUTOMATION_ADD"), 525 526 /** An automation is deleted. This is an enterprise-only event. */ 527 CONTENT_WORKFLOW_AUTOMATION_DELETE("CONTENT_WORKFLOW_AUTOMATION_DELETE"), 528 529 /** A user email alias is confirmed. This is an enterprise-only event. */ 530 EMAIL_ALIAS_CONFIRM("EMAIL_ALIAS_CONFIRM"), 531 532 /** A user email alias is removed. This is an enterprise-only event. */ 533 EMAIL_ALIAS_REMOVE("EMAIL_ALIAS_REMOVE"), 534 535 /** A watermark is added to a file. This is an enterprise-only event. */ 536 WATERMARK_LABEL_CREATE("WATERMARK_LABEL_CREATE"), 537 538 /** A watermark is removed from a file. This is an enterprise-only event. */ 539 WATERMARK_LABEL_DELETE("WATERMARK_LABEL_DELETE"), 540 541 /** Creation of metadata template instance. This is an enterprise-only event. */ 542 METADATA_TEMPLATE_CREATE("METADATA_TEMPLATE_CREATE"), 543 544 /** Update of metadata template instance. This is an enterprise-only event. */ 545 METADATA_TEMPLATE_UPDATE("METADATA_TEMPLATE_UPDATE"), 546 547 /** Deletion of metadata template instance. This is an enterprise-only event. */ 548 METADATA_TEMPLATE_DELETE("METADATA_TEMPLATE_DELETE"), 549 550 /** Item was opened. This is an enterprise-only event. */ 551 ITEM_OPEN("ITEM_OPEN"), 552 553 /** Item was modified. This is an enterprise-only event. */ 554 ITEM_MODIFY("ITEM_MODIFY"), 555 556 /** When a policy set in the Admin console is triggered. This is an enterprise-only event, */ 557 CONTENT_WORKFLOW_ABNORMAL_DOWNLOAD_ACTIVITY("CONTENT_WORKFLOW_ABNORMAL_DOWNLOAD_ACTIVITY"), 558 559 /** Folders were removed from a group in the Admin console. This is an enterprise-only event. */ 560 GROUP_REMOVE_ITEM("GROUP_REMOVE_ITEM"), 561 562 /** Folders were added to a group in the Admin console. This is an enterprise-only event. */ 563 GROUP_ADD_ITEM("GROUP_ADD_ITEM"), 564 565 /** An OAuth2 access token was created for a user. This is an enterprise-only event. */ 566 USER_AUTHENTICATE_OAUTH2_ACCESS_TOKEN_CREATE("USER_AUTHENTICATE_OAUTH2_ACCESS_TOKEN_CREATE"), 567 568 /** Event for file tag updates. */ 569 CONTENT_ACCESS("CONTENT_ACCESS"), 570 571 /** A Shield justification is approved. */ 572 SHIELD_JUSTIFICATION_APPROVAL("SHIELD_JUSTIFICATION_APPROVAL"), 573 574 /** A task's comment is edited. */ 575 TASK_UPDATE("TASK_UPDATE"), 576 577 /** A file is retored to previous version. */ 578 FILE_VERSION_RESTORE("FILE_VERSION_RESTORE"), 579 580 /** Advanced settings of a folder are updated. */ 581 ADVANCED_FOLDER_SETTINGS_UPDATE("ADVANCED_FOLDER_SETTINGS_UPDATE"), 582 583 /** A new application is created in the Box Developer Console. */ 584 APPLICATION_CREATED("APPLICATION_CREATED"), 585 586 /** Device Trust check failed. */ 587 DEVICE_TRUST_CHECK_FAILED("DEVICE_TRUST_CHECK_FAILED"), 588 589 /** When a JWT application has been authorized or reauthorized. */ 590 ENTERPRISE_APP_AUTHORIZATION_UPDATE("ENTERPRISE_APP_AUTHORIZATION_UPDATE"), 591 592 /** A watermarked file is downloaded. */ 593 FILE_WATERMARKED_DOWNLOAD("FILE_WATERMARKED_DOWNLOAD"), 594 595 /** A legal hold policy is created. */ 596 LEGAL_HOLD_POLICY_CREATE("LEGAL_HOLD_POLICY_CREATE"), 597 598 /** A legal hold policy is updated. */ 599 LEGAL_HOLD_POLICY_UPDATE("LEGAL_HOLD_POLICY_UPDATE"), 600 601 /** 602 * Shield detected an anomalous download, session, location, or malicious content based on 603 * enterprise Shield rules. See shield alert events for more information. 604 */ 605 SHIELD_ALERT("SHIELD_ALERT"), 606 607 /** Access to an external collaboration is blocked. */ 608 SHIELD_EXTERNAL_COLLAB_ACCESS_BLOCKED("SHIELD_EXTERNAL_COLLAB_ACCESS_BLOCKED"), 609 610 /** Access to an external collaboration is blocked due to missing a justification. */ 611 SHIELD_EXTERNAL_COLLAB_ACCESS_BLOCKED_MISSING_JUSTIFICATION( 612 "SHIELD_EXTERNAL_COLLAB_ACCESS_BLOCKED_MISSING_JUSTIFICATION"), 613 614 /** An invite to externally collaborate is blocked. */ 615 SHIELD_EXTERNAL_COLLAB_INVITE_BLOCKED("SHIELD_EXTERNAL_COLLAB_INVITE_BLOCKED"), 616 617 /** An invite to externally collaborate is blocked due to missing a justification. */ 618 SHIELD_EXTERNAL_COLLAB_INVITE_BLOCKED_MISSING_JUSTIFICATION( 619 "SHIELD_EXTERNAL_COLLAB_INVITE_BLOCKED_MISSING_JUSTIFICATION"), 620 621 /** A sign request was sent to a signer. */ 622 SIGN_DOCUMENT_ASSIGNED("SIGN_DOCUMENT_ASSIGNED"), 623 624 /** A sign request was cancelled via API or UI. */ 625 SIGN_DOCUMENT_CANCELLED("SIGN_DOCUMENT_CANCELLED"), 626 627 /** A sign request was signed by all signers. */ 628 SIGN_DOCUMENT_COMPLETED("SIGN_DOCUMENT_COMPLETED"), 629 630 /** A sign request was converted to a .pdf for signing. */ 631 SIGN_DOCUMENT_CONVERTED("SIGN_DOCUMENT_CONVERTED"), 632 633 /** A sign request was created via API or UI. The document is not yet sent to signers. */ 634 SIGN_DOCUMENT_CREATED("SIGN_DOCUMENT_CREATED"), 635 636 /** A sign request was declined by a signer. */ 637 SIGN_DOCUMENT_DECLINED("SIGN_DOCUMENT_DECLINED"), 638 639 /** A sign request expired with incomplete signatures. */ 640 SIGN_DOCUMENT_EXPIRED("SIGN_DOCUMENT_EXPIRED"), 641 642 /** A sign request was signed by a signer. */ 643 SIGN_DOCUMENT_SIGNED("SIGN_DOCUMENT_SIGNED"), 644 645 /** A signer clicked on Review Document in the signer email or visited the signing URL. */ 646 SIGN_DOCUMENT_VIEWED_BY_SIGNER("SIGN_DOCUMENT_VIEWED_BY_SIGNER"), 647 648 /** A signer downloaded the signing document. */ 649 SIGNER_DOWNLOADED("SIGNER_DOWNLOADED"), 650 651 /** A signer forwarded the signing document. */ 652 SIGNER_FORWARDED("SIGNER_FORWARDED"), 653 654 /** Accepted terms. */ 655 TERMS_OF_SERVICE_ACCEPT("TERMS_OF_SERVICE_ACCEPT"); 656 657 /** Static map of all EventTypes. */ 658 private static final Map<String, BoxEvent.EventType> EVENT_TYPE_MAP = 659 new HashMap<>(EventType.values().length); 660 661 /* 662 EVENT_TYPE_MAP initialization. 663 */ 664 static { 665 for (BoxEvent.EventType event : BoxEvent.EventType.values()) { 666 EVENT_TYPE_MAP.put(event.jsonValue, event); 667 } 668 } 669 670 /** String representation of the eventType. */ 671 private final String jsonValue; 672 673 /** 674 * Constructor. 675 * 676 * @param jsonValue string representation of the eventType. 677 */ 678 EventType(String jsonValue) { 679 this.jsonValue = jsonValue; 680 } 681 682 /** 683 * Custom implementation of valueOf(). 684 * 685 * @param jsonValue of the EventType. 686 * @return EventType. 687 */ 688 static BoxEvent.EventType lookupByValue(String jsonValue) { 689 return EVENT_TYPE_MAP.get(jsonValue); 690 } 691 692 /** @return string representation of the eventType. */ 693 String toJSONString() { 694 return this.jsonValue; 695 } 696 } 697}