Package evolaris.framework.smsservices.business

Examples of evolaris.framework.smsservices.business.MappingSet


    // get mappings from session
    Object mappingSetFromSession = req.getSession().getAttribute("mappingSet");
    if (!(mappingSetFromSession instanceof MappingSet)) {
      throw new BugException("invalid mappingSet parameter: " + mappingSetFromSession);
    }
    MappingSet mappingSet = (MappingSet) mappingSetFromSession;
    mappingSet.reload(locale, session);
   
    // prepare mapping form and request attributes
    List<User> sourceUsers = new LinkedList<User>();
    List<User> proposedUsers = new LinkedList<User>();
    List<Long> proposedUserIds = new LinkedList<Long>();
View Full Code Here


   *      javax.servlet.http.HttpServletResponse)
   */
  public ActionForward duplicate(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse resp) {
    MappingSelectForm f = (MappingSelectForm) form;
    // create mappings from form
    MappingSet mappingSet = new MappingSet();
   
    // users
   
    UserManager userManager = new UserManager(locale,session);
    long[] sourceUserIds = f.getSourceUserIds();
    if (sourceUserIds != null){  // at least one mapping
      long[] selectedUserIds = f.getSelectedUserIds();
      for (int i = 0; i < sourceUserIds.length; i++){
        long sourceUserId = sourceUserIds[i];
        User sourceUser = userManager.getUserDetails(sourceUserId);
        if (sourceUser == null){
          throw new InputException(getResources(req).getMessage(locale, "smssvc.SourceUserNotAvailableAnymore"),"user #" + sourceUserId + " not found",null,null);
        }
        checkAccessRights(req,sourceUser.getGroup());
        long selectedUserId = selectedUserIds[i];
        if (selectedUserId <= 0){
          throw new InputException(getResources(req).getMessage(locale, "smssvc.UserMappingSelectionMissing"),"sourceUserId = " + sourceUserId,null,null);
        }
        User selectedUser = userManager.getUserDetails(selectedUserId);
        if (selectedUser == null){
          throw new InputException(getResources(req).getMessage(locale, "smssvc.SelectedUserNotAvaliableAnymore"),"user #" + selectedUserId + " not found",null,null);
        }
        checkAccessRights(req,selectedUser.getGroup());
        mappingSet.add(new Entry(sourceUser), new Entry(selectedUser));
      }
    }
   
    // user sets
   
    UserSetManager userSetManager = new UserSetManager(locale,session);
    long[] sourceUserSetIds = f.getSourceUserSetIds();
    if (sourceUserSetIds != null){
      long[] selectedUserSetIds = f.getSelectedUserSetIds();
      for (int i = 0; i < sourceUserSetIds.length; i++){
        long sourceUserSetId = sourceUserSetIds[i];
        UserSet sourceUserSet = userSetManager.getUserSet(sourceUserSetId);
        if (sourceUserSet == null){
          throw new InputException(getResources(req).getMessage(locale, "smssvc.SourceUserSetNotAvailableAnymore"),"user set #" + sourceUserSetId + " not found",null,null);
        }
        checkAccessRights(req,sourceUserSet.getGroup());
        long selectedUserSetId = selectedUserSetIds[i];
        if (selectedUserSetId >= 1){  // mapping entry => assign; no entry => create
          UserSet selectedUserSet = userSetManager.getUserSet(selectedUserSetId);
          if (selectedUserSet == null){
            throw new InputException(getResources(req).getMessage(locale, "smssvc.SelectedUserSetNotAvaliableAnymore"),"user set #" + selectedUserSetId + " not found",null,null);
          }
          checkAccessRights(req,selectedUserSet.getGroup());
          mappingSet.add(new Entry(sourceUserSet), new Entry(selectedUserSet));
        }
      }
    }
   
    // senders
   
    SmsSenderManager senderManager = new SmsSenderManager(locale,session);
    long[] sourceSenderIds = f.getSourceSenderIds();
    if (sourceSenderIds != null){  // at least one mapping
      long[] selectedSenderIds = f.getSelectedSenderIds();
      for (int i = 0; i < sourceSenderIds.length; i++){
        long sourceSenderId = sourceSenderIds[i];
        Sender sourceSender = senderManager.getSmsSenderById(sourceSenderId);
        if (sourceSender == null){
          throw new InputException(getResources(req).getMessage(locale, "smssvc.SourceSenderNotAvailableAnymore"),"sender #" + sourceSenderId + " not found",null,null);
        }
        if (!req.isUserInRole(UserManagerBase.ADMINISTRATOR) && !senderManager.isValidForGroup(sourceSender,webUser.getGroup())) {
          throw new InputException(getResources(req).getMessage(locale, "smssvc.insufficientRights"));
        }
        long selectedSenderId = selectedSenderIds[i];
        if (selectedSenderId >= 1){  // mapping entry => assign; no entry => add to group
          Sender selectedSender = senderManager.getSmsSenderById(selectedSenderId);
          if (selectedSender == null){
            throw new InputException(getResources(req).getMessage(locale, "smssvc.SelectedSenderNotAvaliableAnymore"),"sender #" + selectedSenderId + " not found",null,null);
          }
          if (!req.isUserInRole(UserManagerBase.ADMINISTRATOR) && !senderManager.isValidForGroup(selectedSender,webUser.getGroup())) {
            throw new InputException(getResources(req).getMessage(locale, "smssvc.insufficientRights"));
          }
          mappingSet.add(new Entry(sourceSender), new Entry(selectedSender));
        }
      }
    }

    // blogs

    BlogManager blogManager = new BlogManager(locale, session);
    long[] sourceBlogIds = f.getSourceBlogIds();
    if (sourceBlogIds != null) {  // at least one mapping
      Blog personalBlog = new Blog();
      personalBlog.setId(-99);
      personalBlog.setName(this.getResources(req).getMessage("smssvc.personalBlog"));
      long[] selectedBlogIds = f.getSelectedBlogIds();
      for (int i = 0; i < sourceBlogIds.length; i++){
        long sourceBlogId = sourceBlogIds[i];
        Blog sourceBlog = sourceBlogId == -99 ? personalBlog : blogManager.getBlog(sourceBlogId);
        if (sourceBlog == null){
          throw new InputException(getResources(req).getMessage(locale, "smssvc.SourceBlogNotAvailableAnymore"),"blog #" + sourceBlogId + " not found",null,null);
        }
        if (sourceBlog.getId() != -99) {
          checkAccessRights(req, sourceBlog.getGroup());
        }
        long selectedBlogId = selectedBlogIds[i];
        if (selectedBlogId != -99 && selectedBlogId <= 0) {
          throw new InputException(getResources(req).getMessage(locale, "smssvc.BlogMappingSelectionMissing"),"sourceBlogId = " + sourceBlogId,null,null);
        }
        Blog selectedBlog = selectedBlogId == -99 ? personalBlog : blogManager.getBlog(selectedBlogId);
        if (selectedBlog == null) {
          throw new InputException(getResources(req).getMessage(locale, "smssvc.SelectedBlogNotAvaliableAnymore"),"blog #" + selectedBlogId + " not found",null,null);
        }
        if (selectedBlogId != -1) {
          checkAccessRights(req,selectedBlog.getGroup());
        }
        mappingSet.add(new Entry(sourceBlog), new Entry(selectedBlog));
      }
    }       
   
    // 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));
      }
    }
   
    req.getSession().setAttribute("mappingSet", mappingSet);
    return mapping.findForward("selected");
