Package com.dotmarketing.portlets.contentlet.model

Examples of com.dotmarketing.portlets.contentlet.model.ContentletVersionInfo


        if(!UtilMethods.isSet(versionable) || !UtilMethods.isSet(versionable.getVersionId()))
            throw new DotStateException("invalid identifier");
        Identifier ident = APILocator.getIdentifierAPI().find(versionable);
        if(ident.getAssetType().equals("contentlet")) {
            Contentlet cont = (Contentlet)versionable;
            ContentletVersionInfo info = vfac.getContentletVersionInfo(cont.getIdentifier(), cont.getLanguageId());
            if(info ==null || !UtilMethods.isSet(info.getIdentifier())) {
                // Not yet created
                info = vfac.createContentletVersionInfo(ident, cont.getLanguageId(), versionable.getInode());
            }
            else {
                info.setWorkingInode(versionable.getInode());
                vfac.saveContentletVersionInfo(info, true);
            }
        }
        else {
            VersionInfo info = vfac.findVersionInfoFromDb(ident);

            if(info ==null || !UtilMethods.isSet(info.getIdentifier())) {
                // Not yet created
                vfac.createVersionInfo(ident, versionable.getInode());
            }
            else {
                info.setWorkingInode(versionable.getInode());
                vfac.saveVersionInfo(info, true);
            }
        }
    }
View Full Code Here


            throw new DotStateException("invalid identifier");
        Identifier ident = APILocator.getIdentifierAPI().find(ver.getVersionId());
        String userId;
        if(ident.getAssetType().equals("contentlet")) {
            Contentlet cont=(Contentlet)ver;
            ContentletVersionInfo vinfo=vfac.getContentletVersionInfo(cont.getIdentifier(),cont.getLanguageId());
            userId=vinfo.getLockedBy();
        }
        else {
            VersionInfo vinfo=vfac.getVersionInfo(ver.getVersionId());
            userId=vinfo.getLockedBy();
        }
        if(userId==null)
            throw new DotStateException("asset is not locked");
        return userId;
    }
View Full Code Here

            throw new DotStateException("invalid identifier");
        Identifier ident = APILocator.getIdentifierAPI().find(ver.getVersionId());
        Date date;
        if(ident.getAssetType().equals("contentlet")) {
            Contentlet cont=(Contentlet)ver;
            ContentletVersionInfo vinfo=vfac.getContentletVersionInfo(cont.getIdentifier(),cont.getLanguageId());
            date=vinfo.getLockedOn();
        }
        else {
            VersionInfo vinfo=vfac.getVersionInfo(ident.getId());
            date=vinfo.getLockedOn();
        }
        if(date==null)
            throw new DotStateException("asset is not locked");
        return date;
    }
View Full Code Here

    vfac.saveVersionInfo(vInfo, true);
  }

  @Override
  public void saveContentletVersionInfo( ContentletVersionInfo cvInfo) throws DotDataException, DotStateException {
    ContentletVersionInfo info = vfac.findContentletVersionInfoInDB(cvInfo.getIdentifier(), cvInfo.getLang());
    if(info == null){
      vfac.saveContentletVersionInfo(cvInfo, true);
    }else{
      info.setDeleted(cvInfo.isDeleted());
      info.setLiveInode(cvInfo.getLiveInode());
      info.setLockedBy(cvInfo.getLockedBy());
      info.setLockedOn(cvInfo.getLockedOn());
      info.setWorkingInode(cvInfo.getWorkingInode());
      vfac.saveContentletVersionInfo(info, true);
    }
  }
