Package org.infoglue.cms.entities.content

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


      * The asset is send in as an InputStream which castor inserts automatically.
      */

     public DigitalAsset create(Database db, DigitalAssetVO digitalAssetVO, InputStream is) throws SystemException, Exception
     {
    DigitalAsset digitalAsset = new DigitalAssetImpl();
    digitalAsset.setValueObject(digitalAssetVO);
    digitalAsset.setAssetBlob(is);

    db.create(digitalAsset);
       
        return digitalAsset;
     }
View Full Code Here


    logger.info("originalContentVersionId:" + originalContentVersionId);
    logger.info("oldAssetKey:" + oldAssetKey);
    logger.info("newContentVersionId:" + newContentVersionId);
    logger.info("newAssetKey:" + newAssetKey);
   
    DigitalAsset oldDigitalAsset = getDigitalAsset(originalContentVersionId, oldAssetKey, db);
   
    ContentVersion contentVersion = ContentVersionController.getContentVersionController().getContentVersionWithId(newContentVersionId, db);
    Collection contentVersions = new ArrayList();
    contentVersions.add(contentVersion);
    logger.info("Added contentVersion:" + contentVersion.getId());
      
    DigitalAssetVO digitalAssetVO = new DigitalAssetVO();
    digitalAssetVO.setAssetContentType(oldDigitalAsset.getAssetContentType());
    digitalAssetVO.setAssetFileName(oldDigitalAsset.getAssetFileName());
    digitalAssetVO.setAssetFilePath(oldDigitalAsset.getAssetFilePath());
    digitalAssetVO.setAssetFileSize(oldDigitalAsset.getAssetFileSize());
    digitalAssetVO.setAssetKey(newAssetKey);
   
    DigitalAsset digitalAsset = new DigitalAssetImpl();
    digitalAsset.setValueObject(digitalAssetVO);
    digitalAsset.setAssetBlob(oldDigitalAsset.getAssetBlob());
    digitalAsset.setContentVersions(contentVersions);
   
    try
    {
      db.create(digitalAsset);
    }
    catch(Exception e)
    {
      logger.error("An error occurred so we should not complete the transaction:" + e, e);
      throw new SystemException(e.getMessage());
    }
    //contentVersion.getDigitalAssets().add(digitalAsset);
   
    return digitalAsset.getValueObject();
  }
