Example #1
0
    def put(self):
        self._LOGGER.info('PUT bucket request')

        res = None
        headers = {}
        myDict = {}
        xml = self.getBody()
        if xml:
            myDict = XmlToDict(self.getBody()).getDict()

        #Get HEADER NAME FROM CONSTANT
        if not self.s3Request.SUBRESOURCE:
            headers = self._putBucket(myDict)
        else:
            if self.s3Request.SUBRESOURCE.get('acl', None):
                res = self._putBucketAcl(myDict)
            elif self.s3Request.SUBRESOURCE.get('logging', None):
                res = self._putBucketLogging(myDict)
            elif self.s3Request.SUBRESOURCE.get('versioning', None):
                res = self._putBucketVersioning(myDict)
            elif self.s3Request.SUBRESOURCE.get('website', None):
                res = self._putBucketWebsite(myDict)
            else:
                self._notImplemented()

        self._LOGGER.debug('Headers : %s' % headers)
        self.s3Render(res, self.s3Request.ID_REQUEST, headers)
Example #2
0
    def _putObjectAcl(self):

        self._LOGGER.info("putting the object acl")

        myDict = XmlToDict(self.getBody()).getDict()

        myList = myDict['AccessControlPolicy']['AccessControlList']['Grant']

        grantList = []
        if not type(myList) is types.DictType:
            for grantDict in myList:
                if not grantDict['Grantee'].has_key('ID'):
                    self._LOGGER.warning(
                        'Putting different ACL from the usal CanonicalID, currently not implemented'
                    )
                    raise RestFSError(errCode.err['NotImplemented']['code'],\
                      errCode.err['NotImplemented']['message'],\
                      errCode.err['NotImplemented']['http'])
                grant = Grant()
                grant.uid = grantDict['Grantee']['ID']
                grant.permission = ACPHelper.s3AclToPerm(
                    grantDict['Permission'])
                grantList.append(grant)
        else:
            grant = Grant()
            grant.uid = myList['Grantee']['ID']
            grant.permission = ACPHelper.s3AclToPerm(myList['Permission'])
            grantList.append(grant)

        self.application.objectSrv.putObjectACL(self.s3Request.BUCKET,
                                                self.s3Request.OBJECT,
                                                self.s3Request.ID_REQUEST,
                                                self.getUser(), grantList)

        return None
Example #3
0
    def getObjectACP(self,bucket_name,object_name):
        object_path = self._getObjectPath(bucket_name,object_name)
        path = os.path.join(object_path,"acp.xml")
        if not os.path.exists(path):
            return None
        data = self._readFile(path)

        myDict = XmlToDict(data).getDict()
      
        list = myDict['ACP']['Grant']
        
        grantList = []
        
        if not type(list) is types.DictType:
            for grantDict in list:
                grant = Grant()
                grant.setByDict(grantDict)
                grantList.append(grant)
        else:
                grant = Grant()
                grant.setByDict(list) 
                grantList.append(grant)
        
        acp = ACP()
        acp.setByGrants(grantList)
        return acp
Example #4
0
 def getBucketLogging(self,bucket_name):
     
     bucket_path = self._getBucketPath(bucket_name)
     path = os.path.join(bucket_path,"logging.xml")
     if not os.path.exists(path):
         return None
     data = self._readFile(path)
     myDict = XmlToDict(data).getDict()
   
     list = myDict['Logging']['Grant']
     
     grantList = []
     
     if not type(list) is types.DictType:
         for grantDict in list:
             grant = Grant()
             grant.setByDict(grantDict)
             grantList.append(grant)
     else:
             grant = Grant()
             grant.setByDict(list) 
             grantList.append(grant)
     
     log = BucketLogging()
     log.setByGrants(grantList)
     return log
Example #5
0
 def getBucketWebsite(self,name):
     bucket_path = self._getBucketPath(name)
     path = os.path.join(bucket_path,"website.xml")
     if not os.path.exists(path):
         return None
     data = self._readFile(path)
      
     myDict = XmlToDict(data).getDict()
     web = BucketWebsite()
     web.setByDict(myDict['WebsiteConfiguration'])
     return web  
Example #6
0
 def getBucketVersioning(self,name):
     bucket_path = self._getBucketPath(name)
     path = os.path.join(bucket_path,"versioning.xml")
     if not os.path.exists(path):
         return None
     data = self._readFile(path)
     myDict = XmlToDict(data).getDict()
     
     ver = BucketVersioning()
     ver.setByDict(myDict['VersioningConfiguration'])
     return ver  
Example #7
0
    def getBucketProperties(self,name):

        bucket_path = self._getBucketPath(name)
        path = os.path.join(bucket_path,"global.xml")
        
        if not os.path.exists(path):
            return None
        data = self._readFile(path) 
        myDict = XmlToDict(data).getDict()
        prop = BucketProperties()
        prop.setByDict(myDict['Global'])
        return prop
Example #8
0
 def getObjectProperties(self,bucket_name,object_name):
     object_path = self._getObjectPath(bucket_name,object_name)
     path = os.path.join(object_path,"object.xml")
     
     if not os.path.exists(path):
         return None
     
     data = self._readFile(path) 
     myDict = XmlToDict(data).getDict()
     prop = ObjectProperties()
     prop.setByDict(myDict['Global'])
     return prop
Example #9
0
 def getBucketLocation(self,name):
     bucket_path = self._getBucketPath(name)
     path = os.path.join(bucket_path,"location.xml")
     
     if not os.path.exists(bucket_path):
         return None
     
     data = self._readFile(path) 
     myDict = XmlToDict(data).getDict()
     loc = BucketLocation()
     loc.set(myDict['Location'])
     return loc