コード例 #1
0
    def testGetConnectionPool(self):
        """getting a connection"""

        self._factory = factory.FileSystem(
            BaseConfiguration("http://s3.amazonaws.de/bucketname/keyname"))
        connectionPool = self._factory._getConnectionPool()
        self.assertTrue(isinstance(connectionPool, S3ConnectionPool))
コード例 #2
0
ファイル: persisters.py プロジェクト: rainman110/DataFinder
    def _ensureReadableSystem(self):
        """
        Make sure, self._archiveFileSystem contains a valid readable file system. If
        none is present, the corresponding ZIP file will be downloaded.
        """

        if self._fileSystem is None:
            key = self._rootItem.path + str(self._index)
            if key in _temporaryFileMap:
                self._fileSystem = _temporaryFileMap[key][1]
            else:
                fd, path = mkstemp()
                fileHandle = os.fdopen(fd, "w+b")
                inStream = self._rootItem.dataPersister.retrieveData(
                    self._index)
                try:
                    block = inStream.read(_BLOCK_SIZE)
                    while len(block) > 0:
                        fileHandle.write(block)
                        block = inStream.read(_BLOCK_SIZE)
                        while len(block) > 0:
                            fileHandle.write(block)
                            block = inStream.read(_BLOCK_SIZE)
                    fileHandle.close()
                except (OSError, IOError), error:
                    reason = os.strerror(error.errno or 0)
                    raise ItemError("Cannot retrieve archive.\nReason: '%s'" %
                                    reason)
                else:
                    config = BaseConfiguration('arch:' + path)
                    _log.debug("Downloaded %s to %s." %
                               (self._rootItem.path, path))
                    self._fileSystem = FileSystem(config)
                    _temporaryFileMap[key] = (path, self._fileSystem)
コード例 #3
0
    def setUp(self):
        """ Mocks an utility functionality. """

        factory.FileSystem._getConnectionPool = SimpleMock(
            SimpleMock(SimpleMock()))
        self._factory = factory.FileSystem(
            BaseConfiguration("http://s3.amazonaws.de/bucketname/keyname"))
コード例 #4
0
ファイル: factory_test.py プロジェクト: rainman110/DataFinder
    def setUp(self):
        """ Mocks an utility functionality. """

        self._collectionStorerMock = _CollectionStorerMock()
        factory.createCollectionStorer = self._createCollectionStorerMock
        factory.FileSystem._getConnectionPool = SimpleMock(SimpleMock())
        self._factory = factory.FileSystem(
            BaseConfiguration("http://test.de/mypath/"))
コード例 #5
0
ファイル: adapter_test.py プロジェクト: rainman110/DataFinder
    def setUp(self):
        """ Enables mock connection. """

        adapter._Ldap = _LdapConnectionMock
        self._configuration = Configuration(BaseConfiguration())
        self._configuration.domain = _TEST_DOMAIN
        self._ldapPrincipalSearcher = adapter.LdapPrincipalSearchAdapter(
            self._configuration)
コード例 #6
0
ファイル: factory_test.py プロジェクト: rainman110/DataFinder
 def setUp(self):
     self._connectionMock = SimpleMock()
     self._createSvnConnectionMock = SimpleMock(self._connectionMock)
     connection_pool.util.createSubversionConnection = self._createSvnConnectionMock
     factory.FileSystem._connectionManager = ConnectionPoolManager(
         10)  # Ensure it is empty
     self._factory = factory.FileSystem(
         BaseConfiguration("http://svn.test.de/svn"))
     self.assertTrue(self._factory.hasCustomMetadataSupport)
コード例 #7
0
ファイル: factory_test.py プロジェクト: rainman110/DataFinder
 def testBasicProcedures(self):
     tsmFileSystem = factory.FileSystem(BaseConfiguration("tsm://host.de/basePath"))
     self.assertTrue(isinstance(tsmFileSystem.createDataStorer("/logical/Identifier"), DataTsmAdapter))
     tsmFileSystem.release()
     
     credentials = {"username": "******", "password": "******"}
     tsmFileSystem.updateCredentials(credentials)
     self.assertEquals(tsmFileSystem._configuration.username, "me")
     self.assertEquals(tsmFileSystem._configuration.password, "secret")
