Package org.palo.viewapi.services

Examples of org.palo.viewapi.services.ViewService


    return null;
  }

  private final void delete(String sessionId, View view) throws OperationFailedException,
      SessionExpiredException {
    ViewService viewService = ServiceProvider
        .getViewService(getLoggedInUser(sessionId));
    viewService.delete(view);
  }
View Full Code Here


    }
    }
   
    if (!view.hasRole(viewerRole) && isPublic) {
      try {
        ViewService viewService = ServiceProvider.getViewService(getLoggedInUser(sessionId));
        try {
          viewService.add(viewerRole, view);
        } catch (OperationFailedException e) {
          e.printStackTrace();
        }
      } catch (SessionExpiredException e) {
        e.printStackTrace();
      }
    } else if (view.hasRole(viewerRole) && !isPublic) {
      try {
        ViewService viewService = ServiceProvider.getViewService(getLoggedInUser(sessionId));
        try {
          viewService.remove(viewerRole, view);
        } catch (OperationFailedException e) {
          e.printStackTrace();
        }
      } catch (SessionExpiredException e) {
        e.printStackTrace();
      }     
    }
    if (!view.hasRole(editorRole) && isEditable) {
      try {
        ViewService viewService = ServiceProvider.getViewService(getLoggedInUser(sessionId));
        try {
          viewService.add(editorRole, view);
        } catch (OperationFailedException e) {
          e.printStackTrace();
        }
      } catch (SessionExpiredException e) {
        e.printStackTrace();
      }     
    } else if (view.hasRole(editorRole) && !isEditable) {
      try {
        ViewService viewService = ServiceProvider.getViewService(getLoggedInUser(sessionId));
        try {
          viewService.remove(editorRole, view);
        } catch (OperationFailedException e) {
          e.printStackTrace();
        }
      } catch (SessionExpiredException e) {
        e.printStackTrace();
View Full Code Here

//    }
    return fe;
  }

  private final View getView(String sessionId, XView xView) throws SessionExpiredException {
    ViewService viewService = ServiceProvider
        .getViewService(getLoggedInUser(sessionId));
    return viewService.getView(xView.getId());
  }
View Full Code Here

      if (type.equals(XAccount.TYPE)) {
        Account a = getNative(sessionId, (XAccount) xObj);
        IViewManagement viewManagement = MapperRegistry.getInstance().getViewManagement();       
        try {
          List <View> allViews = viewManagement.findViews(a);
          ViewService viewService = ServiceProvider.getViewService(getLoggedInUser(sessionId));
          try {
            CubeViewReader.CHECK_RIGHTS = false;
            for (View v: allViews) {
              Account acc = v.getAccount();
              Account replaceAccount = findReplaceAccount(sessionId, a.getUser(), acc);
              if (replaceAccount != null && !v.getAccount().getId().equals(replaceAccount.getId())) {
                ((ViewImpl) v).setAccount(replaceAccount);
                viewService.save(v);
              }
            }
          } finally {
            CubeViewReader.CHECK_RIGHTS = true;
          }
        } catch (SQLException e) {
          e.printStackTrace();
        }
        delete(sessionId, getNative(sessionId, (XAccount) xObj));
      }
      else if (type.equals(XConnection.TYPE))
        delete(sessionId, getNative(sessionId, (XConnection) xObj));
      else if (type.equals(XGroup.TYPE))
        delete(sessionId, getNative(sessionId, (XGroup) xObj));
      else if (type.equals(XRole.TYPE))
        delete(sessionId, getNative(sessionId, (XRole) xObj));
      else if (type.equals(XUser.TYPE)) {
        User user = getNative(sessionId, (XUser) xObj);
        IViewManagement viewManagement = MapperRegistry.getInstance().getViewManagement();
        try {
          try {
            IFolderManagement folders = MapperRegistry.getInstance().
              getFolderManagement();         
            AuthUser aUser = ServiceProvider.getAuthenticationService().authenticateHash(user.getLoginName(),
                user.getPassword());
            List <ExplorerTreeNode> nodes = folders.reallyGetFolders(aUser);
            for (ExplorerTreeNode nd: nodes) {
              folders.delete(nd);
            }
          } catch (SQLException e) {
            e.printStackTrace();
          } catch (AuthenticationFailedException e) {
            e.printStackTrace();
          }       
          List <View> allViews = viewManagement.findViews(user);
          ViewService viewService = ServiceProvider.getViewService(getLoggedInUser(sessionId));
          // At this point, the user has agreed to map all his views to admin...
          if (!viewManagement.findViews(user).isEmpty()) {           
            User adminUser = getLoggedInUser(sessionId);
            try {
              CubeViewReader.CHECK_RIGHTS = false;
              for (View v: allViews) {                           
                viewService.setOwner(adminUser, v);
                viewService.save(v);
              }
            } finally {
              CubeViewReader.CHECK_RIGHTS = true;
            }
          }
          IAccountManagement accountManagement = MapperRegistry.getInstance().getAccountManagement();
          for (Account a: accountManagement.getAccounts(user.getId())) {
            allViews = viewManagement.findViews(a);
            try {                 
              CubeViewReader.CHECK_RIGHTS = false;
              for (View v: allViews) {
                Account acc = v.getAccount();
                Account replaceAccount = findReplaceAccount(sessionId, user, acc);
                if (replaceAccount != null && !v.getAccount().getId().equals(replaceAccount.getId())) {
                  ((ViewImpl) v).setAccount(replaceAccount);
                  viewService.save(v);
                }                       
              }
            } finally {
              CubeViewReader.CHECK_RIGHTS = true;
            }
View Full Code Here

      e.printStackTrace();
    }

    if (!view.hasRole(viewerRole) && isPublic) {
      try {
        ViewService viewService = ServiceProvider.getViewService(getLoggedInUser(sessionId));
        try {
          viewService.add(viewerRole, view);
        } catch (OperationFailedException e) {
          e.printStackTrace();
        }
      } catch (SessionExpiredException e) {
        e.printStackTrace();
      }
    } else if (view.hasRole(viewerRole) && !isPublic) {
      try {
        ViewService viewService = ServiceProvider.getViewService(getLoggedInUser(sessionId));
        try {
          viewService.remove(viewerRole, view);
        } catch (OperationFailedException e) {
          e.printStackTrace();
        }
      } catch (SessionExpiredException e) {
        e.printStackTrace();
      }     
    }
    if (!view.hasRole(editorRole) && isEditable) {
      try {
        ViewService viewService = ServiceProvider.getViewService(getLoggedInUser(sessionId));
        try {
          viewService.add(editorRole, view);
        } catch (OperationFailedException e) {
          e.printStackTrace();
        }
      } catch (SessionExpiredException e) {
        e.printStackTrace();
      }     
    } else if (view.hasRole(editorRole) && !isEditable) {
      try {
        ViewService viewService = ServiceProvider.getViewService(getLoggedInUser(sessionId));
        try {
          viewService.remove(editorRole, view);
        } catch (OperationFailedException e) {
          e.printStackTrace();
        }
      } catch (SessionExpiredException e) {
        e.printStackTrace();
View Full Code Here

  public XView setVisibility(String sessionId, XFolderElement element,
      boolean visible, boolean editable, String ownerId,
      String accountId, String dbId, String cubeId) throws SessionExpiredException {
    XView xView = (XView) element.getSourceObject();   
    AuthUser user = getLoggedInUser(sessionId);   
    ViewService vService = ServiceProvider.getViewService(user);
    View view = vService.getView(xView.getId());   
   
    if (!accountId.equals(xView.getAccountId())) {
      try {
        Account newAccount = (Account) MapperRegistry.getInstance().getAccountManagement().find(accountId);
        if (newAccount != null) {
          vService.setAccount(newAccount, view);
          xView.setAccountId(newAccount.getId());
        }
      } catch (SQLException e) {       
      }
    }
    if (!dbId.equals(xView.getDatabaseId())) {
      try {
        CubeViewReader.CHECK_RIGHTS = false;
        vService.setDatabase(dbId, view);
        xView.setDatabaseId(dbId);
      } finally {
        CubeViewReader.CHECK_RIGHTS = true;
      }
    }
    if (!cubeId.equals(xView.getCubeId())) {
      try {
        CubeViewReader.CHECK_RIGHTS = false;
        vService.setCube(cubeId, view);
        xView.setCubeId(cubeId);
        String def = view.getDefinition();
        int index = def.indexOf("cube=\"");
        if (index != -1) {
          int rIndex = def.indexOf("\"", index + 6);
          if (rIndex != -1) {
            def = def.substring(0, index + 6) +
              cubeId + def.substring(rIndex);
            vService.setDefinition(def, view);
            xView.setDefinition(def);
          }
        }
      } finally {
        CubeViewReader.CHECK_RIGHTS = true;
      }
    }     
    if (!ownerId.equals(xView.getOwnerId())) {
      try {
        User newOwner = (User) MapperRegistry.getInstance().getUserManagement().find(ownerId);
        if (newOwner != null) {
          try {
            CubeViewReader.CHECK_RIGHTS = false;
            vService.setOwner(newOwner, view);           
            xView.setOwnerId(newOwner.getId());
          } finally {
            CubeViewReader.CHECK_RIGHTS = true;
          }
        }
      } catch (SQLException e) {
      }     
    }
   
    try {
      ExplorerTreeNode root = FolderModel.getInstance().load(getLoggedInUser(sessionId));
      FolderElement folderElement = (FolderElement) find(root, element.getId());
      try {
        CubeViewReader.CHECK_RIGHTS = false;
        assignViewerAndEditorRole(sessionId, folderElement, view, visible, editable);
      } catch (SQLException e) {
        e.printStackTrace();
      } finally {
        CubeViewReader.CHECK_RIGHTS = true;
      }     
      folderElement.setSourceObject(view);
      saveRoot(sessionId, root);
      try {
        CubeViewReader.CHECK_RIGHTS = false;
        vService.save(view);
      } catch (OperationFailedException e) {
        e.printStackTrace();
      } finally {
        CubeViewReader.CHECK_RIGHTS = true;
      }     
View Full Code Here

    return displayFlags;   
  }

  private final XDirectLinkData parseMultipleViews(String locale, AuthUser authUser, String link, XDirectLinkData data) {
    try {
      ViewService viewService = ServiceProvider.getViewService(authUser);
      int index = -1;
      List <XView> allViews = new ArrayList<XView>();
      while ((index = link.indexOf("[", index + 1)) != -1) {
        int rIndex = link.indexOf("]", index + 1);
        if (rIndex == -1) {
          data.addError(UserSession.trans(locale, "noMatchingClosingBracket"));             
          continue;
        }
        String linkToParse = link.substring(index + 1, rIndex);

        String view = getValue("openview", linkToParse);
        if (view == null) {
          data.addError(UserSession.trans(locale, "noViewIdSpecified"));       
          continue;
        }
        View v = viewService.getView(view);
        if (v == null) {
          data.addError(UserSession.trans(locale, "couldNotFindView", view));             
          continue;
        }
       
View Full Code Here

    if (spagoBISub != null) {     
      getSession().setAttribute("spagobisubobj", spagoBISub);
    }

    try {
      ViewService viewService = ServiceProvider.getViewService(authUser);
      /*SpagoBI modification begin*/
      //View v = viewService.getView(view);
     
      //Account name
      String accountName = getValue("account", link);
      //Connection
      String connection = getValue("connection", link);
      String cubeName = null;
      Cube cube = null;
      String accountId = null;
      if(view.equalsIgnoreCase("")){
        //cube name --> create view dinamically
        cubeName = getValue("cubename", link);

      }
      View v = null;

      for (Account a: authUser.getAccounts()) {
        if(a != null){

          if(view != null && !view.equals("")){           
            //if view specified
            List<View> views = viewService.getViews(a);
            if(!views.isEmpty()){
              Iterator it = views.iterator();
              while(it.hasNext()){
                View selView = (View)it.next();
                if(view != null && !view.equals("")){
                  if(selView.getName().equals(view)){
                    v = selView;
                    break;
                  }
                }
              }
            }

          }else{
            ///tries to get cube
            if(a.getUser().getLoginName().equals(accountName)){
              if(a.getConnection().getName().equals(connection)){
                //use cube name
                accountId = a.getId();
                Connection con = ((PaloAccount) a).login();
                for (Database db: con.getDatabases()) {
                  int connectionType = db.getConnection().getType();
                  Cube c = db.getCubeByName(cubeName);
                  if(c != null){
                    cube = c;
                    //((PaloAccount) a).logout();
                    break;
                  }

                }
               
              }
            }
          }
        }
      }

      /*end*/
     
      if (v != null) {
        String connectionId = v.getAccount().getConnection().getId();
        Account neededAccount = null;
        for (Account a: authUser.getAccounts()) {
          if (a.getConnection().getId().equals(connectionId)) {
            PaloConnection paloCon = a.getConnection();
            if (paloCon.getType() == PaloConnection.TYPE_WSS) {
              continue;
            } else {
              neededAccount = a;
              break;
            }
          }
        }
       
        if (neededAccount == null) {
          data.addError(UserSession.trans(locale, "noAccountForView", v.getName(), v.getId()));             
          return data;
        }

        boolean allowed = false;
        if (v.getOwner() != null) {
          if (authUser.getId().equals(v.getOwner().getId())) {
            allowed = true;
          }
        }
        if (!allowed) {
          for (Role r: v.getRoles()) {
            for (Role r2: authUser.getRoles()) {
              if (r2.getId().equals(r.getId())) {
                if (r2.hasPermission(Right.READ)) {
                  allowed = true;
                  break;
                }
              }
            }
            for (Group g: authUser.getGroups()) {
              for (Role r2: g.getRoles()) {
                if (r2.getId().equals(r.getId())) {
                  if (r2.hasPermission(Right.READ)) {
                    allowed = true;
                    break;
                  }
                }               
              }
            }
          }
        }
        if (!allowed) {
          data.addError(UserSession.trans(locale, "viewCannotBeSeen", v.getName(), v.getId()))
          logger.error("viewCannotBeSeen");
          return data;
        }

       
      }else if(v == null && cube != null){
        //dinamically create view
        //if doesn't exist
        View existingView = viewService.getViewByName(cubeName, cube);

        if(existingView == null){
          v = CubeViewConverter.createDefaultView(cubeName, cube, accountId, authUser, "", null);
          viewService.save(v);
        }else{
          v = existingView;
        }
      }else{
        data.addError(UserSession.trans(locale, "couldNotFindView", view));   
View Full Code Here

        log.debug("AccountToUse:");
        log.debug("  Name: " + xAccount.getLogin());
        log.debug("  Pass: " + data.getUserPassword());
        data.setAuthenticated(true);
        data.setPaloSuiteViewId(viewId);
        ViewService viewService = ServiceProvider.getViewService(authenticatedUser);
        for (View v: viewService.getViews(accountToUse)) {
          String def = v.getDefinition();
          int index;
          if (def != null && (index = def.indexOf("<property id=\"paloSuiteID\" value=")) != -1) {
            int i2 = def.indexOf("value=\"", index) + 7;
            if (i2 != -1) {
View Full Code Here

      String accountId, AuthUser user) {
    XView view = new XView(id, name);
    view.setCubeId(cube.getId());
    view.setDatabaseId(cube.getDatabase().getId());
    view.setAccountId(accountId);
    ViewService vService = ServiceProvider.getViewService(user);
    View v = vService.getView(id);
    if (v != null && v.getOwner() != null) {
      view.setOwnerId(v.getOwner().getId());     
    }
    if (v != null) {
      List <String> ids = new ArrayList<String>();
View Full Code Here

TOP

Related Classes of org.palo.viewapi.services.ViewService

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.