Package com.cloud.bridge.persist.dao

Examples of com.cloud.bridge.persist.dao.SMetaDao


    }


    // [D] Return the contents of the object inline 
    // -> extract the meta data that corresponds the specific versioned item
    SMetaDao metaDao = new SMetaDao();
    List<SMeta> itemMetaData = metaDao.getByTarget( "SObjectItem", item.getId());
    if (null != itemMetaData)
    {
      int i = 0;
      S3MetaDataEntry[] metaEntries = new S3MetaDataEntry[ itemMetaData.size() ];
        ListIterator it = itemMetaData.listIterator();
View Full Code Here


    return response;
    }
   

  private void deleteMetaData( long itemId ) {
      SMetaDao metaDao = new SMetaDao();
      List<SMeta> itemMetaData = metaDao.getByTarget( "SObjectItem", itemId );
      if (null != itemMetaData)
      {
          ListIterator it = itemMetaData.listIterator();
        while( it.hasNext()) {
           SMeta oneTag = (SMeta)it.next();
           metaDao.delete( oneTag );
        }
    }
  }
View Full Code Here

  @SuppressWarnings("deprecation")
  public Tuple<SObject, SObjectItem> allocObjectItem(SBucket bucket, String nameKey, S3MetaDataEntry[] meta, S3AccessControlList acl, String cannedAccessPolicy)
  {
    SObjectDao     objectDao     = new SObjectDao();
    SObjectItemDao objectItemDao = new SObjectItemDao();
    SMetaDao       metaDao       = new SMetaDao();
    SAclDao        aclDao        = new SAclDao();
    SObjectItem    item          = null;
    int            versionSeq    = 1;
    int      versioningStatus    = bucket.getVersioningStatus();
   
    Session session = PersistContext.getSession();
     
    // [A] To write into a bucket the user must have write permission to that bucket
    S3PolicyContext context = new S3PolicyContext( PolicyActions.PutObject, bucket.getName());
    context.setKeyName( nameKey );
    context.setEvalParam( ConditionKeys.Acl, cannedAccessPolicy);
    verifyAccess( context, "SBucket", bucket.getId(), SAcl.PERMISSION_WRITE );

    // [A] If versioning is off them we over write a null object item
    SObject object = objectDao.getByNameKey(bucket, nameKey);
    if ( object != null )
    {
       // -> if versioning is on create new object items
       if ( SBucket.VERSIONING_ENABLED == versioningStatus )
       {
            session.lock(object, LockMode.UPGRADE);
            versionSeq = object.getNextSequence();
            object.setNextSequence(versionSeq + 1);
             session.save(object);
           
            item = new SObjectItem();
            item.setTheObject(object);
            object.getItems().add(item);
            item.setVersion(String.valueOf(versionSeq));
            Date ts = DateHelper.currentGMTTime();
            item.setCreateTime(ts);
            item.setLastAccessTime(ts);
            item.setLastModifiedTime(ts);
            session.save(item);
       }
       else
       {    // -> find an object item with a null version, can be null
          //    if bucket started out with versioning enabled and was then suspended
          item = objectItemDao.getByObjectIdNullVersion( object.getId());
          if (item == null)
          {
              item = new SObjectItem();
              item.setTheObject(object);
              object.getItems().add(item);
              Date ts = DateHelper.currentGMTTime();
              item.setCreateTime(ts);
              item.setLastAccessTime(ts);
              item.setLastModifiedTime(ts);
              session.save(item);     
          }
       }
    }
    else
    {    // -> there is no object nor an object item
       object = new SObject();
       object.setBucket(bucket);
       object.setNameKey(nameKey);
       object.setNextSequence(2);
       object.setCreateTime(DateHelper.currentGMTTime());
       object.setOwnerCanonicalId(UserContext.current().getCanonicalUserId());
       session.save(object);
   
         item = new SObjectItem();
         item.setTheObject(object);
         object.getItems().add(item);
         if (SBucket.VERSIONING_ENABLED  == versioningStatus) item.setVersion(String.valueOf(versionSeq));
         Date ts = DateHelper.currentGMTTime();
         item.setCreateTime(ts);
         item.setLastAccessTime(ts);
         item.setLastModifiedTime(ts);
         session.save(item);
    }
     
   
    // [C] We will use the item DB id as the file name, MD5/contentLength will be stored later
    String suffix = null;
    int dotPos = nameKey.lastIndexOf('.');
    if (dotPos >= 0) suffix = nameKey.substring(dotPos);
    if ( suffix != null )
       item.setStoredPath(String.valueOf(item.getId()) + suffix);
    else item.setStoredPath(String.valueOf(item.getId()));
   
    metaDao.save("SObjectItem", item.getId(), meta);
   
   
    // [D] Are we setting an ACL along with the object
    //  -> the ACL is ALWAYS set on a particular instance of the object (i.e., a version)
    if ( null != cannedAccessPolicy )
View Full Code Here

TOP

Related Classes of com.cloud.bridge.persist.dao.SMetaDao

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.