SHARE
TWEET

Untitled

a guest Jul 19th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.cisco.wx2.atlas.common.bean.server;
  2.  
  3. import java.util.List;
  4. import java.util.Map;
  5.  
  6. import javax.annotation.Nullable;
  7.  
  8. import org.apache.commons.collections4.CollectionUtils;
  9. import org.apache.commons.lang3.StringUtils;
  10.  
  11. import com.cisco.wx2.atlas.common.AdminConstants;
  12. import com.cisco.wx2.atlas.common.bean.commerce.order.OrderingTool;
  13. import com.cisco.wx2.atlas.common.bean.metrics.ProvisioningMetricEvent.OnboardMethod;
  14. import com.cisco.wx2.atlas.common.bean.order.CustomerType;
  15. import com.cisco.wx2.atlas.common.bean.server.EntitlementBean.EntitlementState;
  16. import com.cisco.wx2.atlas.common.bean.server.LicenseBean.LicenseOperation;
  17. import com.cisco.wx2.dto.IdentityName;
  18. import com.cisco.wx2.util.EmailAddress;
  19. import com.fasterxml.jackson.annotation.JsonCreator;
  20. import com.fasterxml.jackson.annotation.JsonIgnore;
  21. import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
  22. import com.fasterxml.jackson.annotation.JsonProperty;
  23.  
  24. @JsonIgnoreProperties(value = { "autoTemplate" })
  25. public class UserCreationBean extends UserBaseRequestBean implements Cloneable {
  26.  
  27.     private List<EntitlementBean> userEntitlements;
  28.     private List<LicenseBean> licenses;
  29.     private OrderingTool onboardType;
  30.     private Map<String, String> resourceGroupProps;
  31.     private OnboardMethod onboardMethod = OnboardMethod.API;
  32.  
  33.     //Attributes from csv for Jabber on Teams
  34.     private Boolean teamsOnJabberEnabled;
  35.     private Boolean ucCallOnJabberEnabled;
  36.     private String profileName;
  37.     private String upgradeProfileName;
  38.     private String operation;
  39.     private Boolean contactMigrationRequired;
  40.     private String callingBehavior;
  41.  
  42.     private boolean autoTemplate = false;
  43.     //One cannot pass customerType as request payload, its computed based on licenses at org level and then set
  44.     private CustomerType customerType = null;
  45.     /**
  46.      * if true, will remove freemium entitlements if every license is removed for this user.
  47.      * default behavior in ATLAS is to keep freemium entitlements.
  48.      */
  49.     boolean removeFreemiumEntitlementsWhenCancelSubscription = false;
  50.  
  51.     @JsonCreator
  52.     public UserCreationBean(@JsonProperty("email") final String email,
  53.                             @Nullable @JsonProperty("displayName") final String displayName,
  54.                             @Nullable @JsonProperty("name") final IdentityName name,
  55.                             @Nullable @JsonProperty("userEntitlements") final List<EntitlementBean> userEntitlements,
  56.                             @Nullable @JsonProperty("licenses") final List<LicenseBean> licenses,
  57.                             @Nullable @JsonProperty("onboardType") final OrderingTool onboardType,
  58.                             @Nullable @JsonProperty("resourceGroupProps") final Map<String, String> resourceGroupProps,
  59.                             @Nullable @JsonProperty("onboardMethod") final OnboardMethod onboardMethod,
  60.                             @Nullable @JsonProperty("isTeamsOnJabberEnabled") final Boolean teamsOnJabberEnabled,
  61.                             @Nullable @JsonProperty("isUCCallOnJabberEnabled") final Boolean ucCallOnJabberEnabled,
  62.                             @Nullable @JsonProperty("operation") final String operation,
  63.                             @Nullable @JsonProperty("profileName") final String profileName,
  64.                             @Nullable @JsonProperty("contactMigrationRequired") final Boolean contactMigrationRequired,
  65.                             @Nullable @JsonProperty("callingBehavior") final String callingBehavior) {
  66.         super(email, displayName, name);
  67.  
  68.         this.userEntitlements = userEntitlements;
  69.         this.setLicenses(licenses);
  70.         this.onboardType = onboardType;
  71.         if (onboardType == null) {
  72.             this.onboardType = OrderingTool.CCW;
  73.         }
  74.         this.setResourceGroupProps(resourceGroupProps);
  75.         if (onboardMethod != null) {
  76.             this.onboardMethod = onboardMethod;
  77.         }
  78.         this.teamsOnJabberEnabled = teamsOnJabberEnabled;
  79.         this.ucCallOnJabberEnabled = ucCallOnJabberEnabled;
  80.         this.operation = operation;
  81.         this.profileName = profileName;
  82.         this.contactMigrationRequired = contactMigrationRequired;
  83.         this.callingBehavior = callingBehavior;
  84.     }
  85.  
  86.     public UserCreationBean(final EmailAddress email, final String displayName, final IdentityName name,
  87.                             final List<EntitlementBean> userEntitlements, final List<LicenseBean> licenses,
  88.                             final OrderingTool onboardType, final Map<String, String> resourceGroupProps,
  89.                             final OnboardMethod onboardMethod) {
  90.         this(email.toString(), displayName, name, userEntitlements, licenses, onboardType, resourceGroupProps, onboardMethod, null, null, null, null, null, null);
  91.  
  92.     }
  93.  
  94.     public UserCreationBean(final EmailAddress email, final String displayName, final IdentityName name,
  95.                             final List<EntitlementBean> userEntitlements, final List<LicenseBean> licenses,
  96.                             final OrderingTool onboardType) {
  97.         this(email.toString(), displayName, name, userEntitlements, licenses, onboardType, null, null, null, null, null, null, null, null);
  98.     }
  99.  
  100.     public UserCreationBean(final EmailAddress email, final String displayName, final IdentityName name) {
  101.         super(email, displayName, name);
  102.     }
  103.  
  104.     public UserCreationBean(final EmailAddress email, final String displayName, final IdentityName name,
  105.                             OnboardMethod onboardMethod) {
  106.         this(email, displayName, null, null, null, null, null, onboardMethod);
  107.     }
  108.  
  109.     public UserCreationBean(final EmailAddress email, final String displayName) {
  110.         this(email, displayName, null, null, null, null, null, null);
  111.     }
  112.  
  113.     public UserCreationBean(final EmailAddress email, final List<LicenseBean> userLicenses) {
  114.         this(email, null, null, null, userLicenses, null, null, null);
  115.     }
  116.  
  117.     public UserCreationBean(final EmailAddress email, final List<EntitlementBean> userEntitlements,
  118.                             final List<LicenseBean> userLicenses) {
  119.         this(email, null, null, userEntitlements, userLicenses, null, null, null);
  120.     }
  121.  
  122.     public UserCreationBean(final EmailAddress email, final String displayName, final List<EntitlementBean> userEntitlements,
  123.                             final List<LicenseBean> userLicenses) {
  124.         this(email, displayName, null, userEntitlements, userLicenses, null, null, null);
  125.     }
  126.  
  127.     public UserCreationBean(final EmailAddress email, final String displayName, final List<EntitlementBean> userEntitlements,
  128.                             final List<LicenseBean> userLicenses, final OrderingTool orderingTool) {
  129.         this(email, displayName, null, userEntitlements, userLicenses, orderingTool, null, null);
  130.     }
  131.  
  132.     public UserCreationBean(final EmailAddress email, final String displayName, final IdentityName name,
  133.                             final List<EntitlementBean> userEntitlements, final List<LicenseBean> licenses) {
  134.         this(email, displayName, name, userEntitlements, licenses, null, null, null);
  135.     }
  136.  
  137.     public UserCreationBean(final EmailAddress email, final String displayName, final List<EntitlementBean> multipleEntitleBean) {
  138.         this(email, displayName, null, multipleEntitleBean, null, null, null, null);
  139.     }
  140.  
  141.     public UserCreationBean(final EmailAddress email, final String displayName, final Map<String, String> resourceGroupProps) {
  142.         this(email, displayName, null, null, null, null, resourceGroupProps, null);
  143.     }
  144.  
  145.     public UserCreationBean(final String email, final String displayName, final IdentityName name,
  146.                             final OnboardMethod onboardMethod) {
  147.         this(email, displayName, null, null, null, null, null, onboardMethod, false, false, null, null, null,
  148.                 AdminConstants.DEFAULT_USER_CALLING_BEHAVIOR);
  149.     }
  150.  
  151.     public UserCreationBean(final String email, final String displayName, final Boolean isTeamsOnJabberEnabled,
  152.                             final Boolean isUCCallOnJabberEnabled, final String profileName,
  153.                             final Boolean contactMigrationRequired) {
  154.         this(email, displayName, null, null, null, null, null, null, isTeamsOnJabberEnabled, isUCCallOnJabberEnabled, null,
  155.                 profileName, contactMigrationRequired, AdminConstants.DEFAULT_USER_CALLING_BEHAVIOR);
  156.     }
  157.  
  158.     public UserCreationBean(final String email, final String displayName, final IdentityName name) {
  159.         super(email, displayName, name);
  160.     }
  161.  
  162.     public EmailAddress getEmail(final String email) {
  163.         return EmailAddress.fromString(email);
  164.     }
  165.  
  166.     public List<EntitlementBean> getUserEntitlements() {
  167.         return userEntitlements;
  168.     }
  169.  
  170.     public void setUserEntitlements(final List<EntitlementBean> userEntitlements) {
  171.         this.userEntitlements = userEntitlements;
  172.     }
  173.  
  174.     public List<LicenseBean> getLicenses() {
  175.         return licenses;
  176.     }
  177.  
  178.     public void setLicenses(final List<LicenseBean> licenses) {
  179.         this.licenses = licenses;
  180.     }
  181.  
  182.     public OrderingTool getOnboardType() {
  183.         return onboardType;
  184.     }
  185.  
  186.     public void setOnboardType(final OrderingTool onboardType) {
  187.         this.onboardType = onboardType;
  188.     }
  189.  
  190.     public Map<String, String> getResourceGroupProps() {
  191.         return resourceGroupProps;
  192.     }
  193.  
  194.     public void setResourceGroupProps(final Map<String, String> resourceGroupProps) {
  195.         this.resourceGroupProps = resourceGroupProps;
  196.     }
  197.  
  198.     public Boolean getTeamsOnJabberEnabled() {
  199.         return teamsOnJabberEnabled;
  200.     }
  201.  
  202.     public void setTeamsOnJabberEnabled(Boolean teamsOnJabberEnabled) {
  203.         this.teamsOnJabberEnabled = teamsOnJabberEnabled;
  204.     }
  205.  
  206.     public Boolean getUCCallOnJabberEnabled() {
  207.         return ucCallOnJabberEnabled;
  208.     }
  209.  
  210.     public void setUCCallOnJabberEnabled(Boolean ucCallOnJabberEnabled) {
  211.         this.ucCallOnJabberEnabled = ucCallOnJabberEnabled;
  212.     }
  213.  
  214.     public String getProfileName() {
  215.         return profileName;
  216.     }
  217.  
  218.     public void setProfileName(String profileName) {
  219.         this.profileName = profileName;
  220.     }
  221.  
  222.     public String getUpgradeProfileName() {
  223.         return upgradeProfileName;
  224.     }
  225.  
  226.     public void setUpgradeProfileName(String upgradeProfileName) {
  227.         this.upgradeProfileName = upgradeProfileName;
  228.     }
  229.  
  230.     public String getOperation() {
  231.         return operation;
  232.     }
  233.  
  234.     public void setOperation(String operation) {
  235.         this.operation = operation;
  236.     }
  237.  
  238.     public Boolean getContactMigrationRequired() {
  239.         return contactMigrationRequired;
  240.     }
  241.  
  242.     public void setContactMigrationRequired(Boolean contactMigrationRequired) {
  243.         this.contactMigrationRequired = contactMigrationRequired;
  244.     }
  245.  
  246.     public String getCallingBehavior() {
  247.         return callingBehavior;
  248.     }
  249.  
  250.     public void setCallingBehavior(String callingBehavior) {
  251.         this.callingBehavior = callingBehavior;
  252.     }
  253.  
  254.     public boolean isContactMigrationRequired() {
  255.         if (this.contactMigrationRequired != null && this.contactMigrationRequired) {
  256.             return true;
  257.         }
  258.         return false;
  259.     }
  260.  
  261.     public boolean isTeamsOnJabberEnabled() {
  262.         if (this.teamsOnJabberEnabled != null && this.teamsOnJabberEnabled) {
  263.             return true;
  264.         }
  265.         return false;
  266.     }
  267.  
  268.     public boolean isUCCallOnJabberEnabled() {
  269.         if (this.ucCallOnJabberEnabled != null && this.ucCallOnJabberEnabled) {
  270.             return true;
  271.         }
  272.         return false;
  273.     }
  274.  
  275.     public boolean isUCCallOnJabberEnabledValid() {
  276.         if (!isUCCallOnJabberEnabled() && StringUtils.isNotEmpty(profileName)) {
  277.             return false;
  278.         }
  279.         return true;
  280.     }
  281.  
  282.     @Override
  283.     public String toString() {
  284.         return "UserCreationBean{" + "email=" + super.getEmail() + ", displayName='" + super.getDisplayName()
  285.                 + "\', userEntitlements=" + userEntitlements + ", licenses=" + licenses + ", onboardingType=" + onboardType
  286.                 + "\', ucCallOnJabberEnabled=" + ucCallOnJabberEnabled + ", teamsOnJabberEnabled=" + teamsOnJabberEnabled
  287.                 + ", profileName=" + profileName + ", upgradeProfileName=" + upgradeProfileName + ", contactMigrationRequired="
  288.                 + contactMigrationRequired + ", callingBehavior=" + callingBehavior + '}';
  289.     }
  290.  
  291.     @Override
  292.     public Object clone() throws CloneNotSupportedException {
  293.         return super.clone();
  294.     }
  295.  
  296.     /**
  297.      * if set to true, freemium entitlements should be removed when subscriptionCanceled
  298.      *
  299.      * @return
  300.      */
  301.     public boolean removeFreemiumEntitlementsWhenCancelSubscription() {
  302.         return removeFreemiumEntitlementsWhenCancelSubscription;
  303.     }
  304.  
  305.     public void setRemoveFreemiumEntitlements(boolean removeFreemiumEntitlements) {
  306.         this.removeFreemiumEntitlementsWhenCancelSubscription = removeFreemiumEntitlements;
  307.     }
  308.  
  309.     /**
  310.      * true if any of the licenses have operation ADD
  311.      *
  312.      * @return
  313.      */
  314.     public boolean isAddingLicense() {
  315.         if (CollectionUtils.isEmpty(this.licenses))
  316.             return false;
  317.         if (this.licenses.stream().anyMatch(e -> LicenseOperation.ADD.equals(e.getIdOperation())))
  318.             return true;
  319.         return false;
  320.     }
  321.  
  322.     /**
  323.      * true if any of user etitlements specified in Active state.
  324.      *
  325.      * @return
  326.      */
  327.     public boolean isAddingEntitlement() {
  328.         if (CollectionUtils.isEmpty(this.userEntitlements))
  329.             return false;
  330.         if (this.getUserEntitlements().stream().anyMatch(e -> EntitlementState.ACTIVE.equals(e.getEntitlementState())))
  331.             return true;
  332.         return false;
  333.     }
  334.  
  335.     @JsonIgnore
  336.     public boolean getAutoTemplate() {
  337.         return autoTemplate;
  338.     }
  339.  
  340.     public void setAutoTemplate(boolean enabled) {
  341.         autoTemplate = enabled;
  342.     }
  343.  
  344.     @JsonIgnore
  345.     public CustomerType getCustomerType() {
  346.         return customerType;
  347.     }
  348.  
  349.     public void setCustomerType(CustomerType customerType) {
  350.         this.customerType = customerType;
  351.     }
  352.  
  353.     public OnboardMethod getOnboardMethod() {
  354.         return onboardMethod;
  355.     }
  356.  
  357.     public void setOnboardMethod(OnboardMethod onboardMethod) {
  358.         this.onboardMethod = onboardMethod;
  359.     }
  360. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top