Examples of PermissionAPI


Examples of com.dotmarketing.business.PermissionAPI

     
      List<Map<String, String>> list = dc.loadResults();
      List<Permissionable> assetsList = new ArrayList<Permissionable>();
      WebAsset permissionable;
     
      PermissionAPI permAPI = APILocator.getPermissionAPI();
     
      while ((assetsList.size() < limit) && (list != null) && (0 < list.size())) {
        for (Map<String, String> map: list) {
          permissionable = (WebAsset) c.newInstance();
          permissionable.setIdentifier(map.get("identifier"));
          permissionable.setInode(map.get("inode"));
         
          if (permAPI.doesUserHavePermission(permissionable, PermissionAPI.PERMISSION_READ, user, false)) {
            assetsList.add(permissionable);
            if (limit < assetsList.size())
              break;
          }
        }
View Full Code Here

Examples of com.dotmarketing.business.PermissionAPI

          permissionable.setIdentifier(map.get("identifier"));
          permissionable.setInode(map.get("inode"));
          assetsList.add(permissionable);
        }
       
        PermissionAPI permAPI = APILocator.getPermissionAPI();
        toReturn.addAll(permAPI.filterCollection(assetsList, PermissionAPI.PERMISSION_READ, false, user));
        if(limit > 0 && toReturn.size() >= limit + offset)
          done = true;
        else if(assetsList.size() < internalLimit)
          done = true;
       
View Full Code Here