View Full Code Here

          digitalAssetVO.setAssetFileName(oldDigitalAsset.getAssetFileName());
          digitalAssetVO.setAssetFilePath(oldDigitalAsset.getAssetFilePath());
          digitalAssetVO.setAssetFileSize(oldDigitalAsset.getAssetFileSize());
          digitalAssetVO.setAssetKey(oldDigitalAsset.getAssetKey());
         
          DigitalAsset digitalAsset = new MediumDigitalAssetImpl();
          digitalAsset.setValueObject(digitalAssetVO);
 
          if(oldAssetFile.exists())
          {
            InputStream is = new FileInputStream(oldAssetFile);
   
            if(is != null)
            {
              digitalAsset.setAssetBlob(is);
            }
            else
              digitalAsset.setAssetBlob(null);
            //digitalAsset.setAssetBlob(oldDigitalAsset.getAssetBlob());
          }
          else
          {
            logger.warn("No asset file found:" + oldAssetFile.getPath());
            digitalAsset.setAssetBlob(null);
          }
         
          db.create(digitalAsset);
         
          assetIdMap.put(oldDigitalAsset.getId(), digitalAsset.getId());
          digitalAsset.setContentVersions(contentVersions);
        }
        catch(Exception e)
        {
          logger.error("An error occurred when we tried to copy asset:" + e.getMessage());
          logger.warn("An error occurred when we tried to copy asset:" + e.getMessage(), e);
View Full Code Here

   * This method gets a asset with a special key inside the given transaction.
   */
 
  public DigitalAsset getDigitalAsset(Integer contentVersionId, String assetKey, Database db) throws SystemException
  {
    DigitalAsset digitalAsset = null;
   
    ContentVersion contentVersion = ContentVersionController.getContentVersionController().getContentVersionWithId(contentVersionId, db);
    Collection digitalAssets = contentVersion.getDigitalAssets();
    Iterator assetIterator = digitalAssets.iterator();
    while(assetIterator.hasNext())
    {
      DigitalAsset currentDigitalAsset = (DigitalAsset)assetIterator.next();
      if(currentDigitalAsset.getAssetKey().equals(assetKey))
      {
        digitalAsset = currentDigitalAsset;
        break;
      }
    }
View Full Code Here

        beginTransaction(db);

        try
        {          
        DigitalAsset digitalAsset = DigitalAssetController.getDigitalAssetWithId(digitalAssetId, db);     
       
        if(entity.equalsIgnoreCase("ContentVersion"))
                ContentVersionController.getContentVersionController().deleteDigitalAssetRelation(entityId, digitalAsset, db);
            else if(entity.equalsIgnoreCase(UserProperties.class.getName()))
                UserPropertiesController.getController().deleteDigitalAssetRelation(entityId, digitalAsset, db);
            else if(entity.equalsIgnoreCase(RoleProperties.class.getName()))
                RolePropertiesController.getController().deleteDigitalAssetRelation(entityId, digitalAsset, db);
            else if(entity.equalsIgnoreCase(GroupProperties.class.getName()))
                GroupPropertiesController.getController().deleteDigitalAssetRelation(entityId, digitalAsset, db);

            logger.info("digitalAsset size after:" + digitalAsset.getContentVersions().size());
            if(digitalAsset.getContentVersions().size() == 0)
              db.remove(digitalAsset);

            //db.remove(digitalAsset);

            commitTransaction(db);
View Full Code Here

      * This method updates a digital asset in the database.
      */
    
     public static DigitalAssetVO update(DigitalAssetVO digitalAssetVO, InputStream is, Database db) throws ConstraintException, SystemException
    {
    DigitalAsset digitalAsset = null;
   
    if(is == null)
    {
      digitalAsset = getMediumDigitalAssetWithId(digitalAssetVO.getId(), db);
      digitalAsset.setValueObject(digitalAssetVO);
    }
    else
    {
      digitalAsset = getDigitalAssetWithId(digitalAssetVO.getId(), db);
      digitalAsset.setValueObject(digitalAssetVO);
        digitalAsset.setAssetBlob(is);
    }

    return digitalAsset.getValueObject();   
    }
View Full Code Here

    
     public static DigitalAssetVO update(DigitalAssetVO digitalAssetVO, InputStream is) throws ConstraintException, SystemException
    {
    Database db = CastorDatabaseService.getDatabase();
   
    DigitalAsset digitalAsset = null;
   
    beginTransaction(db);

    try
    {
      if(is == null)
      {
        digitalAsset = getMediumDigitalAssetWithId(digitalAssetVO.getId(), db);
        digitalAsset.setValueObject(digitalAssetVO);
      }
      else
      {
        digitalAsset = getDigitalAssetWithId(digitalAssetVO.getId(), db);
        digitalAsset.setValueObject(digitalAssetVO);
          digitalAsset.setAssetBlob(is);
      }
      /*
      digitalAsset = getDigitalAssetWithId(digitalAssetVO.getId(), db);
     
      digitalAsset.setValueObject(digitalAssetVO);
      if(is != null)
          digitalAsset.setAssetBlob(is);
      */
     
      commitTransaction(db);
    }
    catch(Exception e)
    {
      logger.error("An error occurred so we should not complete the transaction:" + e, e);
      rollbackTransaction(db);
      throw new SystemException(e.getMessage());
    }

    return digitalAsset.getValueObject();   
    }
View Full Code Here

  {
    Collection digitalAssets = contentVersion.getDigitalAssets();
    Iterator digitalAssetsIterator = digitalAssets.iterator();
    while(digitalAssetsIterator.hasNext())
    {
      DigitalAsset currentDigitalAsset = (DigitalAsset)digitalAssetsIterator.next();
      logger.info("CurrentDigitalAsset:" + currentDigitalAsset.getId() + " - " + currentDigitalAsset.getAssetKey() + " size:" + currentDigitalAsset.getContentVersions().size());
      if(currentDigitalAsset.getContentVersions().size() > 1)
      {
        logger.info("Size was " + currentDigitalAsset.getContentVersions().size() + " so we just delete the relationship");
        currentDigitalAsset.getContentVersions().remove(contentVersion);
        digitalAssetsIterator.remove();
      }
      else
      {
        logger.info("Size was " + currentDigitalAsset.getContentVersions().size() + " so we delete the asset completely");
        currentDigitalAsset.getContentVersions().remove(contentVersion);
        digitalAssetsIterator.remove();
        db.remove(currentDigitalAsset);
      }
    }
  }
View Full Code Here

        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 fileName = digitalAsset.getDigitalAssetId() + "_" + digitalAsset.getAssetFileName();
        String filePath = CmsPropertyHandler.getDigitalAssetPath() + File.separator + folderName;
        dumpDigitalAsset(digitalAsset.getValueObject(), fileName, filePath, db);
        assetPath = filePath + File.separator + fileName;
      }              

            commitTransaction(db);
        }
View Full Code Here

        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 fileName = digitalAsset.getDigitalAssetId() + "_" + digitalAsset.getAssetFileName();
        String filePath = CmsPropertyHandler.getDigitalAssetPath() + File.separator + "protected" + File.separator + folderName;
        dumpDigitalAsset(digitalAsset.getValueObject(), fileName, filePath, db);
        assetPath = filePath + File.separator + fileName;
      }              

            commitTransaction(db);
        }
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.