/** * Creates a cached repository which uses <code>remote</code>, <code>customer</code> and * <code>name</code> to create a <code>RemoteRepository</code>, and uses the <code>Files</code>s * passed in as a for local storage and backup. * @param user A user object, which is allowed to access <code>remote</code>. * @param remote The location of the remote repository. * @param customer The customer name to be used with the remote repository. * @param name The name to be used with the remote repository. * @param local A local file to be used for storage of changes to the repository. * @param backup A local file to be used as a local backup of what was on the server. * @param mostRecentVersion The version from which <code>backup</code> was checked out or committed. * If no version has been committed yet, use <code>UNCOMMITTED_VERSION</code>. */ public CachedRepositoryImpl(User user, URL remote, String customer, String name, File local, File backup, long mostRecentVersion) { this(user, new RemoteRepository(remote, customer, name), new FilebasedBackupRepository(local, backup), mostRecentVersion); }
/** * Helper method for login. * @throws IOException */ private BackupRepository getBackupFromPreferences(Preferences repositoryPrefs) throws IOException { File current = getFileFromPreferences(repositoryPrefs, PREFS_LOCAL_FILE_CURRENT); File backup = getFileFromPreferences(repositoryPrefs, PREFS_LOCAL_FILE_BACKUP); return new FilebasedBackupRepository(current, backup); }
@SuppressWarnings("unchecked") public void updated(Dictionary settings) throws ConfigurationException { if (settings != null) { String url = getNotNull(settings, URL, "DeploymentRepository URL not configured."); String name = getNotNull(settings, NAME, "RepositoryName not configured."); String customer = getNotNull(settings, CUSTOMER, "RepositoryCustomer not configured."); //create the remote repository and set it. try { BackupRepository backup = null; try { backup = new FilebasedBackupRepository(File.createTempFile("currentrepository", null), File.createTempFile("backuprepository", null)); } catch (Exception e) { m_log.log(LogService.LOG_WARNING, "Unable to create temporary files for FilebasedBackupRepository"); } // We always create the remote repository. If we can create a backup repository, we will wrap a CachedRepository // around it. m_directRepository = new RemoteRepository(new URL(url), customer, name); if (backup == null) { m_cachedRepository = null; } else { m_cachedRepository = new CachedRepositoryImpl(null, m_directRepository, backup, CachedRepositoryImpl.UNCOMMITTED_VERSION); } } catch (MalformedURLException mue) { throw new ConfigurationException(URL, mue.getMessage()); } } }
backup.deleteOnExit(); FilebasedBackupRepository rep = new FilebasedBackupRepository(current, backup);