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