Package com.dotmarketing.portlets.links.model

Examples of com.dotmarketing.portlets.links.model.Link


  }
 
  @Override
  protected Link get(String key) {
    key = primaryGroup + key;
    Link menuLink = null;
      try{
        menuLink = (Link)cache.get(key,primaryGroup);
      }catch (DotCacheException e) {
      Logger.debug(this, "Cache Entry not found", e);
    }
View Full Code Here


 
  public void save(Link menuLink, Folder destination) throws DotDataException, DotStateException, DotSecurityException {
   
   
    if(UtilMethods.isSet(menuLink.getInode())) {
      Link oldLink = null;
      try{
        oldLink = (Link) HibernateUtil.load(Link.class, menuLink.getInode());
      }catch(DotHibernateException dhe){
        Logger.debug(this.getClass(), dhe.getMessage());
      }
     
      if(oldLink!=null && InodeUtils.isSet(oldLink.getIdentifier())) {
        oldLink.copy(menuLink);
        HibernateUtil.saveOrUpdate(oldLink);
        HibernateUtil.flush();
        menuLink = oldLink;
      } else {
        String existingId=menuLink.getIdentifier();
View Full Code Here

    if (!permissionAPI.doesUserHavePermission(destination, PermissionAPI.PERMISSION_WRITE, user, respectFrontendRoles)) {
      throw new DotSecurityException("You don't have permission to wirte in the destination folder.");
    }

    Link newLink = new Link();

        newLink.copy(sourceLink);
       
        // translating internal link if internal and different host than the target folder
        if(sourceLink.getLinkType().equals(Link.LinkType.INTERNAL.toString()) &&
                !APILocator.getIdentifierAPI().find(sourceLink).getHostId().equals(destination.getHostId())) {

            Host destHost=APILocator.getHostAPI().find(destination.getHostId(),user,false);
            if(sourceLink.getUrl()!=null && sourceLink.getUrl().contains("/")) {
                String assetPath=sourceLink.getUrl().substring(sourceLink.getUrl().indexOf('/'));
                newLink.setUrl(destHost.getHostname()+assetPath);
            }

            // using source internal link ident get URI on source host. Link to same asset in dest host
            Identifier ident=APILocator.getIdentifierAPI().find(sourceLink.getInternalLinkIdentifier());
            if(ident!=null && UtilMethods.isSet(ident.getId())) {
                Identifier newTargetIdent=APILocator.getIdentifierAPI().find(destHost, ident.getURI());
                if(newTargetIdent!=null && UtilMethods.isSet(newTargetIdent.getId())) {
                    String newLinkIdent=newTargetIdent.getId();
                    newLink.setInternalLinkIdentifier(newLinkIdent);
                }
            }
        }
       
        newLink.setFriendlyName(sourceLink.getFriendlyName());
        newLink.setTitle(sourceLink.getTitle());
        newLink.setShowOnMenu(sourceLink.isShowOnMenu());
        newLink.setProtocal(sourceLink.getProtocal());
        newLink.setLinkCode(sourceLink.getLinkCode());
        newLink.setLinkType(sourceLink.getLinkType());

        //persists the webasset
        save(newLink, destination, user, respectFrontendRoles);

        if(sourceLink.isLive())
View Full Code Here


    @Override
    public Link find(String inode, User user, boolean respectFrontEndRoles) throws DotDataException, DotSecurityException{

      Link link = menuLinkFactory.load(inode);

      if(!APILocator.getPermissionAPI().doesUserHavePermission(link, PermissionAPI.PERMISSION_READ, user,respectFrontEndRoles)){
        throw new DotSecurityException("User "+ user + " does not have permission to link " + inode);
      }
      return link;
View Full Code Here

    }

    List links = getChildrenClass(source,Link.class);
    for (Link link : (List<Link>) links) {
      if (link.isWorking()) {
        Link newLink = LinkFactory.copyLink(link, newFolder);
        // Saving copied pages to update template - pages relationships
        // later
        linksCopied.put(link.getInode(), new Link[] { link, newLink });
      }
    }
View Full Code Here

            Logger.error(this, "Error trying to obtain the current liferay user from the request.", e);
            throw new DotRuntimeException ("Error trying to obtain the current liferay user from the request.");
        }

      HashMap<String, Object> result = new HashMap<String, Object> ();
      Link link = (Link) InodeFactory.getInode(inode, Link.class);
      String oldName = link.getTitle();
      result.put("lastName", oldName);
      result.put("extension", "");
      result.put("newName", newName);
      result.put("inode", inode);
      if (LinkFactory.renameLink(link, newName, user)) {
          result.put("result", 0);
      } else {
          result.put("result", 1);
          if (link.isLocked())
            result.put("errorReason", "The link is locked");
          else
            result.put("errorReason", "Another link with the same name already exists on this folder");
      }
      return result;
View Full Code Here

    public boolean copyLink ( String inode, String newFolder ) throws Exception {

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

        Link link = (Link) InodeFactory.getInode( inode, Link.class );

        // gets folder parent
        Folder parent = null;
        try {
            parent = APILocator.getFolderAPI().find( newFolder, user, false );
View Full Code Here

    public boolean moveLink ( String inode, String newFolder ) throws Exception {

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

        Link link = (Link) InodeFactory.getInode( inode, Link.class );

        // gets folder parent
        Folder parent = null;
        try {
            parent = APILocator.getFolderAPI().find( newFolder, user, false );
View Full Code Here

     * @throws DotDataException
     */
    protected static Link createMenuLink () throws DotSecurityException, DotDataException {

        //Creating the menu link
        Link menuLink = new Link();
        menuLink.setModUser( user.getUserId() );
        menuLink.setOwner( user.getUserId() );
        menuLink.setProtocal( "" );
        menuLink.setShowOnMenu( true );
        menuLink.setSortOrder( 2 );
        menuLink.setTarget( "_blank" );
        menuLink.setTitle( "JUnit MenuLink Test" );
        menuLink.setType( "links" );
        menuLink.setUrl( "www.dotcms.org" );
        menuLink.setFriendlyName( "JUnit Test Menu Link" );
        menuLink.setIDate( new Date() );
        menuLink.setInternalLinkIdentifier( "" );
        menuLink.setLinkCode( "" );
        menuLink.setLinkType( Link.LinkType.EXTERNAL.toString() );
        menuLink.setModDate( new Date() );

        //Saving it and adding it permissions
        menuLinkAPI.save( menuLink, testFolder, user, false );
        permissionAPI.copyPermissions( testFolder, menuLink );

View Full Code Here

         */
        Folder parent1 = fAPI.createFolders("/parent1/sub", host, user, false);
        Folder parent2 = fAPI.createFolders("/parent2/sub", host, user, false);
        pAPI.permissionIndividually(host, parent2, user, false);
       
        Link link = new Link();
        link.setFriendlyName("test link");
        link.setTitle(link.getFriendlyName());
        link.setHostId(host.getIdentifier());
        link.setLinkType(Link.LinkType.EXTERNAL.toString());
        link.setUrl("google.com");
        link.setProtocal("http://");
        mAPI.save(link, parent1, user, false);
       
        // must be getting permissions from the host
        assertEquals(host.getPermissionId(), pAPI.findParentPermissionable(link).getPermissionId());
        assertTrue(mAPI.move(link, parent2, user, false));
View Full Code Here

TOP

Related Classes of com.dotmarketing.portlets.links.model.Link

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.