Package org.infoglue.cms.entities.content

Examples of org.infoglue.cms.entities.content.DigitalAsset


        beginTransaction(db);

        try
        {
      DigitalAsset digitalAsset = getSmallDigitalAssetWithId(digitalAssetId, db);
      if(digitalAsset != null)
      {
        String folderName = "" + (digitalAsset.getDigitalAssetId().intValue() / 1000);
        if(logger.isInfoEnabled())
        {
          logger.info("folderName:" + folderName);
          logger.info("Found a digital asset:" + digitalAsset.getAssetFileName());
        }
        String contentType = digitalAsset.getAssetContentType();
        String assetFilePath = digitalAsset.getAssetFilePath();
        if(assetFilePath.indexOf("IG_ARCHIVE:") > -1)
        {
          assetUrl = CmsPropertyHandler.getWebServerAddress() + "/" + CmsPropertyHandler.getImagesBaseUrl() + "/archivedAsset.gif";
        }
        else if(contentType.equalsIgnoreCase("image/gif") || contentType.equalsIgnoreCase("image/jpg") || contentType.equalsIgnoreCase("image/pjpeg") || contentType.equalsIgnoreCase("image/jpeg") || contentType.equalsIgnoreCase("image/png"))
        {
          String fileName = digitalAsset.getDigitalAssetId() + "_" + digitalAsset.getAssetFileName();
          logger.info("fileName:" + fileName);
          String filePath = CmsPropertyHandler.getDigitalAssetPath() + File.separator + folderName;
          logger.info("filePath:" + filePath);
          logger.info("Making thumb from:" + filePath + File.separator + fileName);
          String thumbnailFileName = digitalAsset.getDigitalAssetId() + "_thumbnail_" + digitalAsset.getAssetFileName();
          //String thumbnailFileName = "thumbnail_" + fileName;
          File thumbnailFile = new File(filePath + File.separator + thumbnailFileName);
          File originalFile = new File(filePath + File.separator + fileName);
          if(!originalFile.exists())
          {
            logger.warn("No file there - let's try getting it again.");
            String originalUrl = DigitalAssetController.getController().getDigitalAssetUrl(digitalAsset.getValueObject(), db);
            logger.warn("originalUrl:" + originalUrl);
            originalFile = new File(filePath + File.separator + fileName);
          }
         
          if(!originalFile.exists())
          {
            logger.warn("The original file " + filePath + File.separator + fileName + " was not found - missing from system.");
            assetUrl = "images" + File.separator + BROKENFILENAME;
          }
          else
          {
            if(!thumbnailFile.exists() && originalFile.exists())
            {
              logger.info("transforming...");
              //ThumbnailGenerator tg = new ThumbnailGenerator();
              ThumbnailGenerator tg = ThumbnailGenerator.getInstance();
              tg.transform(filePath + File.separator + fileName, filePath + File.separator + thumbnailFileName, 75, 75, 100);
              logger.info("transform done...");
            }
           
            assetUrl = CmsPropertyHandler.getWebServerAddress() + "/" + CmsPropertyHandler.getDigitalAssetBaseUrl() + "/" + folderName + "/" + thumbnailFileName;
            logger.info("assetUrl:" + assetUrl);
          }
        }
        else
        {
          String fileName = digitalAsset.getDigitalAssetId() + "_" + digitalAsset.getAssetFileName();
          String filePath = CmsPropertyHandler.getDigitalAssetPath() + File.separator + folderName;
          File originalFile = new File(filePath + File.separator + fileName);
          if(!originalFile.exists())
          {
            assetUrl = CmsPropertyHandler.getWebServerAddress() + "/" + CmsPropertyHandler.getImagesBaseUrl() + "/" + BROKENFILENAME;
View Full Code Here


        try
        {
      ContentVersionVO contentVersion = ContentVersionController.getContentVersionController().getLatestContentVersionVO(contentId, languageId, db);
      if(contentVersion != null)
      {
        DigitalAsset digitalAsset = getSmallDigitalAssetWithId(contentVersion.getId(), db);

        if(digitalAsset != null)
        {
          logger.info("Found a digital asset:" + digitalAsset.getAssetFileName());
          String contentType = digitalAsset.getAssetContentType();
         
          String folderName = "" + (digitalAsset.getDigitalAssetId().intValue() / 1000);
          logger.info("folderName:" + folderName);
          if(contentType.equalsIgnoreCase("image/gif") || contentType.equalsIgnoreCase("image/jpg") || contentType.equalsIgnoreCase("image/png"))
          {
            String fileName = digitalAsset.getDigitalAssetId() + "_" + digitalAsset.getAssetFileName();
            //String filePath = digitalAsset.getAssetFilePath();
            String filePath = CmsPropertyHandler.getDigitalAssetPath() + File.separator + folderName;
            String thumbnailFileName = digitalAsset.getDigitalAssetId() + "_thumbnail_" + digitalAsset.getAssetFileName();
            //String thumbnailFileName = "thumbnail_" + fileName;
            File thumbnailFile = new File(filePath + File.separator + thumbnailFileName);
            if(!thumbnailFile.exists())
            {
              //ThumbnailGenerator tg = new ThumbnailGenerator();
              ThumbnailGenerator tg = ThumbnailGenerator.getInstance();
              tg.transform(filePath + File.separator + fileName, filePath + File.separator + thumbnailFileName, 150, 150, 100);
            }
            assetUrl = CmsPropertyHandler.getWebServerAddress() + "/" + CmsPropertyHandler.getDigitalAssetBaseUrl() + "/" + folderName + "/" + thumbnailFileName;
          }
          else
          {
            String fileName = digitalAsset.getDigitalAssetId() + "_" + digitalAsset.getAssetFileName();
            String filePath = CmsPropertyHandler.getDigitalAssetPath() + File.separator + folderName;
            File originalFile = new File(filePath + File.separator + fileName);
            if(!originalFile.exists())
            {
              assetUrl = "images" + File.separator + BROKENFILENAME;
View Full Code Here

        beginTransaction(db);

        try
        {
      DigitalAsset mediumDigitalAsset = getMediumDigitalAssetWithIdReadOnly(digitalAssetId, db);

      if(mediumDigitalAsset.getContentVersions() != null && mediumDigitalAsset.getContentVersions().size() > 0)
      {
        ContentVersion cv = (ContentVersion)mediumDigitalAsset.getContentVersions().iterator().next();
        if(cv != null)
          contentId = cv.getValueObject().getContentId();
      }
        
      rollbackTransaction(db);
View Full Code Here

  public Integer getContentId(Integer digitalAssetId, Database db) throws Exception
  {
      Integer contentId = null;

      DigitalAsset mediumDigitalAsset = getMediumDigitalAssetWithIdReadOnly(digitalAssetId, db);
    if(mediumDigitalAsset.getContentVersions() != null && mediumDigitalAsset.getContentVersions().size() > 0)
    {
      ContentVersion cv = (ContentVersion)mediumDigitalAsset.getContentVersions().iterator().next();
      if(cv != null)
        contentId = cv.getValueObject().getContentId();
    }
   
    return contentId;
View Full Code Here

  private static DigitalAsset getLatestDigitalAsset(ContentVersion contentVersion)
  {
    Collection digitalAssets = contentVersion.getDigitalAssets();
    Iterator iterator = digitalAssets.iterator();
   
    DigitalAsset digitalAsset = null;
    while(iterator.hasNext())
    {
      DigitalAsset currentDigitalAsset = (DigitalAsset)iterator.next()
      if(digitalAsset == null || currentDigitalAsset.getDigitalAssetId().intValue() > digitalAsset.getDigitalAssetId().intValue())
        digitalAsset = currentDigitalAsset;
    }
    return digitalAsset;
  }
View Full Code Here

  private static DigitalAsset getLatestDigitalAsset(ContentVersion contentVersion, String assetKey)
  {
    Collection digitalAssets = contentVersion.getDigitalAssets();
    Iterator iterator = digitalAssets.iterator();
   
    DigitalAsset digitalAsset = null;
    while(iterator.hasNext())
    {
      DigitalAsset currentDigitalAsset = (DigitalAsset)iterator.next()
      if((digitalAsset == null || currentDigitalAsset.getDigitalAssetId().intValue() > digitalAsset.getDigitalAssetId().intValue()) && currentDigitalAsset.getAssetKey().equalsIgnoreCase(assetKey))
        digitalAsset = currentDigitalAsset;
    }
    return digitalAsset;
  }
View Full Code Here

      long timer = System.currentTimeMillis();
 
      File outputFileDir = new File(filePath);
      outputFileDir.mkdirs();
     
      DigitalAsset digitalAsset = getDigitalAssetWithId(digitalAssetVO.getDigitalAssetId(), db);
     
      InputStream is = digitalAsset.getAssetBlob();
      if((CmsPropertyHandler.getEnableDiskAssets().equals("false") || !tmpOutputFile.exists()) && is != null)
      {
        synchronized (is)
        {
          FileOutputStream fis = new FileOutputStream(tmpOutputFile);
          BufferedOutputStream bos = new BufferedOutputStream(fis);
         
          BufferedInputStream bis = new BufferedInputStream(is);
     
          int character;
          while ((character = bis.read()) != -1)
          {
            bos.write(character);
          }
          bos.flush();
         
          bis.close();
          fis.close();
          bos.close();
 
          logger.info("\n\nExists" + tmpOutputFile.getAbsolutePath() + "=" + tmpOutputFile.exists() + " OR " + outputFile.exists() + ":" + outputFile.length());
          if(tmpOutputFile.length() == 0 || tmpOutputFile.length() != digitalAsset.getAssetFileSize() || (!forceDump && outputFile.exists()) )
          {
            logger.info("outputFile:" + outputFile.getAbsolutePath())
            logger.info("written file:" + tmpOutputFile.length() + " - removing temp and not renaming it...")
            tmpOutputFile.delete();
          }
          else
          {
            if(tmpOutputFile.length() == digitalAsset.getAssetFileSize())
            {
              logger.info("written file:" + tmpOutputFile.getAbsolutePath() + " - renaming it to " + outputFile.getAbsolutePath());
              if (forceDump)
              {
                outputFile.delete();
              }
              tmpOutputFile.renameTo(outputFile);
              logger.info("Renamed to" + outputFile.getAbsolutePath() + "=" + outputFile.exists());
            }
            else
            {
              tmpOutputFile.delete();
            }
          }
        }
      }
      else
      {
        if(logger.isInfoEnabled())
        {
          logger.info("Dumping from file - diskassets is on probably.");
          logger.info("Inside the cms-app I think - we should take the file from disk");
          logger.info("tmpOutputFile:" + tmpOutputFile.getAbsolutePath() + ":" + tmpOutputFile.exists());
          logger.info("outputFile:" + outputFile.getAbsolutePath() + ":" + outputFile.exists());
        }
       
        if(tmpOutputFile.exists())
        {
          logger.info("\n\nExists" + tmpOutputFile.getAbsolutePath() + "=" + tmpOutputFile.exists() + " OR " + outputFile.exists() + ":" + outputFile.length());
          if(tmpOutputFile.length() == 0 || tmpOutputFile.length() == digitalAsset.getAssetFileSize() || outputFile.exists())
          {
            logger.info("outputFile:" + outputFile.getAbsolutePath())
            logger.info("written file:" + tmpOutputFile.length() + " - removing temp and not renaming it...")
            tmpOutputFile.delete();
          }
View Full Code Here

          Map names = new HashMap();
         
          for(int i = 0; i < digitalAssetIdStrings.length; i++)
          {
            Integer digitalAssetId = new Integer(digitalAssetIdStrings[i]);
            DigitalAsset digitalAsset = getDigitalAssetWithId(digitalAssetId, db);
           
        String folderName = "" + (digitalAsset.getDigitalAssetId().intValue() / 1000);
        logger.info("folderName:" + folderName);

        String fileName = digitalAsset.getDigitalAssetId() + "_" + digitalAsset.getAssetFileName();
        if(!outputFile.exists() || outputFile.length() == digitalAsset.getAssetFileSize().intValue())
        {
          dumpDigitalAsset(digitalAsset.getValueObject(), fileName, filePath + File.separator + folderName, db);
        }

        filenames[i] =   "" + filePath + File.separator + folderName + File.separator + fileName; 
        names.put(filenames[i], fileName);
       
        digitalAsset.setAssetFilePath("IG_ARCHIVE:" + archiveFileName + ":" + fileName);
        digitalAsset.setAssetFileSize(new Integer(-1));
       
            if(nullBlob)
              digitalAsset.setAssetBlob(null);
            else
              digitalAsset.setAssetBlob(new ByteArrayInputStream("archived".getBytes()));
           
        assetIdList.add(digitalAsset.getId());
          }
         
            // Create a buffer for reading the files
            byte[] buf = new byte[1024];
           
View Full Code Here

                 File assetFile = new File(tempAssetsPath + File.separator + zipEntryName);
             
              FileInputStream is = new FileInputStream(assetFile);
              String assetId = zipEntryName.substring(0, zipEntryName.indexOf("_"));
             
              DigitalAsset digitalAsset = getDigitalAssetWithId(new Integer(assetId), db);
             
              digitalAsset.setAssetFilePath(zipEntryName);
            digitalAsset.setAssetFileSize(new Integer((int)assetFile.length()));
            digitalAsset.setAssetBlob(is);

                  commitTransaction(db);
                 
                is.close();
                }
View Full Code Here

    if(CmsPropertyHandler.getAssetFileNameForm().equals("contentId_languageId_assetKey"))
    {
      if(contentId == null || languageId == null)
      {
        DigitalAsset asset = DigitalAssetController.getMediumDigitalAssetWithIdReadOnly(digitalAssetVO.getId(), db);
        if(asset.getContentVersions() != null && asset.getContentVersions().size() > 0)
        {
          ContentVersion cv = (ContentVersion)asset.getContentVersions().iterator().next();
          contentId = cv.getValueObject().getContentId();
          languageId = cv.getValueObject().getLanguageId();
        }
      }
      folderName = "" + (contentId / 1000);
View Full Code Here

TOP

Related Classes of org.infoglue.cms.entities.content.DigitalAsset

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.