001package com.box.sdk; 002 003import com.eclipsesource.json.JsonObject; 004import com.eclipsesource.json.JsonValue; 005import java.text.ParseException; 006import java.util.Date; 007import java.util.HashMap; 008import java.util.Map; 009 010/** 011 * Represents an event that was fired off by the Box events API. 012 */ 013@BoxResourceType("event") 014public class BoxEvent extends BoxResource { 015 private BoxResource.Info sourceInfo; 016 private BoxEvent.Type type; 017 private BoxEvent.EventType eventType; 018 private JsonObject sourceJSON; 019 private Date createdAt; 020 private String ipAddress; 021 private JsonObject additionalDetails; 022 private BoxCollaborator.Info accessibleBy; 023 private BoxUser.Info createdBy; 024 private String sessionID; 025 private BoxUser.Info actionBy; 026 027 /** 028 * Constructs a BoxEvent from a JSON string. 029 * 030 * @param api the API connection to be used by the file. 031 * @param json the JSON encoded event. 032 */ 033 public BoxEvent(BoxAPIConnection api, String json) { 034 this(api, JsonObject.readFrom(json)); 035 } 036 037 BoxEvent(BoxAPIConnection api, JsonObject jsonObject) { 038 super(api, jsonObject.get("event_id").asString()); 039 040 for (JsonObject.Member member : jsonObject) { 041 if (member.getValue().isNull()) { 042 continue; 043 } 044 045 this.parseJsonMember(member); 046 } 047 } 048 049 /** 050 * Gets info about the source of this event. 051 * 052 * <p>Note that there is a bug in the enterprise event stream where certain event sources don't correctly map to a 053 * BoxResource.Info. In the case where the event source JSON cannot be mapped to a BoxResource.Info, you can use the 054 * {@link #getSourceJSON} method to access the raw JSON representation of the event source.</p> 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 enterprise event sources 066 * don't correctly map to a BoxResource.Info. In this case, this method can be used to access the raw JSON 067 * directly.</p> 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 * @deprecated use getEventType instead. 080 */ 081 @Deprecated 082 public BoxEvent.Type getType() { 083 return this.type; 084 } 085 086 /** 087 * Gets the type of this event. 088 * 089 * @return the type of this event. 090 */ 091 public BoxEvent.EventType getEventType() { 092 return this.eventType; 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 if (memberName.equals("source")) { 171 // Parsing the source might fail due to a bug in the enterprise event stream where the API returns JSON that 172 // doesn't correctly map to a BoxResource.Info. If this happens, we set the sourceInfo to null and expect 173 // the caller to use the getSourceJSON() method instead. 174 try { 175 this.sourceInfo = BoxResource.parseInfo(this.getAPI(), value.asObject()); 176 } catch (Exception e) { 177 this.sourceInfo = null; 178 } 179 this.sourceJSON = JsonObject.unmodifiableObject(value.asObject()); 180 } else if (memberName.equals("event_type")) { 181 String stringValue = value.asString(); 182 for (Type t : Type.values()) { 183 if (t.name().equals(stringValue)) { 184 this.type = t; 185 break; 186 } 187 } 188 189 this.eventType = BoxEvent.EventType.lookupByValue(stringValue); 190 191 if (this.type == null || this.eventType == null) { 192 this.type = Type.UNKNOWN; 193 this.eventType = EventType.UNKNOWN; 194 } 195 } else if (memberName.equals("created_at")) { 196 try { 197 this.createdAt = BoxDateFormat.parse(value.asString()); 198 } catch (ParseException e) { 199 assert false : "A ParseException indicates a bug in the SDK."; 200 } 201 } else if (memberName.equals("ip_address")) { 202 this.ipAddress = value.asString(); 203 } else if (memberName.equals("additional_details")) { 204 this.additionalDetails = value.asObject(); 205 } else if (memberName.equals("accessible_by")) { 206 this.accessibleBy = (BoxCollaborator.Info) BoxResource.parseInfo(this.getAPI(), value.asObject()); 207 } else if (memberName.equals("created_by")) { 208 this.createdBy = (BoxUser.Info) BoxResource.parseInfo(this.getAPI(), value.asObject()); 209 } else if (memberName.equals("session_id")) { 210 this.sessionID = value.asString(); 211 } else if (memberName.equals("action_by")) { 212 this.actionBy = (BoxUser.Info) BoxResource.parseInfo(this.getAPI(), value.asObject()); 213 } 214 } 215 216 /** 217 * Enumerates the possible types for an event. 218 * 219 * @deprecated use EventType instead. 220 */ 221 @Deprecated 222 public enum Type { 223 /** 224 * The type of the event is unknown. 225 */ 226 UNKNOWN, 227 228 /** 229 * An file or folder was created. 230 */ 231 ITEM_CREATE, 232 233 /** 234 * An file or folder was uploaded. 235 */ 236 ITEM_UPLOAD, 237 238 /** 239 * A comment was created on a folder, file, or other comment. 240 */ 241 COMMENT_CREATE, 242 243 /** 244 * A comment was deleted on a folder, file, or other comment. 245 */ 246 COMMENT_DELETE, 247 248 /** 249 * An file or folder was downloaded. 250 */ 251 ITEM_DOWNLOAD, 252 253 /** 254 * A file was previewed. 255 */ 256 ITEM_PREVIEW, 257 258 /** 259 * A file or folder was moved. 260 */ 261 ITEM_MOVE, 262 263 /** 264 * A file or folder was copied. 265 */ 266 ITEM_COPY, 267 268 /** 269 * A task was assigned. 270 */ 271 TASK_ASSIGNMENT_CREATE, 272 273 /** 274 * A task was assignment was completed. 275 */ 276 TASK_ASSIGNMENT_COMPLETE, 277 278 /** 279 * A task was assignment was updated. 280 */ 281 TASK_ASSIGNMENT_UPDATE, 282 283 284 /** 285 * A task was created. 286 */ 287 TASK_CREATE, 288 289 /** 290 * A file was locked. 291 */ 292 LOCK_CREATE, 293 294 /** 295 * A file was unlocked. 296 */ 297 LOCK_DESTROY, 298 299 /** 300 * A file or folder was deleted. 301 */ 302 ITEM_TRASH, 303 304 /** 305 * A file or folder was recovered from the trash. 306 */ 307 ITEM_UNDELETE_VIA_TRASH, 308 309 /** 310 * A collaborator was added to a folder. 311 */ 312 COLLAB_ADD_COLLABORATOR, 313 314 /** 315 * A collaborator's role was change in a folder. 316 */ 317 COLLAB_ROLE_CHANGE, 318 319 /** 320 * A collaborator was invited to a folder. 321 */ 322 COLLAB_INVITE_COLLABORATOR, 323 324 /** 325 * A collaborator was removed from a folder. 326 */ 327 COLLAB_REMOVE_COLLABORATOR, 328 329 /** 330 * A folder was marked for sync. 331 */ 332 ITEM_SYNC, 333 334 /** 335 * A folder was un-marked for sync. 336 */ 337 ITEM_UNSYNC, 338 339 /** 340 * A file or folder was renamed. 341 */ 342 ITEM_RENAME, 343 344 /** 345 * A file or folder was enabled for sharing. 346 */ 347 ITEM_SHARED_CREATE, 348 349 /** 350 * A file or folder was disabled for sharing. 351 */ 352 ITEM_SHARED_UNSHARE, 353 354 /** 355 * A folder was shared. 356 */ 357 ITEM_SHARED, 358 359 /** 360 * A previous version of a file was promoted to the current version. 361 */ 362 ITEM_MAKE_CURRENT_VERSION, 363 364 /** 365 * A tag was added to a file or folder. 366 */ 367 TAG_ITEM_CREATE, 368 369 /** 370 * 2 factor authentication enabled by user. 371 */ 372 ENABLE_TWO_FACTOR_AUTH, 373 374 /** 375 * Free user accepts invitation to become a managed user. 376 */ 377 MASTER_INVITE_ACCEPT, 378 379 /** 380 * Free user rejects invitation to become a managed user. 381 */ 382 MASTER_INVITE_REJECT, 383 384 /** 385 * Granted Box access to account. 386 */ 387 ACCESS_GRANTED, 388 389 /** 390 * Revoke Box access to account. 391 */ 392 ACCESS_REVOKED, 393 394 /** 395 * A user logged in from a new device. 396 */ 397 ADD_LOGIN_ACTIVITY_DEVICE, 398 399 /** 400 * A user session associated with an app was invalidated. 401 */ 402 REMOVE_LOGIN_ACTIVITY_DEVICE, 403 404 /** 405 * An admin role changed for a user. 406 */ 407 CHANGE_ADMIN_ROLE, 408 409 /** 410 * A user was added to a group. This is an enterprise-only event. 411 */ 412 GROUP_ADD_USER, 413 414 /** 415 * A user was created. This is an enterprise-only event. 416 */ 417 NEW_USER, 418 419 /** 420 * A group was created. This is an enterprise-only event. 421 */ 422 GROUP_CREATION, 423 424 /** 425 * A group was deleted. This is an enterprise-only event. 426 */ 427 GROUP_DELETION, 428 429 /** 430 * A user was deleted. This is an enterprise-only event. 431 */ 432 DELETE_USER, 433 434 /** 435 * A group was edited. This is an enterprise-only event. 436 */ 437 GROUP_EDITED, 438 439 /** 440 * A user was edited. This is an enterprise-only event. 441 */ 442 EDIT_USER, 443 444 /** 445 * A group was granted access to a folder. This is an enterprise-only event. 446 */ 447 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, 453 454 /** 455 * A user was removed from a group. This is an enterprise-only event. 456 */ 457 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, 463 464 /** 465 * A group had its access to a file removed. This is an enterprise-only event. 466 */ 467 GROUP_REMOVE_FILE, 468 469 /** 470 * An administrator logged in. This is an enterprise-only event. 471 */ 472 ADMIN_LOGIN, 473 474 /** 475 * A device was associated with a user. This is an enterprise-only event. 476 */ 477 ADD_DEVICE_ASSOCIATION, 478 479 /** 480 * There was a failed login attempt. This is an enterprise-only event. 481 */ 482 FAILED_LOGIN, 483 484 /** 485 * There was a successful login. This is an enterprise-only event. 486 */ 487 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, 493 494 /** 495 * A device was disassociated with a user. This is an enterprise-only event. 496 */ 497 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, 503 504 /** 505 * A user rejected the terms of service. This is an enterprise-only event. 506 */ 507 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, 514 515 /** 516 * An item was copied. This is an enterprise-only event. 517 */ 518 COPY, 519 520 /** 521 * An item was deleted. This is an enterprise-only event. 522 */ 523 DELETE, 524 525 /** 526 * An item was downloaded. This is an enterprise-only event. 527 */ 528 DOWNLOAD, 529 530 /** 531 * An item was edited. This is an enterprise-only event. 532 */ 533 EDIT, 534 535 /** 536 * An item was locked. This is an enterprise-only event. 537 */ 538 LOCK, 539 540 /** 541 * An item was moved. This is an enterprise-only event. 542 */ 543 MOVE, 544 545 /** 546 * An item was previewed. This is an enterprise-only event. 547 */ 548 PREVIEW, 549 550 /** 551 * An item was renamed. This is an enterprise-only event. 552 */ 553 RENAME, 554 555 /** 556 * An item was set to be auto-deleted. This is an enterprise-only event. 557 */ 558 STORAGE_EXPIRATION, 559 560 /** 561 * An item was undeleted. This is an enterprise-only event. 562 */ 563 UNDELETE, 564 565 /** 566 * An item was unlocked. This is an enterprise-only event. 567 */ 568 UNLOCK, 569 570 /** 571 * An item was uploaded. This is an enterprise-only event. 572 */ 573 UPLOAD, 574 575 /** 576 * An shared link was created for an item. This is an enterprise-only event. 577 */ 578 SHARE, 579 580 /** 581 * The shared link for an item was updated. This is an enterprise-only event. 582 */ 583 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, 589 590 /** 591 * The expiration time was set for a shared link. This is an enterprise-only event. 592 */ 593 SHARE_EXPIRATION, 594 595 /** 596 * The shared link for an item was REMOVE_DEVICE_ASSOCIATION. This is an enterprise-only event. 597 */ 598 UNSHARE, 599 600 /** 601 * A user accepted a collaboration invite. This is an enterprise-only event. 602 */ 603 COLLABORATION_ACCEPT, 604 605 /** 606 * A user's collaboration role was changed. This is an enterprise-only event. 607 */ 608 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, 614 615 /** 616 * A collaboration was removed from a folder. This is an enterprise-only event. 617 */ 618 COLLABORATION_REMOVE, 619 620 /** 621 * A user was invited to collaborate on a folder. This is an enterprise-only event. 622 */ 623 COLLABORATION_INVITE, 624 625 /** 626 * An expiration time was set for a collaboration. This is an enterprise-only event. 627 */ 628 COLLABORATION_EXPIRATION, 629 630 /** 631 * Creation of metadata instance. This is an enterprise-only event. 632 */ 633 METADATA_INSTANCE_CREATE, 634 635 /** 636 * Update of metadata instance. This is an enterprise-only event. 637 */ 638 METADATA_INSTANCE_UPDATE, 639 640 /** 641 * Deletion of metadata instance. This is an enterprise-only event. 642 */ 643 METADATA_INSTANCE_DELETE, 644 645 /** 646 * Content Workflow upload policy violation. This is an enterprise-only event. 647 */ 648 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, 654 655 /** 656 * A task assignment is deleted. This is an enterprise-only event. 657 */ 658 TASK_ASSIGNMENT_DELETE, 659 660 /** 661 * Retention is removed. This is an enterprise-only event. 662 */ 663 DATA_RETENTION_REMOVE_RETENTION, 664 665 /** 666 * Retention is created. This is an enterprise-only event. 667 */ 668 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, 674 675 /** 676 * A legal hold assignment is created. This is an enterprise-only event. 677 */ 678 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, 684 685 /** 686 * A legal hold policy is deleted. This is an enterprise-only event. 687 */ 688 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, 694 695 /** 696 * An application public key is added. This is an enterprise-only event. 697 */ 698 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, 704 705 /** 706 * A content policy is added. This is an enterprise-only event. 707 */ 708 CONTENT_WORKFLOW_POLICY_ADD, 709 710 /** 711 * An automation is added. This is an enterprise-only event. 712 */ 713 CONTENT_WORKFLOW_AUTOMATION_ADD, 714 715 /** 716 * An automation is deleted. This is an enterprise-only event. 717 */ 718 CONTENT_WORKFLOW_AUTOMATION_DELETE, 719 720 /** 721 * A user email alias is confirmed. This is an enterprise-only event. 722 */ 723 EMAIL_ALIAS_CONFIRM, 724 725 /** 726 * A user email alias is removed. This is an enterprise-only event. 727 */ 728 EMAIL_ALIAS_REMOVE, 729 730 /** 731 * A watermark is added to a file. This is an enterprise-only event. 732 */ 733 WATERMARK_LABEL_CREATE, 734 735 /** 736 * A watermark is removed from a file. This is an enterprise-only event. 737 */ 738 WATERMARK_LABEL_DELETE, 739 740 /** 741 * Creation of metadata template instance. This is an enterprise-only event. 742 */ 743 METADATA_TEMPLATE_CREATE, 744 745 /** 746 * Update of metadata template instance. This is an enterprise-only event. 747 */ 748 METADATA_TEMPLATE_UPDATE, 749 750 /** 751 * Deletion of metadata template instance. This is an enterprise-only event. 752 */ 753 METADATA_TEMPLATE_DELETE, 754 755 /** 756 * Item was opened. This is an enterprise-only event. 757 */ 758 ITEM_OPEN, 759 760 /** 761 * Item was modified. This is an enterprise-only event. 762 */ 763 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, 769 770 /** 771 * Folders were removed from a group in the Admin console. This is an enterprise-only event. 772 */ 773 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, 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, 784 785 /** 786 * Event for file tag updates. 787 */ 788 CONTENT_ACCESS, 789 790 /** 791 * A Shield justification is approved. 792 */ 793 SHIELD_JUSTIFICATION_APPROVAL, 794 795 /** 796 * A task's comment is edited. 797 */ 798 TASK_UPDATE, 799 800 /** 801 * A file is retored to previous version. 802 */ 803 FILE_VERSION_RESTORE, 804 805 /** 806 * Advanced settings of a folder are updated. 807 */ 808 ADVANCED_FOLDER_SETTINGS_UPDATE; 809 } 810 811 /** 812 * Enumerates the possible types for an event. 813 */ 814 public enum EventType { 815 /** 816 * The type of the event is unknown. 817 */ 818 UNKNOWN("UNKNOWN"), 819 820 /** 821 * An file or folder was created. 822 */ 823 ITEM_CREATE("ITEM_CREATE"), 824 825 /** 826 * An file or folder was uploaded. 827 */ 828 ITEM_UPLOAD("ITEM_UPLOAD"), 829 830 /** 831 * A comment was created on a folder, file, or other comment. 832 */ 833 COMMENT_CREATE("COMMENT_CREATE"), 834 835 /** 836 * A comment was deleted on a folder, file, or other comment. 837 */ 838 COMMENT_DELETE("COMMENT_DELETE"), 839 840 /** 841 * An file or folder was downloaded. 842 */ 843 ITEM_DOWNLOAD("ITEM_DOWNLOAD"), 844 845 /** 846 * A file was previewed. 847 */ 848 ITEM_PREVIEW("ITEM_PREVIEW"), 849 850 /** 851 * A file or folder was moved. 852 */ 853 ITEM_MOVE("ITEM_MOVE"), 854 855 /** 856 * A file or folder was copied. 857 */ 858 ITEM_COPY("ITEM_COPY"), 859 860 /** 861 * A task was assigned. 862 */ 863 TASK_ASSIGNMENT_CREATE("TASK_ASSIGNMENT_CREATE"), 864 865 /** 866 * A task was assignment was completed. 867 */ 868 TASK_ASSIGNMENT_COMPLETE("TASK_ASSIGNMENT_COMPLETE"), 869 870 /** 871 * A task was assignment was updated. 872 */ 873 TASK_ASSIGNMENT_UPDATE("TASK_ASSIGNMENT_UPDATE"), 874 875 /** 876 * A task was created. 877 */ 878 TASK_CREATE("TASK_CREATE"), 879 880 /** 881 * A file was locked. 882 */ 883 LOCK_CREATE("LOCK_CREATE"), 884 885 /** 886 * A file was unlocked. 887 */ 888 LOCK_DESTROY("LOCK_DESTROY"), 889 890 /** 891 * A file or folder was deleted. 892 */ 893 ITEM_TRASH("ITEM_TRASH"), 894 895 /** 896 * A file or folder was recovered from the trash. 897 */ 898 ITEM_UNDELETE_VIA_TRASH("ITEM_UNDELETE_VIA_TRASH"), 899 900 /** 901 * A collaborator was added to a folder. 902 */ 903 COLLAB_ADD_COLLABORATOR("COLLAB_ADD_COLLABORATOR"), 904 905 /** 906 * A collaborator's role was change in a folder. 907 */ 908 COLLAB_ROLE_CHANGE("COLLAB_ROLE_CHANGE"), 909 910 /** 911 * A collaborator was invited to a folder. 912 */ 913 COLLAB_INVITE_COLLABORATOR("COLLAB_INVITE_COLLABORATOR"), 914 915 /** 916 * A collaborator was removed from a folder. 917 */ 918 COLLAB_REMOVE_COLLABORATOR("COLLAB_REMOVE_COLLABORATOR"), 919 920 /** 921 * A folder was marked for sync. 922 */ 923 ITEM_SYNC("ITEM_SYNC"), 924 925 /** 926 * A folder was un-marked for sync. 927 */ 928 ITEM_UNSYNC("ITEM_UNSYNC"), 929 930 /** 931 * A file or folder was renamed. 932 */ 933 ITEM_RENAME("ITEM_RENAME"), 934 935 /** 936 * A file or folder was enabled for sharing. 937 */ 938 ITEM_SHARED_CREATE("ITEM_SHARED_CREATE"), 939 940 /** 941 * A file or folder was disabled for sharing. 942 */ 943 ITEM_SHARED_UNSHARE("ITEM_SHARED_UNSHARE"), 944 945 /** 946 * A folder was shared. 947 */ 948 ITEM_SHARED("ITEM_SHARED"), 949 950 /** 951 * A previous version of a file was promoted to the current version. 952 */ 953 ITEM_MAKE_CURRENT_VERSION("ITEM_MAKE_CURRENT_VERSION"), 954 955 /** 956 * A tag was added to a file or folder. 957 */ 958 TAG_ITEM_CREATE("TAG_ITEM_CREATE"), 959 960 /** 961 * 2 factor authentication enabled by user. 962 */ 963 ENABLE_TWO_FACTOR_AUTH("ENABLE_TWO_FACTOR_AUTH"), 964 965 /** 966 * Free user accepts invitation to become a managed user. 967 */ 968 ADMIN_INVITE_ACCEPT("MASTER_INVITE_ACCEPT"), 969 970 /** 971 * Free user rejects invitation to become a managed user. 972 */ 973 ADMIN_INVITE_REJECT("MASTER_INVITE_REJECT"), 974 975 /** 976 * Granted Box access to account. 977 */ 978 ACCESS_GRANTED("ACCESS_GRANTED"), 979 980 /** 981 * Revoke Box access to account. 982 */ 983 ACCESS_REVOKED("ACCESS_REVOKED"), 984 985 /** 986 * A user logged in from a new device. 987 */ 988 ADD_LOGIN_ACTIVITY_DEVICE("ADD_LOGIN_ACTIVITY_DEVICE"), 989 990 /** 991 * A user session associated with an app was invalidated. 992 */ 993 REMOVE_LOGIN_ACTIVITY_DEVICE("REMOVE_LOGIN_ACTIVITY_DEVICE"), 994 995 /** 996 * An admin role changed for a user. 997 */ 998 CHANGE_ADMIN_ROLE("CHANGE_ADMIN_ROLE"), 999 1000 /** 1001 * A user was added to a group. This is an enterprise-only event. 1002 */ 1003 GROUP_ADD_USER("GROUP_ADD_USER"), 1004 1005 /** 1006 * A user was created. This is an enterprise-only event. 1007 */ 1008 NEW_USER("NEW_USER"), 1009 1010 /** 1011 * A group was created. This is an enterprise-only event. 1012 */ 1013 GROUP_CREATION("GROUP_CREATION"), 1014 1015 /** 1016 * A group was deleted. This is an enterprise-only event. 1017 */ 1018 GROUP_DELETION("GROUP_DELETION"), 1019 1020 /** 1021 * A user was deleted. This is an enterprise-only event. 1022 */ 1023 DELETE_USER("DELETE_USER"), 1024 1025 /** 1026 * A group was edited. This is an enterprise-only event. 1027 */ 1028 GROUP_EDITED("GROUP_EDITED"), 1029 1030 /** 1031 * A user was edited. This is an enterprise-only event. 1032 */ 1033 EDIT_USER("EDIT_USER"), 1034 1035 /** 1036 * A group was granted access to a folder. This is an enterprise-only event. 1037 */ 1038 GROUP_ADD_FOLDER("GROUP_ADD_FOLDER"), 1039 1040 /** 1041 * A group was granted access to a file. This is an enterprise-only event. 1042 */ 1043 GROUP_ADD_FILE("GROUP_ADD_FILE"), 1044 1045 /** 1046 * A user was removed from a group. This is an enterprise-only event. 1047 */ 1048 GROUP_REMOVE_USER("GROUP_REMOVE_USER"), 1049 1050 /** 1051 * A group had its access to a folder removed. This is an enterprise-only event. 1052 */ 1053 GROUP_REMOVE_FOLDER("GROUP_REMOVE_FOLDER"), 1054 1055 /** 1056 * A group had its access to a file removed. This is an enterprise-only event. 1057 */ 1058 GROUP_REMOVE_FILE("GROUP_REMOVE_FILE"), 1059 1060 /** 1061 * An administrator logged in. This is an enterprise-only event. 1062 */ 1063 ADMIN_LOGIN("ADMIN_LOGIN"), 1064 1065 /** 1066 * A device was associated with a user. This is an enterprise-only event. 1067 */ 1068 ADD_DEVICE_ASSOCIATION("ADD_DEVICE_ASSOCIATION"), 1069 1070 /** 1071 * There was a failed login attempt. This is an enterprise-only event. 1072 */ 1073 FAILED_LOGIN("FAILED_LOGIN"), 1074 1075 /** 1076 * There was a successful login. This is an enterprise-only event. 1077 */ 1078 LOGIN("LOGIN"), 1079 1080 /** 1081 * A user's OAuth2 access token was refreshed. This is an enterprise-only event. 1082 */ 1083 USER_AUTHENTICATE_OAUTH2_TOKEN_REFRESH("USER_AUTHENTICATE_OAUTH2_TOKEN_REFRESH"), 1084 1085 /** 1086 * A device was disassociated with a user. This is an enterprise-only event. 1087 */ 1088 REMOVE_DEVICE_ASSOCIATION("REMOVE_DEVICE_ASSOCIATION"), 1089 1090 /** 1091 * A user agreed to the terms of service. This is an enterprise-only event. 1092 */ 1093 TERMS_OF_SERVICE_AGREE("TERMS_OF_SERVICE_AGREE"), 1094 1095 /** 1096 * A user rejected the terms of service. This is an enterprise-only event. 1097 */ 1098 TERMS_OF_SERVICE_REJECT("TERMS_OF_SERVICE_REJECT"), 1099 1100 /** 1101 * Virus found on a file. Event is only received by enterprises that have opted in to be notified. 1102 * This is an enterprise-only event. 1103 */ 1104 FILE_MARKED_MALICIOUS("FILE_MARKED_MALICIOUS"), 1105 1106 /** 1107 * An item was copied. This is an enterprise-only event. 1108 */ 1109 COPY("COPY"), 1110 1111 /** 1112 * An item was deleted. This is an enterprise-only event. 1113 */ 1114 DELETE("DELETE"), 1115 1116 /** 1117 * An item was downloaded. This is an enterprise-only event. 1118 */ 1119 DOWNLOAD("DOWNLOAD"), 1120 1121 /** 1122 * An item was edited. This is an enterprise-only event. 1123 */ 1124 EDIT("EDIT"), 1125 1126 /** 1127 * An item was locked. This is an enterprise-only event. 1128 */ 1129 LOCK("LOCK"), 1130 1131 /** 1132 * An item was moved. This is an enterprise-only event. 1133 */ 1134 MOVE("MOVE"), 1135 1136 /** 1137 * An item was previewed. This is an enterprise-only event. 1138 */ 1139 PREVIEW("PREVIEW"), 1140 1141 /** 1142 * An item was renamed. This is an enterprise-only event. 1143 */ 1144 RENAME("RENAME"), 1145 1146 /** 1147 * An item was set to be auto-deleted. This is an enterprise-only event. 1148 */ 1149 STORAGE_EXPIRATION("STORAGE_EXPIRATION"), 1150 1151 /** 1152 * An item was undeleted. This is an enterprise-only event. 1153 */ 1154 UNDELETE("UNDELETE"), 1155 1156 /** 1157 * An item was unlocked. This is an enterprise-only event. 1158 */ 1159 UNLOCK("UNLOCK"), 1160 1161 /** 1162 * An item was uploaded. This is an enterprise-only event. 1163 */ 1164 UPLOAD("UPLOAD"), 1165 1166 /** 1167 * An shared link was created for an item. This is an enterprise-only event. 1168 */ 1169 SHARE("SHARE"), 1170 1171 /** 1172 * The shared link for an item was updated. This is an enterprise-only event. 1173 */ 1174 ITEM_SHARED_UPDATE("ITEM_SHARED_UPDATE"), 1175 1176 /** 1177 * The expiration time for a shared link was extended. This is an enterprise-only event. 1178 */ 1179 UPDATE_SHARE_EXPIRATION("UPDATE_SHARE_EXPIRATION"), 1180 1181 /** 1182 * The expiration time was set for a shared link. This is an enterprise-only event. 1183 */ 1184 SHARE_EXPIRATION("SHARE_EXPIRATION"), 1185 1186 /** 1187 * The shared link for an item was REMOVE_DEVICE_ASSOCIATION. This is an enterprise-only event. 1188 */ 1189 UNSHARE("UNSHARE"), 1190 1191 /** 1192 * A user accepted a collaboration invite. This is an enterprise-only event. 1193 */ 1194 COLLABORATION_ACCEPT("COLLABORATION_ACCEPT"), 1195 1196 /** 1197 * A user's collaboration role was changed. This is an enterprise-only event. 1198 */ 1199 COLLABORATION_ROLE_CHANGE("COLLABORATION_ROLE_CHANGE"), 1200 1201 /** 1202 * The expiration time for a collaboration was extended. This is an enterprise-only event. 1203 */ 1204 UPDATE_COLLABORATION_EXPIRATION("UPDATE_COLLABORATION_EXPIRATION"), 1205 1206 /** 1207 * A collaboration was removed from a folder. This is an enterprise-only event. 1208 */ 1209 COLLABORATION_REMOVE("COLLABORATION_REMOVE"), 1210 1211 /** 1212 * A user was invited to collaborate on a folder. This is an enterprise-only event. 1213 */ 1214 COLLABORATION_INVITE("COLLABORATION_INVITE"), 1215 1216 /** 1217 * An expiration time was set for a collaboration. This is an enterprise-only event. 1218 */ 1219 COLLABORATION_EXPIRATION("COLLABORATION_EXPIRATION"), 1220 1221 /** 1222 * Creation of metadata instance. This is an enterprise-only event. 1223 */ 1224 METADATA_INSTANCE_CREATE("METADATA_INSTANCE_CREATE"), 1225 1226 /** 1227 * Update of metadata instance. This is an enterprise-only event. 1228 */ 1229 METADATA_INSTANCE_UPDATE("METADATA_INSTANCE_UPDATE"), 1230 1231 /** 1232 * Deletion of metadata instance. This is an enterprise-only event. 1233 */ 1234 METADATA_INSTANCE_DELETE("METADATA_INSTANCE_DELETE"), 1235 1236 /** 1237 * Content Workflow upload policy violation. This is an enterprise-only event. 1238 */ 1239 CONTENT_WORKFLOW_UPLOAD_POLICY_VIOLATION("CONTENT_WORKFLOW_UPLOAD_POLICY_VIOLATION"), 1240 1241 /** 1242 * Edit the permissions on a folder. This is an enterprise-only-event. 1243 */ 1244 CHANGE_FOLDER_PERMISSION("CHANGE_FOLDER_PERMISSION"), 1245 1246 /** 1247 * A task assignment is deleted. This is an enterprise-only event. 1248 */ 1249 TASK_ASSIGNMENT_DELETE("TASK_ASSIGNMENT_DELETE"), 1250 1251 /** 1252 * Retention is removed. This is an enterprise-only event. 1253 */ 1254 DATA_RETENTION_REMOVE_RETENTION("DATA_RETENTION_REMOVE_RETENTION"), 1255 1256 /** 1257 * Retention is created. This is an enterprise-only event. 1258 */ 1259 DATA_RETENTION_CREATE_RETENTION("DATA_RETENTION_CREATE_RETENTION"), 1260 1261 /** 1262 * A retention policy assignment is added. This is an enterprise-only event. 1263 */ 1264 RETENTION_POLICY_ASSIGNMENT_ADD("RETENTION_POLICY_ASSIGNMENT_ADD"), 1265 1266 /** 1267 * A legal hold assignment is created. This is an enterprise-only event. 1268 */ 1269 LEGAL_HOLD_ASSIGNMENT_CREATE("LEGAL_HOLD_ASSIGNMENT_CREATE"), 1270 1271 /** 1272 * A legal hold assignment is deleted. This is an enterprise-only event. 1273 */ 1274 LEGAL_HOLD_ASSIGNMENT_DELETE("LEGAL_HOLD_ASSIGNMENT_DELETE"), 1275 1276 /** 1277 * A legal hold policy is deleted. This is an enterprise-only event. 1278 */ 1279 LEGAL_HOLD_POLICY_DELETE("LEGAL_HOLD_POLICY_DELETE"), 1280 1281 /** 1282 * There is a sharing policy violation. This is an enterprise-only event. 1283 */ 1284 CONTENT_WORKFLOW_SHARING_POLICY_VIOLATION("CONTENT_WORKFLOW_SHARING_POLICY_VIOLATION"), 1285 1286 /** 1287 * An application public key is added. This is an enterprise-only event. 1288 */ 1289 APPLICATION_PUBLIC_KEY_ADDED("APPLICATION_PUBLIC_KEY_ADDED"), 1290 1291 /** 1292 * An application public key is deleted. This is an enterprise-only event. 1293 */ 1294 APPLICATION_PUBLIC_KEY_DELETED("APPLICATION_PUBLIC_KEY_DELETED"), 1295 1296 /** 1297 * A content policy is added. This is an enterprise-only event. 1298 */ 1299 CONTENT_WORKFLOW_POLICY_ADD("CONTENT_WORKFLOW_POLICY_ADD"), 1300 1301 /** 1302 * An automation is added. This is an enterprise-only event. 1303 */ 1304 CONTENT_WORKFLOW_AUTOMATION_ADD("CONTENT_WORKFLOW_AUTOMATION_ADD"), 1305 1306 /** 1307 * An automation is deleted. This is an enterprise-only event. 1308 */ 1309 CONTENT_WORKFLOW_AUTOMATION_DELETE("CONTENT_WORKFLOW_AUTOMATION_DELETE"), 1310 1311 /** 1312 * A user email alias is confirmed. This is an enterprise-only event. 1313 */ 1314 EMAIL_ALIAS_CONFIRM("EMAIL_ALIAS_CONFIRM"), 1315 1316 /** 1317 * A user email alias is removed. This is an enterprise-only event. 1318 */ 1319 EMAIL_ALIAS_REMOVE("EMAIL_ALIAS_REMOVE"), 1320 1321 /** 1322 * A watermark is added to a file. This is an enterprise-only event. 1323 */ 1324 WATERMARK_LABEL_CREATE("WATERMARK_LABEL_CREATE"), 1325 1326 /** 1327 * A watermark is removed from a file. This is an enterprise-only event. 1328 */ 1329 WATERMARK_LABEL_DELETE("WATERMARK_LABEL_DELETE"), 1330 1331 /** 1332 * Creation of metadata template instance. This is an enterprise-only event. 1333 */ 1334 METADATA_TEMPLATE_CREATE("METADATA_TEMPLATE_CREATE"), 1335 1336 /** 1337 * Update of metadata template instance. This is an enterprise-only event. 1338 */ 1339 METADATA_TEMPLATE_UPDATE("METADATA_TEMPLATE_UPDATE"), 1340 1341 /** 1342 * Deletion of metadata template instance. This is an enterprise-only event. 1343 */ 1344 METADATA_TEMPLATE_DELETE("METADATA_TEMPLATE_DELETE"), 1345 1346 /** 1347 * Item was opened. This is an enterprise-only event. 1348 */ 1349 ITEM_OPEN("ITEM_OPEN"), 1350 1351 /** 1352 * Item was modified. This is an enterprise-only event. 1353 */ 1354 ITEM_MODIFY("ITEM_MODIFY"), 1355 1356 /** 1357 * When a policy set in the Admin console is triggered. This is an enterprise-only event, 1358 */ 1359 CONTENT_WORKFLOW_ABNORMAL_DOWNLOAD_ACTIVITY("CONTENT_WORKFLOW_ABNORMAL_DOWNLOAD_ACTIVITY"), 1360 1361 /** 1362 * Folders were removed from a group in the Admin console. This is an enterprise-only event. 1363 */ 1364 GROUP_REMOVE_ITEM("GROUP_REMOVE_ITEM"), 1365 1366 /** 1367 * Folders were added to a group in the Admin console. This is an enterprise-only event. 1368 */ 1369 GROUP_ADD_ITEM("GROUP_ADD_ITEM"), 1370 1371 /** 1372 * An OAuth2 access token was created for a user. This is an enterprise-only event. 1373 */ 1374 USER_AUTHENTICATE_OAUTH2_ACCESS_TOKEN_CREATE("USER_AUTHENTICATE_OAUTH2_ACCESS_TOKEN_CREATE"), 1375 1376 /** 1377 * Event for file tag updates. 1378 */ 1379 CONTENT_ACCESS("CONTENT_ACCESS"), 1380 1381 /** 1382 * A Shield justification is approved. 1383 */ 1384 SHIELD_JUSTIFICATION_APPROVAL("SHIELD_JUSTIFICATION_APPROVAL"), 1385 1386 /** 1387 * A task's comment is edited. 1388 */ 1389 TASK_UPDATE("TASK_UPDATE"), 1390 1391 /** 1392 * A file is retored to previous version. 1393 */ 1394 FILE_VERSION_RESTORE("FILE_VERSION_RESTORE"), 1395 1396 /** 1397 * Advanced settings of a folder are updated. 1398 */ 1399 ADVANCED_FOLDER_SETTINGS_UPDATE("ADVANCED_FOLDER_SETTINGS_UPDATE"); 1400 1401 /** 1402 * Static map of all EventTypes. 1403 */ 1404 private static final Map<String, BoxEvent.EventType> EVENT_TYPE_MAP = 1405 new HashMap<String, BoxEvent.EventType>(EventType.values().length); 1406 1407 /** 1408 * EVENT_TYPE_MAP initialization. 1409 */ 1410 static { 1411 for (BoxEvent.EventType event : BoxEvent.EventType.values()) { 1412 EVENT_TYPE_MAP.put(event.jsonValue, event); 1413 } 1414 } 1415 1416 /** 1417 * String representation of the eventType. 1418 */ 1419 private final String jsonValue; 1420 1421 /** 1422 * Constructor. 1423 * 1424 * @param jsonValue string representation of the eventType. 1425 */ 1426 EventType(String jsonValue) { 1427 this.jsonValue = jsonValue; 1428 } 1429 1430 /** 1431 * Creates the eventType from given string. 1432 * 1433 * @param jsonValue string to be converted to role. 1434 * @return the role, created from string value. 1435 */ 1436 static BoxEvent.EventType fromJSONString(String jsonValue) { 1437 for (BoxEvent.EventType type : BoxEvent.EventType.values()) { 1438 if (type.jsonValue.equalsIgnoreCase(jsonValue)) { 1439 return type; 1440 } 1441 } 1442 throw new IllegalArgumentException("Invalid value for enum EventType: " + jsonValue); 1443 } 1444 1445 /** 1446 * Custom implementation of valueOf(). 1447 * 1448 * @param jsonValue of the EventType. 1449 * @return EventType. 1450 */ 1451 static BoxEvent.EventType lookupByValue(String jsonValue) { 1452 return EVENT_TYPE_MAP.get(jsonValue); 1453 } 1454 1455 /** 1456 * @return string representation of the eventType. 1457 */ 1458 String toJSONString() { 1459 return this.jsonValue; 1460 } 1461 } 1462}