Examples of SmsCommandEntry


Examples of evolaris.framework.smsservices.datamodel.SmsCommandEntry

     
      // security check: do not allow "dangerous" commands in timer events applied to more than one user
      if (timerEvent.getRequestingUserSet() != null){
        for (CommandEntry entry : commandEntries) {
          if (entry instanceof SmsCommandEntry){
            SmsCommandEntry smsCommandEntry = (SmsCommandEntry)entry;
            if (smsCommandEntry.getDestinationUserSet() != null || smsCommandEntry.getDestinationGroup() != null){
              ResourceBundle messages = ResourceBundle.getBundle("SmsServices", locale);
              throw new InputException(messages.getString("smssvc.SendingToMoreThanOneUserNotAllowedInTimerEventAppliedToMoreThanOneRequestingUser"));
            }
          }
        }
View Full Code Here

Examples of evolaris.framework.smsservices.datamodel.SmsCommandEntry

    smsSendForm.setSendConfirmationPending(false);

    Group group = getCurrentGroup(req);

    // template selector: first set content from the template, if selected; content will be changed later if not allowed (except destination group, which  has to be checked explicitly)
    prepareTemplate(req, smsSendForm, group, new SmsCommandEntry());

    // set defaults, if no user or template entries

    if (smsSendForm.getDestinationSelection() == null){
      smsSendForm.setDestinationSelection(-1)// none selected
View Full Code Here

Examples of evolaris.framework.smsservices.datamodel.SmsCommandEntry

    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);
          smsCommandEntry.setDestinationMsisdn(msisdn);
          smsCommandEntry.setDestinationUser(null);
        } catch (NumberFormatException e){
          throw new BugException("validation of countryCode and mobileNumber failed");
        }
        break;
      default:
        throw new BugException("illegal destination selection number");
    }

    LOGGER.info("User " + req.getUserPrincipal().getName().toLowerCase()
        + ": Created message command entry #" + smsCommandEntry.getId()
        + "; label: " + smsCommandEntry.getSortLabel() + "; with message: " + smsCommandEntry.getTextContent()
        + "; MSISDN: " + smsCommandEntry.getSender().getMsisdn());
    setCommandEntryInRequest(req, smsCommandEntry);
    return mapping.findForward("created");
  }
View Full Code Here

Examples of evolaris.framework.smsservices.datamodel.SmsCommandEntry

   */
  @SuppressWarnings("unchecked")
  private void prepareTemplate(HttpServletRequest req, SmsInteractionEnterOrEditForm sendForm) {

    CommandEntryManager commandEntryManager = new CommandEntryManager(locale,session);
    Set<SmsCommandEntry> commandEntries = commandEntryManager.getTemplateCommandEntries(groupFromSession(req), new SmsCommandEntry());
    req.getSession().setAttribute("templates",commandEntries);

    Long selectedTemplateId = sendForm.getTemplateId();
    sendForm.setTemplateId(-1L)// none selected
    if (selectedTemplateId != null && selectedTemplateId != -1){
View Full Code Here

Examples of evolaris.framework.smsservices.datamodel.SmsCommandEntry

    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

Examples of evolaris.framework.smsservices.datamodel.SmsCommandEntry

   *      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);
    Set<SmsCommandEntry> commandEntries = commandEntryManager.getTemplateCommandEntries(group, new SmsCommandEntry());
    req.getSession().setAttribute("templates",commandEntries);
   
    req.getSession().setAttribute("enterOrEdit", "edit");
    req.getSession().setAttribute("formActionPath", req.getParameter("formActionPath"));
    return mapping.findForward("edit");
View Full Code Here

Examples of evolaris.framework.smsservices.datamodel.SmsCommandEntry

    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);
          smsCommandEntry.setDestinationUser(null);
          smsCommandEntry.setDestinationMsisdn(msisdn);
        } catch (NumberFormatException e){
          throw new BugException("validation of countryCode and mobileNumber failed");
        }
        break;
      default:
        throw new BugException("illegal destination selection number");
    }
    LOGGER.info("User " + req.getUserPrincipal().getName().toLowerCase()
        + ": Modified message command entry #" + smsCommandEntry.getId()
        + "; label: " + smsCommandEntry.getSortLabel() + "; message: " + smsCommandEntry.getTextContent()
        + "; MSISDN: " + smsCommandEntry.getSender().getMsisdn());
    setCommandEntryInRequest(req, smsCommandEntry);
    return mapping.findForward("modified");
  }
View Full Code Here

Examples of evolaris.framework.smsservices.datamodel.SmsCommandEntry

    Set<CommandEntry> templates = commandEntryManager.getTemplateCommandEntries(groupToDisplay, null);
    DisplayableInteractionContent[] interactions = null;
    SortedSet<CommandEntry> sortedCommandEntries = new TreeSet<CommandEntry>(new CommandEntryManager.TemplateCommandEntryComparator());
    for (CommandEntry entry : templates) {
      if(!req.isUserInRole(SmsDbManager.INTERACTION_ADMINISTRATOR) && entry.getClass().isInstance(new UpcallCommandEntry())
          || !req.isUserInRole(SmsDbManager.SMS_SENDER) && entry.getClass().isInstance(new SmsCommandEntry())
          || !req.isUserInRole(SmsDbManager.EMAIL_SENDER) && entry.getClass().isInstance(new EmailCommandEntry())){
        // only users in role interaction_administrator are allowed to view upcall command templates,
        // users in roles sms_sender / email_sender are allowed to see sms / email templates
      } else {
        sortedCommandEntries.add(entry);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.