View Full Code Here

    }

    req.getSession().setAttribute("newInteractionList", editedFragment)// needed when we duplicate or come back
   
    // mapping from command entries of the duplication source fragment
    MappingSet mappingSet = new MappingSet(commandEntries,editedFragment.getGroup(), locale, session);
   
    req.getSession().setAttribute("mappingSet", mappingSet);
    req.getSession().setAttribute("destinationGroupId", editedFragment.getGroup().getId());
    return mapping.findForward("duplicateIncludingInteractions");
  }
View Full Code Here

    // get mappings from session
    Object mappingSetFromSession = req.getSession().getAttribute("mappingSet");
    if (!(mappingSetFromSession instanceof MappingSet)) {
      throw new BugException("invalid mappingSet parameter: " + mappingSetFromSession);
    }
    MappingSet mappingSet = (MappingSet) mappingSetFromSession;
    mappingSet.reload(locale, session);
   
    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();
View Full Code Here

    req.getSession().setAttribute("newInteractionList", editedInvocation)// needed when we duplicate or come back
    smsDbManager.checkInvocationUniqueness(editedInvocation,false);
    smsDbManager.checkIfInvocationAllowed(editedInvocation,false);
   
    // mapping from command entries of the duplication source invocation
    MappingSet mappingSet = new MappingSet(commandEntries,editedInvocation.getGroup(), locale, session);
   
    req.getSession().setAttribute("mappingSet", mappingSet);
    req.getSession().setAttribute("destinationGroupId", editedInvocation.getGroup().getId());
    return mapping.findForward("duplicateIncludingInteractions");
  }
