Examples of CachedRepositoryImpl


Examples of org.apache.ace.repository.ext.impl.CachedRepositoryImpl

            String fileRoot = FILE_ROOT + File.separator + location.getAuthority().replace(':', '-') + location.getPath().replace('/', '\\') + File.separator + customer + File.separator + name + File.separator;
            File local = getFile(fileRoot + "local");
            File backup = getFile(fileRoot + "backup");
            m_properties = getFile(fileRoot + "properties");

            m_repo = new CachedRepositoryImpl(null, location, customer, name, local, backup, loadVersion(m_properties));
        }
    }
View Full Code Here

Examples of org.apache.ace.repository.ext.impl.CachedRepositoryImpl

     */
    private CachedRepository getCachedRepositoryFromPreferences(User user, Repository repository) throws IOException {
        long mostRecentVersion = m_repositoryPrefs.getLong("version", CachedRepositoryImpl.UNCOMMITTED_VERSION);
        File current = getFileFromPreferences(PREFS_LOCAL_FILE_CURRENT);
        File backup = getFileFromPreferences(PREFS_LOCAL_FILE_BACKUP);
        return new CachedRepositoryImpl(user, repository, new FilebasedBackupRepository(current, backup), mostRecentVersion);
    }
View Full Code Here

Examples of org.apache.ace.repository.ext.impl.CachedRepositoryImpl

     * Creates the cached repository when given a remote repository.
     *
     * @param remoteRepo the remote repository to add, cannot be <code>null</code>.
     */
    final void addRepo(Repository remoteRepo) {
        m_repo = new CachedRepositoryImpl(remoteRepo, m_backup, loadVersion(m_properties));
    }
View Full Code Here

Examples of org.apache.ace.repository.ext.impl.CachedRepositoryImpl

     * Helper method for login.
     * @throws IOException
     */
    private CachedRepository getCachedRepositoryFromPreferences(Repository repository, Preferences repositoryPrefs) throws IOException {
        long mostRecentVersion = repositoryPrefs.getLong("version", CachedRepositoryImpl.UNCOMMITTED_VERSION);
        return new CachedRepositoryImpl(repository, getBackupFromPreferences(repositoryPrefs), mostRecentVersion);
    }
View Full Code Here

Examples of org.apache.ace.repository.ext.impl.CachedRepositoryImpl

                        .setService(ConnectionFactory.class)
                        .setRequired(true)));

                m_cachedRepository = null;
                if (backup != null) {
                    m_cachedRepository = new CachedRepositoryImpl(m_directRepository, backup, CachedRepositoryImpl.UNCOMMITTED_VERSION);
                }
            }
            catch (IllegalArgumentException e) {
                throw new ConfigurationException("Authentication", e.getMessage());
            }
View Full Code Here

Examples of org.apache.ace.repository.ext.impl.CachedRepositoryImpl

        Repository m_repository = new MockRepository();
        byte[] testContent = new byte[] {'i', 'n', 'i', 't', 'i', 'a', 'l'};
        m_repository.commit(new ByteArrayInputStream(testContent), 0);
        BackupRepository m_backupRepository = new MockBackupRepository();

        CachedRepository m_cachedRepository = new CachedRepositoryImpl(m_repository, m_backupRepository, 0);

        InputStream input = m_cachedRepository.checkout(1);
        byte[] inputBytes = AdminTestUtil.copy(input);
        assert AdminTestUtil.byteArraysEqual(inputBytes, testContent) : "We got something different than 'initial' from checkout: " + new String(inputBytes);
        input = m_cachedRepository.getLocal(false);
        inputBytes = AdminTestUtil.copy(input);
        assert AdminTestUtil.byteArraysEqual(inputBytes, testContent) : "We got something different than 'initial' from getLocal: " + new String(inputBytes);
        input = m_backupRepository.read();
        inputBytes = AdminTestUtil.copy(input);
        assert AdminTestUtil.byteArraysEqual(inputBytes, testContent) : "We got something different than 'initial' from the backup repository: " + new String(inputBytes);