コード例 #8
0
    def __init__(self,
                 repositoryUri,
                 user,
                 password,
                 dryRun,
                 deleteOld,
                 removeLinkPrefix=None):
        self._conversionMap = {
            "DataFinderType": u"____datatype____",
            "DataFinderDataStore": u"____datastorename____",
            "DataFinderModificationDate":
            u"____contentmodificationdatetime____",
            "DataFinderCreationDate": u"____contentcreationdatetime____",
            "DataFinderLength": u"____content.size____",
            "DataFinderArchiveIdentifier": u"____contentidentifier____",
            "DataFinderArchiveRetentionExeededDate":
            u"____archiveretentionexceededdatetime____",
            "DataFinderArchiveRootCollection":
            u"____archiverootcollection____",
        }
        self._datetypes = [
            "DataFinderModificationDate", "DataFinderCreationDate",
            "DataFinderArchiveRetentionExeededDate"
        ]
        self._oldPropertyIds = self._conversionMap.keys()[:] + [
            LINK_PROPERTY_OLD
        ]

        self._dataFormatRegistry = registry.DataFormatRegistry()
        self._dataFormatRegistry.load()
        self._dryRun = dryRun
        self._deleteOld = deleteOld
        self._removeLinkPrefix = removeLinkPrefix

        # Little trick to correctly set the link target WebDAV property
        identifier_mapping._logicalToPersistenceIdMapping["linkTarget"] = (
            "http://dlr.de/system/", "linkTarget")

        fs = factory.createFileStorer(
            repositoryUri,
            BaseConfiguration(repositoryUri, username=user, password=password))
        self._walk([fs])
コード例 #9
0
def createFileStorer(itemUri, additionalParameters=BaseConfiguration()):
    """ 
    Creates a file storer object for the given URI. 

    @param itemUri:This is the URI of file storer item. 
    @type itemUri: C{unicode}
    @param additionalParameters: Defines additional parameters, e.g. credentials.
    @type additionalParameters: L{BaseConfiguration<datafinder.persistence.common.configuration.BaseConfiguration>}

    @raise PersistenceError: Indicates an unsupported interface or wrong configuration.
   
    @note: When setting C{itemUri} to C{None} a null pattern conform file storer 
           implementation is returned. 
    """
    # pylint: disable=E1103
    # E1103: urlsplit produces the required results but pylint
    # cannot correctly determine it.

    if itemUri is None:
        return FileSystem(None).createFileStorer("/")
    else:
        parsedUri = urlsplit(itemUri, allow_fragments=False)
        baseUri = parsedUri.scheme + "://" + parsedUri.netloc + "/"
        if additionalParameters.baseUri is None:
            additionalParameters.baseUri = baseUri

        if parsedUri.path.startswith(additionalParameters.uriPath):
            fileStorerPath = parsedUri.path[len(additionalParameters.uriPath):]
            if not fileStorerPath.startswith("/"):
                fileStorerPath = "/" + fileStorerPath
        else:
            errorMessage = "The item URI '%s' and the file system base URI '%s' do not match." \
                           % (parsedUri.path, additionalParameters.uriPath)
            raise PersistenceError(errorMessage)
        return FileSystem(additionalParameters).createFileStorer(
            fileStorerPath)
コード例 #10
0
 def testWithoutLuceneScheme(self):
     baseConfig = BaseConfiguration("https://server.com/path/index.idx")
     config = Configuration(baseConfig, None)
     
     self.assertEquals(config.luceneIndexUri, "https://server.com/path/index.idx")
コード例 #11
0
 def testNone(self):
     baseConfig = BaseConfiguration(None)
     self.assertRaises(PersistenceError, Configuration, baseConfig, None)
コード例 #12
0
 def testEmptyLuceneFileUri(self):
     baseConfig = BaseConfiguration("")
     self.assertRaises(PersistenceError, Configuration, baseConfig, None)
コード例 #13
0
 def testLuceneFileUri(self):
     baseConfig = BaseConfiguration("lucene+file:///path/index.idx")
     config = Configuration(baseConfig, None)
     
     self.assertEquals(config.luceneIndexUri, "file:///path/index.idx")
コード例 #14
0
 def testLuceneHttpUri(self):
     baseConfig = BaseConfiguration("lucene+http://server.com/path/index.idx")
     config = Configuration(baseConfig, None)
     
     self.assertEquals(config.luceneIndexUri, "http://server.com/path/index.idx")
コード例 #15
0
 def setUp(self):
     self._baseConfig = BaseConfiguration("http://test.dlr.de/myPath",
                                          user="******", password="******")