Package evolaris.platform.smssvc.web.form

Examples of evolaris.platform.smssvc.web.form.SmsInteractionEnterOrEditForm


   *      org.apache.struts.action.ActionForm,
   *      javax.servlet.http.HttpServletRequest,
   *      javax.servlet.http.HttpServletResponse)
   */
  public ActionForward enter(ActionMapping mapping, ActionForm form,HttpServletRequest req, HttpServletResponse resp)  {
    SmsInteractionEnterOrEditForm smsInteractionEnterOrEditForm = (SmsInteractionEnterOrEditForm) form;

    if (smsInteractionEnterOrEditForm.getDestinationSelection() == null || smsInteractionEnterOrEditForm.getDestinationSelection() <= 0){
      smsInteractionEnterOrEditForm.setDestinationSelection(1)// initially select the sender as destination
      smsInteractionEnterOrEditForm.setCountryCode("43")// we are from Austria
      // everything else is empty/null => no selections
    }

    smsInteractionEnterOrEditForm.setSortLabel(sortLabelProposalFromSession(req));
   
    smsInteractionEnterOrEditForm.setSortLabel(sortLabelProposalFromSession(req));
    Group group = groupFromSession(req);
    checkAccessRights(req, group);

    // user sets
    prepareUserSets(req, smsInteractionEnterOrEditForm, group);
   
    // destination users
    Set<User> users = new HashSet<User>()// no user selection possible here
    SortedSet<SmsDestinationAddress> userAddresses = SmsDestinationAddress.smsDestinationAddresses(users);
    prepareUser(req, smsInteractionEnterOrEditForm, userAddresses);

    // prepare templates
    prepareTemplate(req, smsInteractionEnterOrEditForm);
   
    String[] senderList = configuredSenderMsisdns(req, group,null);
    req.getSession().setAttribute("msisdnList",senderList);
    if (group.getDefaultSender() != null) {
      smsInteractionEnterOrEditForm.setSendingMsisdn(group.getDefaultSender().getMsisdn()+"");
    } else {
      smsInteractionEnterOrEditForm.setSendingMsisdn(senderList[0])// first one is default
    }
    req.getSession().setAttribute("interactionGroupName",group.getGroupname());

    req.getSession().setAttribute("enterOrEdit", "enter");
    req.getSession().setAttribute("formActionPath", req.getParameter("formActionPath"));
View Full Code Here


   *      org.apache.struts.action.ActionForm,
   *      javax.servlet.http.HttpServletRequest,
   *      javax.servlet.http.HttpServletResponse)
   */
  public ActionForward edit(ActionMapping mapping, ActionForm form,HttpServletRequest req, HttpServletResponse resp)  {
    SmsInteractionEnterOrEditForm smsInteractionEnterOrEditForm = (SmsInteractionEnterOrEditForm) form;
    SmsCommandEntry smsCommandEntry = (SmsCommandEntry)commandEntryFromRequest(req);
    Group group = smsCommandEntry.getGroup();
    checkAccessRights(req, group);
    if (smsCommandEntry.getUseAsTemplate() == 1){
      req.getSession().setAttribute("attributeId", null)// application-independent selection lists in case of template editing
    }
   
    smsInteractionEnterOrEditForm.setCommandEntryId(smsCommandEntry.getId())// not to be used when editing
    smsInteractionEnterOrEditForm.setSortLabel(smsCommandEntry.getSortLabel());
    smsInteractionEnterOrEditForm.setMessage(smsCommandEntry.getTextContent());
    smsInteractionEnterOrEditForm.setDelayInSeconds(smsCommandEntry.getDelayInSeconds());
   
    prepareUserSets(req, smsInteractionEnterOrEditForm, group);
   
    // destination users (no users selectable because refresh does not work; already selected user may be inserted below)
    Set<User> users = new HashSet<User>();

    if(smsCommandEntry.getDestinationContact() == 1){
      smsInteractionEnterOrEditForm.setDestinationSelection(2);
      smsInteractionEnterOrEditForm.setCountryCode("43");
    } else if(smsCommandEntry.getDestinationUserSet() != null || smsCommandEntry.getCurrentUserSetAsDestination() == 1){
      smsInteractionEnterOrEditForm.setDestinationSelection(4);
      smsInteractionEnterOrEditForm.setUserSetId(smsCommandEntry.getDestinationUserSet() != null ? smsCommandEntry.getDestinationUserSet().getId() : -2);
      smsInteractionEnterOrEditForm.setCountryCode("43");
    } else if(smsCommandEntry.getDestinationUser() != null){
      smsInteractionEnterOrEditForm.setDestinationSelection(5);
      smsInteractionEnterOrEditForm.setUserId(smsCommandEntry.getDestinationUser().getId());
      users.add(smsCommandEntry.getDestinationUser());
      smsInteractionEnterOrEditForm.setCountryCode("43");
    } else if (smsCommandEntry.getDestinationMsisdn() != null){
      smsInteractionEnterOrEditForm.setDestinationSelection(6);
      smsInteractionEnterOrEditForm.setUserSetId(-1L);
      smsInteractionEnterOrEditForm.setCountryCode(UserManager.countryCode(smsCommandEntry.getDestinationMsisdn()));
      smsInteractionEnterOrEditForm.setMobileNumber(UserManager.mobileNumber(smsCommandEntry.getDestinationMsisdn()));
    } else { // the sender of the request is also the receiver
      smsInteractionEnterOrEditForm.setCountryCode("43");
      smsInteractionEnterOrEditForm.setDestinationSelection(1);
    }
    SortedSet<SmsDestinationAddress> userAddresses = SmsDestinationAddress.smsDestinationAddresses(users);
    prepareUser(req, smsInteractionEnterOrEditForm, userAddresses);

    String[] senderList = configuredSenderMsisdns(req, group,smsCommandEntry.getSender());
    smsInteractionEnterOrEditForm.setSendingMsisdn((smsCommandEntry.getSender() == null || senderList[0].startsWith("(")) ? senderList[0] :smsCommandEntry.getSender().getMsisdn() + "");

    req.getSession().setAttribute("msisdnList",senderList);
    req.getSession().setAttribute("interactionGroupName",group.getGroupname());

    CommandEntryManager commandEntryManager = new CommandEntryManager(locale,session);
View Full Code Here

   *      org.apache.struts.action.ActionForm,
   *      javax.servlet.http.HttpServletRequest,
   *      javax.servlet.http.HttpServletResponse)
   */
  public ActionForward modify(ActionMapping mapping, ActionForm form,HttpServletRequest req, HttpServletResponse resp)  {
    SmsInteractionEnterOrEditForm msgForm = (SmsInteractionEnterOrEditForm) form;
    long commandEntryId = msgForm.getCommandEntryId();
    CommandEntryManager commandEntryManager = new CommandEntryManager(locale,session);
    CommandEntry commandEntry = commandEntryManager.getCommandEntry(commandEntryId);
    if (commandEntry == null || !(commandEntry instanceof SmsCommandEntry)){
      throw new InputException(getResources(req).getMessage(locale, "smssvc.editedInteractionDoesNotExistAnymore"))// may have been deleted
    }
    SmsCommandEntry smsCommandEntry = (SmsCommandEntry)commandEntry;
    Group group = smsCommandEntry.getGroup();
    checkAccessRights(req, group);
    commandEntryManager.evict(smsCommandEntry)// do not modify in this session yet (might be erroneous)

    String messageText = msgForm.getMessage();
    if (grossSmsMessageLength(messageText) > MAX_MESSAGE_TEXT_LENGTH){
      throw new InputException(getResources(req).getMessage(locale,"smssvc.messageLongerThan450characters"));
    }
    Sender sender = senderFromMsisdn(req, msgForm.getSendingMsisdn(), group);
    SmsTextValidator.checkForValidLatin1AndSmsAllowingPlaceholders(msgForm.getMessage(), locale);
    smsCommandEntry.setSender(sender);
    smsCommandEntry.setTextContent(messageText);
    smsCommandEntry.setDelayInSeconds(msgForm.getDelayInSeconds());
   
    String sortLabel = msgForm.getSortLabel();
    smsCommandEntry.setSortLabel(sortLabel);

    switch (msgForm.getDestinationSelection().intValue()){
      case 1: // message return to sender
        smsCommandEntry.setDestinationContact(0);
        smsCommandEntry.setDestinationUserSet(null);
        smsCommandEntry.setDestinationUser(null);
        smsCommandEntry.setDestinationMsisdn(null);
        break;
      case 2: // contact
        smsCommandEntry.setDestinationContact(1);
        smsCommandEntry.setDestinationUserSet(null);
        smsCommandEntry.setDestinationUser(null);
        smsCommandEntry.setDestinationMsisdn(null);
        break;
      case 4: // message to user set
        smsCommandEntry.setDestinationContact(0);
        Long userSetId = msgForm.getUserSetId();
        if(userSetId.longValue() == -1){
          throw new BugException("illegal user set id: " + userSetId);
        }
        UserSetManager userSetManager = new UserSetManager(locale,session);
        UserSet userSet =  userSetManager.getUserSet(userSetId);
        if (userSet == null && userSetId != -2) {
          throw new ConfigurationException("illegal user set id: " + userSetId);
        }
        smsCommandEntry.setDestinationUserSet(userSet);
        smsCommandEntry.setCurrentUserSetAsDestination(userSetId == -2 ? 1 : 0);       
        smsCommandEntry.setDestinationUser(null);
        smsCommandEntry.setDestinationMsisdn(null);
        break;
      case 5: // message to user
        Long userId = msgForm.getUserId();
        if (userId.longValue() == -1){
          String noUserSelectedString = getResources(req).getMessage(locale,"smssvc.MessageNotSentBecauseNoUserSelected");
          throw new InputException(noUserSelectedString);
        }
        UserManager userManager = new UserManager(locale,session);
        User user = userManager.getUserDetails(userId);
        if (user == null){
          throw new ConfigurationException("illegal user id: " + user);
        }
        smsCommandEntry.setDestinationContact(0);
        smsCommandEntry.setDestinationUser(user);
        smsCommandEntry.setDestinationUserSet(null);
        smsCommandEntry.setDestinationMsisdn(null);
        break;
      case 6: // message to msisdn
        smsCommandEntry.setDestinationContact(0);
        String countryCode = msgForm.getCountryCode();
        String mobileNumber = msgForm.getMobileNumber();
        try {
          long countryCodeNumber = Long.parseLong(countryCode);
          long mobileNumberNumber = Long.parseLong(mobileNumber);
          long msisdn = Long.parseLong(countryCodeNumber + "" + mobileNumberNumber)// ignores leading zeros
          smsCommandEntry.setDestinationUserSet(null);
View Full Code Here

   *      javax.servlet.http.HttpServletRequest,
   *      javax.servlet.http.HttpServletResponse)
   */
  public ActionForward create(ActionMapping mapping, ActionForm form,HttpServletRequest req, HttpServletResponse resp)  {

    SmsInteractionEnterOrEditForm msgForm = (SmsInteractionEnterOrEditForm) form;

    String messageText = msgForm.getMessage();
    if (grossSmsMessageLength(messageText) > MAX_MESSAGE_TEXT_LENGTH){
      throw new InputException(getResources(req).getMessage(locale,"smssvc.messageLongerThan450characters"));
    }
    SmsCommandEntry smsCommandEntry = new SmsCommandEntry();
    Group group = groupFromSession(req);
    checkAccessRights(req, group);
    Sender sender = senderFromMsisdn(req, msgForm.getSendingMsisdn(), group);
    SmsTextValidator.checkForValidLatin1AndSmsAllowingPlaceholders(msgForm.getMessage(), locale);
    smsCommandEntry.setSender(sender);
    smsCommandEntry.setTextContent(messageText);
    smsCommandEntry.setDelayInSeconds(msgForm.getDelayInSeconds());   

    String sortLabel = msgForm.getSortLabel();
    smsCommandEntry.setSortLabel(sortLabel);
    smsCommandEntry.setGroup(group);

    switch (msgForm.getDestinationSelection().intValue()){
      case 1: // message return to sender
        smsCommandEntry.setDestinationContact(0);
        smsCommandEntry.setDestinationUserSet(null);
        smsCommandEntry.setDestinationMsisdn(null);
        smsCommandEntry.setDestinationUser(null);
        break;
      case 2: // contact
        smsCommandEntry.setDestinationContact(1);
        smsCommandEntry.setDestinationUserSet(null);
        smsCommandEntry.setDestinationMsisdn(null);
        smsCommandEntry.setDestinationUser(null);
        break;
      case 4: // message to user set
        smsCommandEntry.setDestinationContact(0);
        Long userSetId = msgForm.getUserSetId();
        if(userSetId.longValue() == -1){
          throw new BugException("illegal user set id: " + userSetId);
        }
        UserSetManager userSetManager = new UserSetManager(locale,session);
        UserSet userSet =  userSetManager.getUserSet(userSetId);
        if (userSet == null&& userSetId != -2) {
          throw new ConfigurationException("illegal user set id: " + userSetId);
        }
        smsCommandEntry.setDestinationUserSet(userSet);
        smsCommandEntry.setCurrentUserSetAsDestination(userSetId == -2 ? 1 : 0);
        smsCommandEntry.setDestinationMsisdn(null);
        smsCommandEntry.setDestinationUser(null);
        break;
      case 5: // message to user
        smsCommandEntry.setDestinationContact(0);
        Long userId = msgForm.getUserId();
        if (userId.longValue() == -1){
          String noUserSelectedString = getResources(req).getMessage(locale,"smssvc.MessageNotSentBecauseNoUserSelected");
          throw new InputException(noUserSelectedString);
        }
        UserManager userManager = new UserManager(locale,session);
        User user = userManager.getUserDetails(userId);
        if (user == null){
          throw new ConfigurationException("illegal user id: " + user);
        }
        smsCommandEntry.setDestinationUser(user);
        smsCommandEntry.setDestinationUserSet(null);
        smsCommandEntry.setDestinationMsisdn(null);
        break;
      case 6: // message to msisdn
        smsCommandEntry.setDestinationContact(0);
        String countryCode = msgForm.getCountryCode();
        String mobileNumber = msgForm.getMobileNumber();
        try {
          long countryCodeNumber = Long.parseLong(countryCode);
          long mobileNumberNumber = Long.parseLong(mobileNumber);
          long msisdn = Long.parseLong(countryCodeNumber + "" + mobileNumberNumber)// ignores leading zeros
          smsCommandEntry.setDestinationUserSet(null);
View Full Code Here

   */
  private ActionForward getFormDataByTemplate(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse resp) {
    Long selectedTemplateId = Long.parseLong(req.getParameter("id"));
   
    if (selectedTemplateId != null && selectedTemplateId != -1){
      SmsInteractionEnterOrEditForm f = new SmsInteractionEnterOrEditForm();
      CommandEntryManager commandEntryManager = new CommandEntryManager(locale,session);
      SmsCommandEntry templateEntry = (SmsCommandEntry)commandEntryManager.getCommandEntry(selectedTemplateId);
      f.initializeFromTemplate(templateEntry);
     
      JSONObject jsonObject = JSONObject.fromObject(f);
      writeJsonResult(jsonObject.toString(), resp);
    }
   
View Full Code Here

TOP

Related Classes of evolaris.platform.smssvc.web.form.SmsInteractionEnterOrEditForm

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.