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