View Full Code Here

Examples of org.apache.ace.repository.ext.impl.CachedRepositoryImpl

    @Test( groups = { TestUtils.UNIT } )
    public void testCommit() throws IllegalArgumentException, IOException {
        Repository m_repository = new MockRepository();
        BackupRepository m_backupRepository = new MockBackupRepository();

        CachedRepository m_cachedRepository = new CachedRepositoryImpl(m_repository, m_backupRepository, 0);
        byte[] testContent = new byte[] {'i', 'n', 'i', 't', 'i', 'a', 'l'};

        InputStream input = new ByteArrayInputStream(testContent);
        m_cachedRepository.commit(input, 0);

        m_cachedRepository = new CachedRepositoryImpl(m_repository, m_backupRepository, 0);
        input = m_cachedRepository.checkout(1);
        byte[] inputBytes = AdminTestUtil.copy(input);
        assert AdminTestUtil.byteArraysEqual(inputBytes, testContent) : "We got something different than 'initial' from checkout: " + new String(inputBytes);

        byte[] newTestContent = new byte[] {'n', 'e', 'w'};

        m_cachedRepository.writeLocal(new ByteArrayInputStream(newTestContent));

        m_cachedRepository.commit();

        m_cachedRepository = new CachedRepositoryImpl(m_repository, m_backupRepository, 0);
        input = m_cachedRepository.checkout(2);
        inputBytes = AdminTestUtil.copy(input);
        assert AdminTestUtil.byteArraysEqual(inputBytes, newTestContent) : "We got something different than 'new' from checkout: " + new String(inputBytes);
    }
View Full Code Here

Examples of org.apache.ace.repository.ext.impl.CachedRepositoryImpl

    @Test( groups = { TestUtils.UNIT } )
    public void testRevert() throws IllegalArgumentException, IOException {
        Repository m_repository = new MockRepository();
        BackupRepository m_backupRepository = new MockBackupRepository();

        CachedRepository m_cachedRepository = new CachedRepositoryImpl(m_repository, m_backupRepository, 0);
        byte[] testContent = new byte[] {'i', 'n', 'i', 't', 'i', 'a', 'l'};

        InputStream input = new ByteArrayInputStream(testContent);
        m_cachedRepository.commit(input, 0);

        m_cachedRepository = new CachedRepositoryImpl(m_repository, m_backupRepository, 0);
        input = m_cachedRepository.checkout(1);

        byte[] newTestContent = new byte[] {'n', 'e', 'w'};

        m_cachedRepository.writeLocal(new ByteArrayInputStream(newTestContent));
        input = m_cachedRepository.getLocal(false);
        byte[] inputBytes = AdminTestUtil.copy(input);
        assert AdminTestUtil.byteArraysEqual(inputBytes, newTestContent) : "We got something different than 'new' from getLocal: " + new String(inputBytes);

        m_cachedRepository.revert();
        input = m_cachedRepository.getLocal(false);
        inputBytes = AdminTestUtil.copy(input);
        assert AdminTestUtil.byteArraysEqual(inputBytes, testContent) : "We got something different than 'initial' from getLocal: " + new String(inputBytes);
    }
View Full Code Here

Examples of org.apache.ace.repository.ext.impl.CachedRepositoryImpl

     *
     * @param remoteRepo
     *            the remote repository to add, cannot be <code>null</code>.
     */
    final void addRepo(Repository remoteRepo) {
        m_repo = new CachedRepositoryImpl(remoteRepo, m_backup, loadVersion(m_properties));
    }
View Full Code Here

Examples of org.apache.ace.repository.ext.impl.CachedRepositoryImpl

     *
     * @throws IOException
     */
    private CachedRepository getCachedRepositoryFromPreferences(Repository repository, Preferences repositoryPrefs) throws IOException {
        long mostRecentVersion = repositoryPrefs.getLong("version", CachedRepositoryImpl.UNCOMMITTED_VERSION);
        return new CachedRepositoryImpl(repository, getBackupFromPreferences(repositoryPrefs), mostRecentVersion);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.