Examples of com.dotmarketing.business.PermissionAPI

      try {
        ContentletIndexAPI indexAPI = APILocator.getContentletIndexAPI();

        //Creating a test structure
        PermissionAPI permissionAPI = APILocator.getPermissionAPI();

        //Set up a test folder
        testFolder = APILocator.getFolderAPI().createFolders( "testSearchIndexByDateFolder", defaultHost, user, false );
        permissionAPI.permissionIndividually( permissionAPI.findParentPermissionable( testFolder ), testFolder, user, false );

        //Set up a test structure
        String structureName = "testSearchIndexByDateStructure";
        testStructure = new Structure();
        testStructure.setHost( defaultHost.getIdentifier() );
        testStructure.setFolder( testFolder.getInode() );
        testStructure.setName( structureName );
        testStructure.setStructureType( Structure.STRUCTURE_TYPE_CONTENT );
        testStructure.setOwner( user.getUserId() );
        testStructure.setVelocityVarName( structureName );
        StructureFactory.saveStructure( testStructure );
        StructureCache.addStructure( testStructure );
        //Adding test field

        Field field = new Field( "testSearchIndexByDateField", Field.FieldType.DATE_TIME,  Field.DataType.DATE, testStructure, true, true, true, 1, false, false, true );
        field.setVelocityVarName( "testSearchIndexByDateField" );
        field.setListed( true );
        FieldFactory.saveField( field );
        FieldsCache.addField( field );

        //Creating a test contentlet
        testContent = new Contentlet();
        testContent.setReviewInterval( "1m" );
        testContent.setStructureInode( testStructure.getInode() );
        testContent.setHost( defaultHost.getIdentifier() );
        testContent.setLanguageId(1);

        contentletAPI.setContentletProperty( testContent, field, "03/05/2014" );

        testContent = contentletAPI.checkin( testContent, null, permissionAPI.getPermissions( testStructure ), user, false );
        APILocator.getVersionableAPI().setLive(testContent);

      //And add it to the index
      indexAPI.addContentToIndex( testContent );
View Full Code Here

Examples of com.dotmarketing.business.PermissionAPI

     * @return
     * @throws Exception
     */
    private Structure loadTestStructure () throws Exception {

        PermissionAPI permissionAPI = APILocator.getPermissionAPI();

        //Set up a test folder
        Folder testFolder = APILocator.getFolderAPI().createFolders( "/" + new Date().getTime() + "/", defaultHost, user, false );
        permissionAPI.permissionIndividually( permissionAPI.findParentPermissionable( testFolder ), testFolder, user, false );

        //Set up a test structure
        String structureName = "ESContentletIndexAPITest_" + new Date().getTime();
        Structure testStructure = new Structure();
        testStructure.setHost( defaultHost.getIdentifier() );
View Full Code Here

Examples of com.dotmarketing.business.PermissionAPI

          dc.addParam(endDate);
          dc.addParam(structureInode);

          List<Map<String, String>> contentIdentifiers = dc.loadResults();

          PermissionAPI perAPI = APILocator.getPermissionAPI();
          IdentifierAPI identAPI = APILocator.getIdentifierAPI();

          for(Map<String, String> ident:contentIdentifiers){
            Identifier identifier = identAPI.find(ident.get("content_ident"));
            if(perAPI.doesUserHavePermission(identifier, PermissionAPI.PERMISSION_READ, user)){
              Map<String, String> h = new HashMap<String, String>();
              h.put("identifier", ident.get("content_ident"));
              h.put("numberOfViews", ident.get("numberOfViews"));
              result.add(h);
            }
View Full Code Here

Examples of com.dotmarketing.business.PermissionAPI

  public void _checkUserPermissions(Inode webAsset, User user, int permission) throws ActionException, DotDataException {
    // Checking permissions
    if (!InodeUtils.isSet(webAsset.getInode()))
      return;
    PermissionAPI perAPI = APILocator.getPermissionAPI();
    if (!perAPI.doesUserHavePermission(webAsset, permission, user)) {
      Logger.debug(DeliverCampaignThread.class, "_checkUserPermissions: user does not have permissions ( " + permission + " ) over this asset: " + webAsset);
      throw new ActionException(WebKeys.USER_PERMISSIONS_EXCEPTION);
    }
  }
View Full Code Here

Examples of com.dotmarketing.business.PermissionAPI

      localTransaction = DbConnectionFactory.getConnection().getAutoCommit();

      if (localTransaction) {
        HibernateUtil.startTransaction();
      }
      PermissionAPI papi = APILocator.getPermissionAPI();
      if (!papi.doesUserHavePermission(folder, PermissionAPI.PERMISSION_EDIT_PERMISSIONS, user)) {
        Logger.error(this.getClass(), "User " + user.getUserId() + " does not have permissions to folder " + folder.getInode());
        throw new DotSecurityException("User " + "does not have edit permissions on folder " + folder.getTitle());
      }

      Folder faker = new Folder();
View Full Code Here

Examples of com.dotmarketing.business.PermissionAPI

  public Map<String, Object> findHostsPaginated(String filter, boolean showArchived, int offset, int count) throws DotDataException, DotSecurityException, PortalException, SystemException {

    WebContext ctx = WebContextFactory.get();
    HttpServletRequest req = ctx.getHttpServletRequest();
    User user = userWebAPI.getLoggedInUser(req);
    PermissionAPI permissionAPI = APILocator.getPermissionAPI();

    boolean respectFrontend = !userWebAPI.isLoggedToBackend(req);
    List<Host> hosts = hostAPI.findAllFromDB(user, respectFrontend);

    long totalResults;
    List<Map<String, Object>> listOfHosts = new ArrayList<Map<String,Object>>(hosts.size());

    Structure hostStructure = StructureCache.getStructureByVelocityVarName("Host");
    List<Field> fields = FieldsCache.getFieldsByStructureVariableName("Host");

    List<Field> searchableFields = new ArrayList<Field>(fields.size());
    for(Field field : fields) {
      if(field.isListed() && field.getFieldType().startsWith("text"))
        searchableFields.add(field);
    }

    Collections.sort(hosts, new HostNameComparator());

    for(Host h : hosts) {
      if(h.isSystemHost())
        continue;
      boolean addToList = false;

      if (showArchived) {
        if(!UtilMethods.isSet(filter))
          addToList = true;
        else {
          for(Field searchableField : searchableFields) {
            String value = h.getStringProperty(searchableField.getVelocityVarName());
            if(value != null && value.toLowerCase().contains(filter.toLowerCase()))
              addToList = true;
          }
        }
      } else if (!h.isArchived()) {
        if(!UtilMethods.isSet(filter))
          addToList = true;
        else {
          for(Field searchableField : searchableFields) {
            String value = h.getStringProperty(searchableField.getVelocityVarName());
            if(value != null && value.toLowerCase().contains(filter.toLowerCase()))
              addToList = true;
          }
        }
      }


      if(addToList) {

        boolean hostInSetup = false;
        try {
          hostInSetup = QuartzUtils.isJobSequentiallyScheduled("setup-host-" + h.getIdentifier(), "setup-host-group");
        } catch (SchedulerException e) {
          Logger.error(HostAjax.class, e.getMessage(), e);
        }

        Map<String, Object> hostMap = h.getMap();
        hostMap.put("userPermissions", permissionAPI.getPermissionIdsFromUser(h, user));
        hostMap.put("hostInSetup", hostInSetup);
        hostMap.put("archived", h.isArchived());
        hostMap.put("live", h.isLive());
        listOfHosts.add(hostMap);
      }
View Full Code Here

Examples of com.dotmarketing.business.PermissionAPI

      HibernateUtil.delete(t);
    }

    object = (Category) HibernateUtil.load(Category.class, object.getInode());

    PermissionAPI perAPI = APILocator.getPermissionAPI();
    perAPI.removePermissions(object);

    HibernateUtil.delete(object);
    try {
      cleanParentChildrenCaches(object);
      catCache.remove(object);
View Full Code Here

Examples of com.dotmarketing.business.PermissionAPI

  private void _setRolePermission(UserProxy userProxy, ActionRequest req)
  throws Exception {
   
    User user = _getUser(req);
   
    PermissionAPI perAPI = APILocator.getPermissionAPI();
    // read permission
    String[] readPermissions = req.getParameterValues("readRole");
    // write permission
    String[] writePermissions = req.getParameterValues("writeRole");

    String userProxyInode = userProxy.getInode();

    if (InodeUtils.isSet(userProxyInode)) {

      //adding roles to user
      Permission permission = null;
      if (readPermissions != null) {
        for (int n = 0; n < readPermissions.length; n++) {
          permission = new Permission(userProxyInode, readPermissions[n],  PERMISSION_READ);
          perAPI.save(permission, userProxy, user, false);
        }
      }

      if (writePermissions != null) {
        for (int n = 0; n < writePermissions.length; n++) {
          permission = new Permission(userProxyInode, writePermissions[n], PERMISSION_WRITE);
          perAPI.save(permission, userProxy, user, false);
        }
      }
    }
  }
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.