Package evolaris.platform.smssvc.web.form

Examples of evolaris.platform.smssvc.web.form.MappingSelectForm$SelectableUser


   *      org.apache.struts.action.ActionForm,
   *      javax.servlet.http.HttpServletRequest,
   *      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);
View Full Code Here

TOP

Related Classes of evolaris.platform.smssvc.web.form.MappingSelectForm$SelectableUser

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.