Package evolaris.framework.async.business

Examples of evolaris.framework.async.business.SmsDbManager


 
  protected ActionForward enter(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse resp) {
    SmsInteractionExecutionForm executionForm = (SmsInteractionExecutionForm)form;
   
    Long invocationId = executionForm.getId();
    SmsDbManager smsDbManager = new SmsDbManager(locale,session);
   
    Invocation invocation = smsDbManager.getInvocation(invocationId);
   
    if (invocation == null){
      throw new InputException(getResources(req).getMessage(locale, "sys.entryNotAvailable"),"id = " + executionForm.getId(),null,null);
    }
   
View Full Code Here


 
  public ActionForward send(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse resp) {
    SmsInteractionExecutionForm executionForm = (SmsInteractionExecutionForm)form;
   
    Long invocationId = executionForm.getId();
    SmsDbManager smsDbManager = new SmsDbManager(locale,session);
   
    Invocation invocation = smsDbManager.getInvocation(invocationId);
   
    if (invocation == null){
      throw new InputException(getResources(req).getMessage(locale, "sys.entryNotAvailable"),"id = " + executionForm.getId(),null,null);
    }

    LOGGER.info("processing sms service event #" + executionForm.getId() + " (Keyword: " + invocation.getKeywords() + "; group: " + invocation.getGroup().getGroupname() + ")");
   
    String msisdn = "";
    if(executionForm.getCountryCode() != null && executionForm.getCountryCode().trim().length() >= 1){
      msisdn = executionForm.getCountryCode();
    }

    if(executionForm.getMobileNumber() != null && executionForm.getMobileNumber().trim().length() >= 1){
      msisdn +=  Long.parseLong(executionForm.getMobileNumber()); //the convertion is used to cut the leading zero
    }
     
    // execute the commands 
    Set<CommandEntry> commandEntries = invocation.getCommandEntries();
    // table-driven action evaluation
    UserManager userManager = new UserManager(locale,session);
    User user = userManager.registerUserByMsisdn(Long.parseLong(msisdn), null, invocation.getGroup());
   
    InteractionLogManager interactionLogManager = new InteractionLogManager(locale, session);   
    EventParameters eventParameters = null;
   
    ReceivedSms receivedSms = new ReceivedSms();
    receivedSms.setSender(msisdn);
    receivedSms.setReceiver(invocation.getMsisdn() != null ? Long.toString(invocation.getMsisdn()) : "");
    receivedSms.setOperator("SIMULATOR");
    receivedSms.setContent(executionForm.getMessage());
    receivedSms.setSubject(executionForm.getMmsSubject());
    if (executionForm.getFile() != null && executionForm.getFile().getFileSize() > 0) {
      try {
        receivedSms.setAttachment(new SerialBlob(executionForm.getFile().getFileData()));
        receivedSms.setAttachmentContentType(executionForm.getFile().getContentType());
        receivedSms.setAttachmentName(executionForm.getFile().getFileName());
      } catch (Exception e) {
        LOGGER.error("Creating blob from uploaded file faild.", e);
        throw new BugException("Creating blob from uploaded file faild.", e);
      }
    }
   
    receivedSms.setInvocation(invocation);
    SmsDbManager smsMgr = new SmsDbManager(locale, session);
    smsMgr.writeIncomingMessageLog(receivedSms);
    eventParameters = new SmsEventParameters(locale, session, user, invocation, receivedSms);
    InteractionLog log = new InteractionLog();
    eventParameters.updateInteractionLog(log);
    log.setOperation(InteractionLogManager.EVENT_SMS_SIMULATED);
    log.setParameter(executionForm.getMessage());
View Full Code Here

      sender.getGatewayProvider();
      sender.getDescription();
    }
    req.setAttribute("selectableSenders", senders);
   
    SmsDbManager smsDbManager = new SmsDbManager(locale,session);
    req.setAttribute("selectableFragments", smsDbManager.getFragments(destinationGroup));
   
    BlogManager blogMgr = new BlogManager(locale, session);
    List<Blog> blogs = blogMgr.getBlogs(destinationGroup);
    for (Blog blog : blogs) { // fill cache
      blog.getName();
View Full Code Here

      }
    }       
   
    // fragments
   
    SmsDbManager smsDbManager = new SmsDbManager(locale,session);
    long[] sourceFragmentIds = f.getSourceFragmentIds();
    if (sourceFragmentIds != null){  // at least one mapping
      long[] selectedFragmentIds = f.getSelectedFragmentIds();
      for (int i = 0; i < sourceFragmentIds.length; i++){
        long sourceFragmentId = sourceFragmentIds[i];
        Fragment sourceFragment = smsDbManager.getFragment(sourceFragmentId);
        if (sourceFragment == null){
          throw new InputException(getResources(req).getMessage(locale, "smssvc.SourceFragmentNotAvailableAnymore"),"fragment #" + sourceFragmentId + " not found",null,null);
        }
        checkAccessRights(req,sourceFragment.getGroup());
        long selectedFragmentId = selectedFragmentIds[i];
        if (selectedFragmentId <= 0){
          throw new InputException(getResources(req).getMessage(locale, "smssvc.FragmentMappingSelectionMissing"),"sourceFragmentId = " + sourceFragmentId,null,null);
        }
        Fragment selectedFragment = smsDbManager.getFragment(selectedFragmentId);
        if (selectedFragment == null){
          throw new InputException(getResources(req).getMessage(locale, "smssvc.SelectedFragmentNotAvaliableAnymore"),"fragment #" + selectedFragmentId + " not found",null,null);
        }
        checkAccessRights(req,selectedFragment.getGroup());
        mappingSet.add(new Entry(sourceFragment), new Entry(selectedFragment));
View Full Code Here

    req.getSession().setAttribute("oldInteractionListId", oldFragment.getId());
    Set<CommandEntry> commandEntries = oldFragment.getCommandEntries();
    Fragment editedFragment = f.toEntry(new Fragment(), locale, session, getResources(req));
   
    // check for fragment with the same name already here to avoid error messages after selecting the mapping
    SmsDbManager smsDbManager = new SmsDbManager(locale,session);
    Fragment existingFragment = smsDbManager.getFragment(f.getName(),editedFragment.getGroup());
    if (existingFragment != null){
      throw new InputException(MessageFormat.format(ResourceBundle.getBundle("SmsServices", locale).getString("FragmentP0AlreadyExists"),f.getName()));
    }

    req.getSession().setAttribute("newInteractionList", editedFragment)// needed when we duplicate or come back
View Full Code Here

   
    Object oldInteractionListId = req.getSession().getAttribute("oldInteractionListId");
    if (oldInteractionListId == null || !(oldInteractionListId instanceof Long)){
      throw new InputException(getResources(req).getMessage(locale, "admin.entryNotAvailable"),"old fragment entry not found in session",null,null);
    }
    Fragment oldFragment = new SmsDbManager(locale,session).getFragment((Long)oldInteractionListId);
    if (oldFragment == null){
      throw new InputException(getResources(req).getMessage(locale, "admin.entryNotAvailable"),"old fragment entry #" + oldInteractionListId + " not found",null,null);
    }
    checkAccessRights(req,oldFragment.getGroup(),null);

    Object newEntry = req.getSession().getAttribute("newInteractionList");
    if (newEntry == null || !(newEntry instanceof Fragment)){
      throw new InputException(getResources(req).getMessage(locale, "admin.entryNotAvailable"),"new fragment entry not found in session",null,null);
    }
   
    // reload references in current session
    Fragment newFragment = (Fragment)newEntry;
    f.initialize(newFragment,locale,session,getResources(req));
    newFragment = new Fragment();
    f.toEntry(newFragment, locale, session, getResources(req));
    checkAccessRights(req, newFragment.getGroup(),null);
   
    // group assignment is not editable => perform source to destination automatically
    mappingSet.add(new Entry(oldFragment.getGroup()), new Entry(newFragment.getGroup()));
   
    // Create duplicated command entries according to the original execution order
    CommandEntryManager commandEntryManager = new CommandEntryManager(locale,session);
    SortedSet<CommandEntry> newCommandEntries = new TreeSet<CommandEntry>(new CommandEntryManager.CommandEntryComparator());
    Set<CommandEntry> oldCommandEntries = oldFragment.getCommandEntries();
    SortedSet<CommandEntry> sortedOldCommandEntries = new TreeSet<CommandEntry>(new CommandEntryManager.CommandEntryComparator());
    sortedOldCommandEntries.addAll(oldCommandEntries);
    for (CommandEntry oldCommandEntry : sortedOldCommandEntries) {
      CommandEntryExtender extender = commandEntryManager.createCommandEntryExtender(oldCommandEntry);
      CommandEntry duplicatedCommandEntry = extender.duplicateCommandEntry(newFragment.getGroup(),mappingSet);
      Set<InteractionList> fragments = new TreeSet<InteractionList>();
      fragments.add(newFragment);
      duplicatedCommandEntry.setInteractionLists(fragments);
      commandEntryManager.create(duplicatedCommandEntry)// also sets the ID for sorting
      newCommandEntries.add(duplicatedCommandEntry);
    }
    newFragment.setCommandEntries(newCommandEntries);
    SmsDbManager smsDbManager = new SmsDbManager(locale,session);
    smsDbManager.createFragment(newFragment);
     return mapping.findForward("duplicated");
  }
View Full Code Here

   * @param id  fragment ID
   * @return fragment entry; null if not found
   */
  @Override
  protected Fragment entryFromDatabase(long id) {
    SmsDbManager smsDbManager = new SmsDbManager(locale,session);
    return smsDbManager.getFragment(id);
  }
View Full Code Here

    }
    long interactionListId = ((Long)interactionListIdParam).longValue();
    if (interactionListId == -1) {
      throw new BugException("interactionList id -1 in session");
    }
    SmsDbManager smsDbManager = new SmsDbManager(locale,session);
    InteractionList interactionList = smsDbManager.getInteractionList(interactionListId);
    if(interactionList == null) {
      throw new ConfigurationException("There is no interactionList with id: " + interactionListId + " -> cannot add a new interaction");
    }
    if (!req.isUserInRole(UserManagerBase.ADMINISTRATOR) && (!req.isUserInRole(SmsDbManager.INTERACTION_ADMINISTRATOR) || webUser.getGroup() != interactionList.getGroup())){
      throw new InputException(getResources(req).getMessage(locale, "smssvc.insufficientRights"));
View Full Code Here

      throw new BugException("no interactionList id in form");
    }
    req.getSession().setAttribute("interactionListId", interactionListId);
    req.getSession().setAttribute("groupId", groupId);
    req.getSession().setAttribute("applicationId", applicationId);
    SmsDbManager smsDbManager = new SmsDbManager(locale,session);
    InteractionList interactionList = smsDbManager.getInteractionList(interactionListId);
    if (interactionList == null){  // may happen if the interactionList was deleted in the meantime
      String interactionListDeletedString = getResources(req).getMessage(locale,"smssvc.interactionDefinitionNotPossible");
      throw new InputException(interactionListDeletedString);
    }
    if (!req.isUserInRole(UserManagerBase.ADMINISTRATOR) && (!req.isUserInRole(SmsDbManager.INTERACTION_ADMINISTRATOR) || webUser.getGroup() != interactionList.getGroup())){
View Full Code Here

  // associates the command entry with the current keyword/service
  private void associate(HttpServletRequest req,CommandEntryManager commandEntryManager, CommandEntry commandEntry) {

    // get the current keyword/service from the session
    SmsDbManager smsDbManager = new SmsDbManager(locale,session);
    Object interactionListIdParameter = req.getSession().getAttribute("interactionListId");
    if (interactionListIdParameter == null || !(interactionListIdParameter instanceof Long)){
      throw new BugException("no interactionList id found for association");
    }
    long interactionListId = ((Long)interactionListIdParameter).longValue();
    if (interactionListId == -1){
      throw new BugException("interactionList id -1 in session");
    }
    InteractionList interactionList = smsDbManager.getInteractionList(interactionListId);
    if(interactionList == null){
      throw new ConfigurationException("There is no interactionList with id: " + interactionListId + " -> cannot add a new interaction");
    }

    // check access rights
View Full Code Here

TOP

Related Classes of evolaris.framework.async.business.SmsDbManager

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.