View Full Code Here

      vfac.deleteContentletVersionInfo(identifier, lang);
  }

  public boolean hasLiveVersion(Versionable verthrows DotDataException, DotStateException{
    if(ver instanceof Contentlet) {
      ContentletVersionInfo vi = this.getContentletVersionInfo(ver.getVersionId(), ((Contentlet) ver).getLanguageId());
      return (vi != null && UtilMethods.isSet(vi.getLiveInode()));
    }
    else{
      VersionInfo vi = this.getVersionInfo(ver.getVersionId());
      return (vi != null && UtilMethods.isSet(vi.getLiveInode()));
    }
  }
View Full Code Here

      loadFields(con, m);
      loadPermissions(con, m);
      loadRelationshipFields(con, m);

      Identifier ident = APILocator.getIdentifierAPI().find(con);
      ContentletVersionInfo cvi = APILocator.getVersionableAPI().getContentletVersionInfo(ident.getId(), con.getLanguageId());
      Structure st=StructureCache.getStructureByInode(con.getStructureInode());

      Folder conFolder=APILocator.getFolderAPI().findFolderByPath(ident.getParentPath(), ident.getHostId(), APILocator.getUserAPI().getSystemUser(), false);

      m.put("title", con.getTitle());
      m.put("structureName", st.getVelocityVarName());
            m.put("structureType", st.getStructureType() + "");
            m.put("inode", con.getInode());
            m.put("type", "content");
            m.put("modDate", datetimeFormat.format(con.getModDate()));
            m.put("owner", con.getOwner()==null ? "0" : con.getOwner());
            m.put("modUser", con.getModUser());
            m.put("live", Boolean.toString(con.isLive()));
            m.put("working", Boolean.toString(con.isWorking()));
            m.put("locked", Boolean.toString(con.isLocked()));
            m.put("deleted", Boolean.toString(con.isArchived()));
            m.put("languageId", Long.toString(con.getLanguageId()));
            m.put("identifier", ident.getId());
            m.put("conHost", ident.getHostId());
            m.put("conFolder", conFolder!=null && InodeUtils.isSet(conFolder.getInode()) ? conFolder.getInode() : con.getFolder());
            m.put("parentPath", ident.getParentPath());
            m.put("path", ident.getPath());

            if(UtilMethods.isSet(ident.getSysPublishDate()))
                m.put("pubdate", datetimeFormat.format(ident.getSysPublishDate()));
            else
                m.put("pubdate", datetimeFormat.format(cvi.getVersionTs()));

            if(UtilMethods.isSet(ident.getSysExpireDate()))
                m.put("expdate", datetimeFormat.format(ident.getSysExpireDate()));
            else
                m.put("expdate", "29990101000000");

            m.put("versionTs", datetimeFormat.format(cvi.getVersionTs()));

            String urlMap = null;
            try{
              urlMap = APILocator.getContentletAPI().getUrlMapForContentlet(con, APILocator.getUserAPI().getSystemUser(), true);
                if(urlMap != null){
View Full Code Here

           
            if(InodeUtils.isSet(con.getInode())){
                APILocator.getPermissionAPI().removePermissions(con);

                ContentletVersionInfo verInfo=APILocator.getVersionableAPI().getContentletVersionInfo(con.getIdentifier(), con.getLanguageId());
                if(verInfo!=null && UtilMethods.isSet(verInfo.getIdentifier())) {
                    if(UtilMethods.isSet(verInfo.getLiveInode()) && verInfo.getLiveInode().equals(con.getInode()))
                        try {
                            APILocator.getVersionableAPI().removeLive(con);
                        } catch (Exception e) {
                            throw new DotDataException(e.getMessage(),e);
                        }
                    if(verInfo.getWorkingInode().equals(con.getInode()))
                        APILocator.getVersionableAPI().deleteContentletVersionInfo(con.getIdentifier(), con.getLanguageId());
                }

                try {
                    com.dotmarketing.portlets.contentlet.business.Contentlet c =
View Full Code Here

            if(rr instanceof File) {
                Assert.assertNotSame(filename, ((File)rr).name);
            }
        }
       
        ContentletVersionInfo vi = APILocator.getVersionableAPI().getContentletVersionInfo(file.getIdentifier(), 1);
        Assert.assertTrue(vi.isDeleted());
  }
View Full Code Here

       
        try {
            if(!modified && assetType.equals("content")) {
                // check for versionInfo TS on content
                for(Language lang : APILocator.getLanguageAPI().getLanguages()) {
                            ContentletVersionInfo info=APILocator.getVersionableAPI().getContentletVersionInfo(assetId, lang.getId());
                            if(info!=null && InodeUtils.isSet(info.getIdentifier())) {
                                modified = modified || assetModDate.before(info.getVersionTs());
                            }
                }
            }
            if(!modified && (assetType.equals("template") || assetType.equals("links") || assetType.equals("container") || assetType.equals("htmlpage"))) {
                // check for versionInfo TS
                        VersionInfo info=APILocator.getVersionableAPI().getVersionInfo(assetId);
                        if(info!=null && InodeUtils.isSet(info.getIdentifier())) {
                            modified = assetModDate.before(info.getVersionTs());
                        }
            }
        } catch (Exception e) {
                    Logger.warn(getClass(), "Error checking versionInfo for assetType:"+assetType+" assetId:"+assetId+
                            " process continues without checking versionInfo.ts",e);
View Full Code Here

                            Logger.error(this, "Error compiling "+host.getHostname()+":"+uri, ex);
                            throw new Exception(ex);
                        }
                       
                        // build cache object
                        ContentletVersionInfo vinfo = APILocator.getVersionableAPI().getContentletVersionInfo(ident.getId(), defLang);
                        CachedCSS newcache = new CachedCSS();
                        newcache.data = compiler.getOutput();
                        newcache.hostId = host.getIdentifier();
                        newcache.uri = actualUri;
                        newcache.live = live;
                        newcache.modDate = vinfo.getVersionTs();
                        newcache.imported = new ArrayList<ImportedAsset>();
                        for(String importUri : compiler.getAllImportedURI()) {
                            // newcache entry for the imported asset
                            ImportedAsset asset = new ImportedAsset();
                            asset.uri = importUri;
                            Identifier ii;
                            if(importUri.startsWith("//")) {
                                importUri=importUri.substring(2);
                                String hn=importUri.substring(0, importUri.indexOf('/'));
                                String uu=importUri.substring(importUri.indexOf('/'));
                                ii = APILocator.getIdentifierAPI().find(APILocator.getHostAPI().findByName(hn, user, live),uu);
                            }
                            else {
                                ii = APILocator.getIdentifierAPI().find(host, importUri);
                            }
                            ContentletVersionInfo impInfo = APILocator.getVersionableAPI().getContentletVersionInfo(ii.getId(), defLang);
                            asset.modDate = impInfo.getVersionTs();
                            newcache.imported.add(asset);
                            Logger.debug(this, host.getHostname()+":"+actualUri+" imports-> "+importUri);
                           
                            // actual cache entry for the imported asset. If needed
                            synchronized(ii.getId().intern()) {
                                if(CacheLocator.getCSSCache().get(ii.getHostId(), importUri, live, user)==null) {
                                    CachedCSS entry = new CachedCSS();
                                    entry.data = null;
                                    entry.hostId = ii.getHostId();
                                    entry.imported = new ArrayList<ImportedAsset>();
                                    entry.live = live;
                                    entry.modDate = impInfo.getVersionTs();
                                    entry.uri = importUri;
                                    CacheLocator.getCSSCache().add(entry);
                                }
                            }
                        }
View Full Code Here

TOP

Related Classes of com.dotmarketing.portlets.contentlet.model.ContentletVersionInfo

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.