View Full Code Here

    // get mappings from session
    Object mappingSetFromSession = req.getSession().getAttribute("mappingSet");
    if (!(mappingSetFromSession instanceof MappingSet)) {
      throw new BugException("invalid mappingSet parameter: " + mappingSetFromSession);
    }
    MappingSet mappingSet = (MappingSet) mappingSetFromSession;
    mappingSet.reload(locale, session);
   
    Object oldInvocationId = req.getSession().getAttribute("oldInteractionListId");
    if (oldInvocationId == null || !(oldInvocationId instanceof Long)){
      throw new InputException(getResources(req).getMessage(locale, "admin.entryNotAvailable"),"old invocation entry not found in session",null,null);
    }
    Invocation oldInvocation = new SmsDbManager(locale,session).getInvocation((Long)oldInvocationId);
    if (oldInvocation == null){
      throw new InputException(getResources(req).getMessage(locale, "admin.entryNotAvailable"),"old invocation entry #" + oldInvocationId + " not found",null,null);
    }
    checkAccessRights(req,oldInvocation.getGroup(),null);

    Object newEntry = req.getSession().getAttribute("newInteractionList");
    if (newEntry == null || !(newEntry instanceof Invocation)){
      throw new InputException(getResources(req).getMessage(locale, "admin.entryNotAvailable"),"new invocation entry not found in session",null,null);
    }
   
    // reload references in current session
    Invocation newInvocation = (Invocation)newEntry;
    f.initialize(newInvocation,locale,session,getResources(req));
    newInvocation = new Invocation();
    f.toEntry(newInvocation, locale, session, getResources(req));
    checkAccessRights(req, newInvocation.getGroup(),null);
   
    // group assignment is not editable => perform source to destination automatically
    mappingSet.add(new Entry(oldInvocation.getGroup()), new Entry(newInvocation.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 = oldInvocation.getCommandEntries();
View Full Code Here

    f.setOwningUserId(webUser.getId());
    TimerEvent editedTimerEvent = f.toEntry(new TimerEvent(), locale, session, getResources(req));
    req.getSession().setAttribute("newTimerEvent", editedTimerEvent)// needed when we duplicate or come back
   
    // mapping from command entries of the duplication source
    MappingSet mappingSet = new MappingSet(commandEntries,editedTimerEvent.getGroup(), locale, session);
   
    req.getSession().setAttribute("mappingSet", mappingSet);
    req.getSession().setAttribute("destinationGroupId", editedTimerEvent.getGroup().getId());
    return mapping.findForward("duplicateIncludingInteractions");
  }
View Full Code Here

    // get mappings from session
    Object mappingSetFromSession = req.getSession().getAttribute("mappingSet");
    if (!(mappingSetFromSession instanceof MappingSet)) {
      throw new BugException("invalid mappingSet parameter: " + mappingSetFromSession);
    }
    MappingSet mappingSet = (MappingSet) mappingSetFromSession;
    mappingSet.reload(locale, session);
   
    Object oldTimerEventId = req.getSession().getAttribute("oldInteractionListId");
    if (oldTimerEventId == null || !(oldTimerEventId instanceof Long)){
      throw new InputException(getResources(req).getMessage(locale, "admin.entryNotAvailable"),"old timer event entry not found in session",null,null);
    }
    TimerEvent oldTimerEvent = new SmsServiceDbManager(locale,session).getTimerEvent((Long)oldTimerEventId);
    if (oldTimerEvent == null){
      throw new InputException(getResources(req).getMessage(locale, "admin.entryNotAvailable"),"old timer event entry #" + oldTimerEventId + " not found",null,null);
    }
    checkAccessRights(req,oldTimerEvent.getGroup(),null);

    Object newEntry = req.getSession().getAttribute("newTimerEvent");
    if (newEntry == null || !(newEntry instanceof TimerEvent)){
      throw new InputException(getResources(req).getMessage(locale, "admin.entryNotAvailable"),"new timer event entry not found in session",null,null);
    }
   
    // reload references in current session
    TimerEvent newTimerEvent = (TimerEvent)newEntry;
    f.initialize(newTimerEvent,locale,session,getResources(req));
    newTimerEvent = new TimerEvent();
    f.toEntry(newTimerEvent, locale, session, getResources(req));
    checkAccessRights(req, newTimerEvent.getGroup(),null);
   
    // group assignment is not editable => perform source to destination automatically
    mappingSet.add(new Entry(oldTimerEvent.getGroup()), new Entry(newTimerEvent.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 = oldTimerEvent.getCommandEntries();
View Full Code Here

TOP

Related Classes of evolaris.framework.smsservices.business.MappingSet

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.