Package com.dotmarketing.portlets.contentlet.business

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


    boolean isStructure = permissionable instanceof Structure;

    if(!isHost && !isFolder && !isCategory && !isStructure)
      return;

    HostAPI hostAPI = APILocator.getHostAPI();
    Host systemHost = hostAPI.findSystemHost();
    DotConnect dc = new DotConnect();

    boolean ran01=false,ran02=false,ran03=false,ran04=false,ran05=false,
            ran06=false,ran07=false,ran08=false,ran09=false,ran10=false;

    List<Map<String, Object>> idsToClear = new ArrayList<Map<String, Object>>();
    List<Permission> permissions = filterOnlyInheritablePermissions(loadPermissions(permissionable), parentPermissionableId);
    for(Permission p : permissions) {

      if (isHost || isFolder) {

        Host parentHost = null;
        if(isFolder)
          try {
            parentHost = hostAPI.findParentHost((Folder)permissionable, APILocator.getUserAPI().getSystemUser(), false);
          } catch (DotSecurityException e) {
            Logger.error(this, e.getMessage(), e);
          }
        else
          parentHost = (Host)permissionable;
View Full Code Here


          if(inheritedPermissions.size() > 0) {
            break;
          }
          parentPermissionable = parentPermissionable.getParentPermissionable();
        }
        HostAPI hostAPI = APILocator.getHostAPI();
        if(newReference == null)
          newReference = hostAPI.findSystemHost();
        boolean localTransaction = false;
        try{
          try{
            localTransaction =   HibernateUtil.startLocalTransactionIfNeeded();
          }
View Full Code Here

    boolean isFolder = permissionable instanceof Folder;
    boolean isStructure = permissionable instanceof Structure;
    boolean isCategory = permissionable instanceof Category;

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

    //Search all children remove individual permissions and permission references and make them point to this permissionable
    List<Map<String, String>> idsToClear = new ArrayList<Map<String,String>>();
    if(isHost || isFolder) {

      Permissionable host = null;
      try {
        host = isHost?permissionable:hostAPI.findParentHost((Folder)permissionable, systemUser, false);
      } catch (DotSecurityException e) {
        Logger.error(PermissionBitFactoryImpl.class, e.getMessage(), e);
        throw new DotRuntimeException(e.getMessage(), e);
      }
      Folder folder = isFolder?(Folder)permissionable:null;
View Full Code Here

    if(!isHost && !isFolder) {
      Logger.info(this, "Ending cascade role permissions (not a folder or a host) for permissionable " + permissionable.getPermissionId() + " for role " + role.getId());
      return;
    }

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

    List<Permission> allPermissions = filterOnlyInheritablePermissions(loadPermissions(permissionable), permissionable.getPermissionId());

    if(isHost && permissionable.getPermissionId().equals(systemHost.getPermissionId())) {
      List<Host> allHosts;
      try {
        allHosts = hostAPI.findAll(systemUser, false);
      } catch (DotSecurityException e) {
        Logger.error(PermissionBitFactoryImpl.class, e.getMessage(), e);
        throw new DotRuntimeException(e.getMessage(), e);
      }
      for(Host host : allHosts) {
View Full Code Here

    boolean isHost = permissionable instanceof Host ||
      (permissionable instanceof Contentlet && ((Contentlet)permissionable).getStructure().getVelocityVarName().equals("Host"));
    boolean isFolder = permissionable instanceof Folder;

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

    Permissionable host = null;
    try {
      host = isHost ? permissionable : hostAPI.findParentHost((Folder) permissionable, systemUser, false);
    } catch (DotSecurityException e) {
      Logger.error(PermissionBitFactoryImpl.class, e.getMessage(), e);
      throw new DotRuntimeException(e.getMessage(), e);
    }
    Folder folder = isFolder ? (Folder) permissionable : null;
View Full Code Here

      filter = filter.substring(0, filter.length() - 1);
    WebContext ctx = WebContextFactory.get();
    HttpServletRequest req = ctx.getHttpServletRequest();
    User user = userWebAPI.getLoggedInUser(req);

    HostAPI hostAPI = APILocator.getHostAPI();
    List<Host> hosts = hostAPI.findAll(user, userWebAPI.isLoggedToFrontend(req));
    List<Map<String, Object>> hostResults = new ArrayList<Map<String, Object>>();
    Collections.sort(hosts, new HostNameComparator());

    for(Host host : hosts) {
      if(host.isSystemHost() || (!showArchived && host.isArchived()))
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) {
      throw new DotRuntimeException(e.getMessage(), e);
    }
View Full Code Here

  @SuppressWarnings("unchecked")
  public void _saveWebAsset(ActionRequest req, ActionResponse res,
      PortletConfig config, ActionForm form, User user) throws Exception {

    HostAPI hostAPI = APILocator.getHostAPI();
    IdentifierAPI identifierAPI = APILocator.getIdentifierAPI();
   
    //wraps request to get session object
    ActionRequestImpl reqImpl = (ActionRequestImpl) req;
    HttpServletRequest httpReq = reqImpl.getHttpServletRequest();

    LinkForm linkForm = (LinkForm) form;
   
    //gets the new information for the link from the request object
    Link link = new Link();
    link.setTitle(((LinkForm) form).getTitle());   
    BeanUtils.copyProperties(link,form);
    req.setAttribute(WebKeys.LINK_FORM_EDIT,link);
   
    boolean previousShowMenu = link.isShowOnMenu();

    //gets the current link being edited from the request object
    Link currentLink = (Link) req.getAttribute(WebKeys.LINK_EDIT);
   
    //parent folder or inode for this file
    Folder parent = APILocator.getFolderAPI().find(req.getParameter("parent"), user, false);
    //http://jira.dotmarketing.net/browse/DOTCMS-5899
    if(UtilMethods.isSet(currentLink.getInode())){
      Identifier id = APILocator.getIdentifierAPI().find(currentLink);
      String URI = id.getURI();
      String uriPath = URI.substring(0,URI.lastIndexOf("/")+1);
      if(!uriPath.equals(APILocator.getIdentifierAPI().find(parent).getPath())){
        id.setURI(APILocator.getIdentifierAPI().find(parent).getPath()+currentLink.getProtocal() + currentLink.getUrl());
        APILocator.getIdentifierAPI().save(id);
      }
    }
   
    //Checking permissions
    _checkPermissions(currentLink, parent, user, httpReq);

    //gets user id from request for mod user
    String userId = user.getUserId();

    // take care of internal links
    if (InodeUtils.isSet(linkForm.getInternalLinkIdentifier())) {

      Identifier internalLinkIdentifier = identifierAPI.findFromInode(linkForm.getInternalLinkIdentifier());
      //link.setLinkType(LinkType.INTERNAL.toString());
      link.setInternalLinkIdentifier(internalLinkIdentifier.getInode());
      link.setProtocal("http://");

      StringBuffer myURL = new StringBuffer();
      if(InodeUtils.isSet(internalLinkIdentifier.getHostId())) {
        Host host = hostAPI.find(internalLinkIdentifier.getHostId(), user, false);
        myURL.append(host.getHostname());
      }
      myURL.append(internalLinkIdentifier.getURI());
      link.setUrl(myURL.toString());
     
View Full Code Here

    Folder folder = APILocator.getFolderAPI().findParentFolder(object, APILocator.getUserAPI().getSystemUser(),false);
    return folder;
  }

  public Host getParentHost(HTMLPage object) throws DotIdentifierStateException, DotDataException, DotSecurityException {
    HostAPI hostAPI = APILocator.getHostAPI();

    Folder folder = APILocator.getFolderAPI().findParentFolder(object, APILocator.getUserAPI().getSystemUser(),false);
    Host host;
    try {
      User systemUser = APILocator.getUserAPI().getSystemUser();
      host = hostAPI.findParentHost(folder, systemUser, false);
    } catch (DotDataException e) {
      Logger.error(HTMLPageFactory.class, e.getMessage(), e);
      throw new DotRuntimeException(e.getMessage(), e);
    } catch (DotSecurityException e) {
      Logger.error(HTMLPageFactory.class, e.getMessage(), e);
View Full Code Here

  @SuppressWarnings("unchecked")
  private void addPermissionToRoleList(Permissionable perm, Permission p, Map<String, Map<String, Object>> roles, boolean inheritable) throws DotDataException, DotSecurityException {
    Map<String, Permissionable> inodeCache = new HashMap<String, Permissionable>();

    RoleAPI roleAPI = APILocator.getRoleAPI();
    HostAPI hostAPI = APILocator.getHostAPI();
    User systemUser = APILocator.getUserAPI().getSystemUser();
    String roleId = p.getRoleId();
    Map<String, Object> roleMap = roles.get(roleId);
    if(roleMap == null) {
      Role role = roleAPI.loadRoleById(roleId);
      if(role == null)
        return;
      roleMap = role.toMap();
      roles.put(role.getId(), roleMap);
      if(!inheritable) {
        if(p.getInode().equals(perm.getPermissionId())) {
          roleMap.put("inherited", false);
        } else {
          roleMap.put("inherited", true);
          String assetInode = p.getInode();

          //try from the cache
          Permissionable permParent = inodeCache.get(p.getInode());
          if(permParent == null) {
            // because identifiers are not Inodes, we need to do a double lookup
            permParent = InodeFactory.getInode(assetInode, Inode.class);
            if(permParent !=null || InodeUtils.isSet(permParent.getPermissionId())){
              inodeCache.put(permParent.getPermissionId(), permParent);

            }
            else{
              permParent = APILocator.getIdentifierAPI().find(assetInode);
              if(permParent != null && InodeUtils.isSet(permParent.getPermissionId())){
                inodeCache.put(permParent.getPermissionId(), permParent);
              }
            }
          }
          if(permParent instanceof Folder) {
            roleMap.put("inheritedFromType", "folder");
            roleMap.put("inheritedFromPath", APILocator.getIdentifierAPI().find((Folder)permParent).getPath());
            roleMap.put("inheritedFromId", ((Folder)permParent).getInode());
          } else if (permParent instanceof Structure) {
            roleMap.put("inheritedFromType", "structure");
            roleMap.put("inheritedFromPath", ((Structure)permParent).getName());
            roleMap.put("inheritedFromId", ((Structure)permParent).getInode());
          } else if (permParent instanceof Category) {
            roleMap.put("inheritedFromType", "category");
            roleMap.put("inheritedFromPath", ((Category)permParent).getCategoryName());
            roleMap.put("inheritedFromId", ((Category)permParent).getInode());
          } else {
            Host host = hostAPI.find(assetInode, systemUser, false);
            if(host != null) {
              roleMap.put("inheritedFromType", "host");
              roleMap.put("inheritedFromPath", host.getHostname());
              roleMap.put("inheritedFromId", host.getIdentifier());
            }
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.