/** * 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); }
@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()); } } }
/** * Helper method for login, which loads a set of repositories. * @param user A <code>User</code> object * @param rsd A RepositorySetDescriptor, defining the set to be created. * @param repos An array of <code>ObjectRepositoryImpl</code> which this set should manage. Each * @return The newly created repository set. * @throws IOException */ @SuppressWarnings("unchecked") public RepositorySet loadRepositorySet(User user, RepositorySetDescriptor rsd, ObjectRepositoryImpl[] repos) throws IOException { Repository repo = new RemoteRepository(rsd.m_location, rsd.m_customer, rsd.m_name); Preferences prefs = m_preferences.getUserPreferences(user.getName()); Preferences repoPrefs = getRepositoryPrefs(prefs, rsd.m_location, rsd.m_customer, rsd.m_name); return new RepositorySet(m_changeNotifier, m_log, user, repoPrefs, repos, getCachedRepositoryFromPreferences(user, repo, repoPrefs), rsd.m_name, rsd.m_writeAccess); }