Package com.dotmarketing.portlets.contentlet.business

Examples of com.dotmarketing.portlets.contentlet.business.HostAPI


  }

  @SuppressWarnings("unchecked")
  private Permissionable retrievePermissionable (String assetId, Long language, User user, boolean respectFrontendRoles) throws DotDataException, DotSecurityException {
   
    HostAPI hostAPI = APILocator.getHostAPI();
    Permissionable perm = null;

    //Determining the type
    try{
      //Host?
      perm = hostAPI.find(assetId, user, respectFrontendRoles);
    }
    catch(Exception e){

    }
   
View Full Code Here


  }
 
  protected Identifier createNewIdentifier(Versionable versionable, Folder folder, String existingId) throws DotDataException {

    User systemUser = APILocator.getUserAPI().getSystemUser();
    HostAPI hostAPI = APILocator.getHostAPI();

    String uuid=existingId;

    Identifier identifier = new Identifier();
    Identifier parentId=APILocator.getIdentifierAPI().find(folder);

    if(versionable instanceof Folder) {
      identifier.setAssetType("folder");
      identifier.setAssetName(((Folder) versionable).getName());
    }
    else {
      String uri = versionable.getVersionType() + "." + versionable.getInode();
      identifier.setId(uuid);
      if(versionable instanceof Contentlet){
        Contentlet cont = (Contentlet)versionable;
        if(cont.getStructure().getStructureType()==Structure.STRUCTURE_TYPE_FILEASSET){
          try {
            uri = cont.getBinary(FileAssetAPI.BINARY_FIELD)!=null?cont.getBinary(FileAssetAPI.BINARY_FIELD).getName():"";
            if(UtilMethods.isSet(cont.getStringProperty(FileAssetAPI.FILE_NAME_FIELD)))//DOTCMS-7093
              uri = cont.getStringProperty(FileAssetAPI.FILE_NAME_FIELD);
          } catch (IOException e) {
            Logger.debug(this, e.getMessage() + " Issue happened while assigning Binary Field");
          }
        }
        identifier.setAssetType("contentlet");
        identifier.setParentPath(parentId.getPath());
        identifier.setAssetName(uri);
      } else if (versionable instanceof WebAsset) {
        identifier.setURI(((WebAsset) versionable).getURI(folder));
        identifier.setAssetType(versionable.getVersionType());
        if(versionable instanceof Link)
            identifier.setAssetName(versionable.getInode());
      } else{
        identifier.setURI(uri);
        identifier.setAssetType(versionable.getVersionType());
      }
      identifier.setId(null);
    }

    Host host;
    try {
      host = hostAPI.findParentHost(folder, systemUser, false);
    } catch (DotSecurityException e) {
      throw new DotStateException("I can't find the parent host!");
    }
   
    if("folder".equals(identifier.getAssetType()) && APILocator.getHostAPI().findSystemHost().getIdentifier().equals(host.getIdentifier())){
View Full Code Here

  public Permissionable getParentPermissionable() throws DotDataException {

    try {
      User systemUser = APILocator.getUserAPI().getSystemUser();
      HostAPI hostAPI = APILocator.getHostAPI();
      Host host = hostAPI.findParentHost(this, systemUser, false);

      if (host == null) {
        host = hostAPI.findSystemHost(systemUser, false);
      }
      return host;
    } catch (DotSecurityException e) {
      Logger.error(Container.class, e.getMessage(), e);
      throw new DotRuntimeException(e.getMessage(), e);
View Full Code Here

        HttpServletRequest req = WebContextFactory.get().getHttpServletRequest();
        User user = getUser( req );

        UserWebAPI userWebAPI = WebAPILocator.getUserWebAPI();
        HostAPI hostAPI = APILocator.getHostAPI();

        //Searching for the folder to copy
        Folder folder = APILocator.getFolderAPI().find( inode, user, false );

        if ( !folderAPI.exists( newFolder ) ) {

            Host parentHost = hostAPI.find( newFolder, user, !userWebAPI.isLoggedToBackend( req ) );

            if ( !permissionAPI.doesUserHavePermission( folder, PERMISSION_WRITE, user ) || !permissionAPI.doesUserHavePermission( parentHost, PERMISSION_WRITE, user ) ) {
                throw new DotRuntimeException( "The user doesn't have the required permissions." );
            }
View Full Code Here

        return container;
    }

    public static Container copyContainer (Container currentContainer) throws DotDataException, DotStateException, DotSecurityException {

      HostAPI hostAPI = APILocator.getHostAPI();

    //gets the new information for the template from the request object
    Container newContainer = new Container();

    newContainer.copy(currentContainer);
         newContainer.setFriendlyName(currentContainer.getFriendlyName()
        + " (COPY) ");
         newContainer.setTitle(currentContainer.getTitle() + " (COPY) ");

        //Copy the structure
//        Structure st = StructureCache.getStructureByInode(currentContainer.getStructureInode());
//        newContainer.setStructureInode(st.getInode());



    //persists the webasset
    HibernateUtil.saveOrUpdate(newContainer);


    //Copy the host
    Host h;
    try {
      h = hostAPI.findParentHost(currentContainer, APILocator.getUserAPI().getSystemUser(), false);
    } catch (DotSecurityException e) {
      Logger.error(ContainerFactory.class, e.getMessage(), e);
      throw new DotRuntimeException(e.getMessage(), e);
    }
        //TreeFactory.saveTree(new Tree(h.getIdentifier(), newContainer.getInode()));
View Full Code Here

        return hostMap;
  }

  private Map<String, Object> folderMap(Folder f) throws DotDataException, DotSecurityException {
      UserWebAPI userWebAPI = WebAPILocator.getUserWebAPI();
    HostAPI hostAPI = APILocator.getHostAPI();
    Map<String, Object> folderMap = new HashMap<String, Object>();
    folderMap.put("type", "folder");
    folderMap.put("name", f.getName());
    folderMap.put("id", f.getInode());
    folderMap.put("inode", f.getInode());
    folderMap.put("defaultFileType", f.getDefaultFileType());
    String currentPath = hostAPI.findParentHost(f, userWebAPI.getSystemUser(), false).getHostname();
    String fullPath = currentPath + ":/" + f.getName();
    String absolutePath = "/" + f.getName();
    folderMap.put("fullPath", fullPath);
    folderMap.put("absolutePath", absolutePath);
        return folderMap;
View Full Code Here

      roles = com.dotmarketing.business.APILocator.getRoleAPI().loadRolesForUser(user.getUserId()).toArray(new Role[0]);
    } catch (DotDataException e1) {
      Logger.error(BrowserAjax.class,e1.getMessage(),e1);
    }
        boolean respectFrontendRoles = userWebAPI.isLoggedToFrontend(ctx.getHttpServletRequest());
    HostAPI hostAPI = APILocator.getHostAPI();
    List<Host> hosts = hostAPI.findAll(user, respectFrontendRoles);
    List<Map<String, Object>> hostsToReturn = new ArrayList<Map<String,Object>>(hosts.size());
    Collections.sort(hosts, new HostNameComparator());
    for (Host h: hosts) {
      List permissions = new ArrayList();
      try {
View Full Code Here

  public List<Map<String, Object>> getHostsByPermissions(String requiredPermissions) throws PortalException, SystemException, DotDataException, DotSecurityException {
      UserWebAPI userWebAPI = WebAPILocator.getUserWebAPI();
      WebContext ctx = WebContextFactory.get();
        User user = userWebAPI.getLoggedInUser(ctx.getHttpServletRequest());
        boolean respectFrontendRoles = userWebAPI.isLoggedToFrontend(ctx.getHttpServletRequest());
    HostAPI hostAPI = APILocator.getHostAPI();
    List<Host> hosts = hostAPI.findAll(user, respectFrontendRoles);
    List<Map<String, Object>> hostsToReturn = new ArrayList<Map<String,Object>>(hosts.size());
    Collections.sort(hosts, new HostNameComparator());
    for (Host h: hosts) {
      if(UtilMethods.isSet(requiredPermissions)){
        if(permissionAPI.doesUserHavePermissions(h,requiredPermissions, user)){
View Full Code Here

  public List<Map<String, Object>> getHostsWithThemes() throws PortalException, SystemException, DotDataException, DotSecurityException {
      UserWebAPI userWebAPI = WebAPILocator.getUserWebAPI();
      WebContext ctx = WebContextFactory.get();
        User user = userWebAPI.getLoggedInUser(ctx.getHttpServletRequest());
    HostAPI hostAPI = APILocator.getHostAPI();

    // get hosts the user has read permissions on
    List<Host> hosts = hostAPI.getHostsWithPermission(com.dotmarketing.business.PermissionAPI.PERMISSION_READ, false, user, false);

    List<Map<String, Object>> hostsToReturn = new ArrayList<Map<String,Object>>(hosts.size());
    List<Host> filteredHosts = new ArrayList<Host>();

    for (Host h : hosts) {
View Full Code Here

      roles = com.dotmarketing.business.APILocator.getRoleAPI().loadRolesForUser(user.getUserId()).toArray(new Role[0]);
    } catch (DotDataException e1) {
      Logger.error(BrowserAjax.class,e1.getMessage(),e1);
    }
    boolean respectFrontendRoles = userWebAPI.isLoggedToFrontend(ctx.getHttpServletRequest());
    HostAPI hostAPI = APILocator.getHostAPI();
    List<Host> hosts = hostAPI.findAll(user, respectFrontendRoles);
    List<Map<String, Object>> hostsToReturn = new ArrayList<Map<String,Object>>(hosts.size());
    Collections.sort(hosts, new HostNameComparator());
    for (Host h: hosts) {
      List permissions = new ArrayList();
      try {
        permissions = permissionAPI.getPermissionIdsFromRoles(h, roles, user);
      } catch (DotDataException e) {
        Logger.error(this, "Could not load permissions : ",e);
      }
      if(permissions.contains(PERMISSION_READ)){
        hostsToReturn.add(hostMap(h));
      }
    }
    Host system = hostAPI.findSystemHost();
    List permissions = new ArrayList();
    try {
      permissions = permissionAPI.getPermissionIdsFromRoles(system, roles, user);
    } catch (DotDataException e) {
      Logger.error(this, "Could not load permissions : ",e);
View Full Code Here

TOP

Related Classes of com.dotmarketing.portlets.contentlet.business.HostAPI

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.