congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
CachedRepositoryImpl
Code IndexAdd Tabnine to your IDE (free)

How to use
CachedRepositoryImpl
in
org.apache.ace.repository.ext.impl

Best Java code snippets using org.apache.ace.repository.ext.impl.CachedRepositoryImpl (Showing top 11 results out of 315)

origin: org.apache.ace/org.apache.ace.repository.ext

public InputStream checkout(boolean fail) throws IOException, IllegalArgumentException {
  m_mostRecentVersion = highestRemoteVersion();
  if (m_mostRecentVersion == 0) {
    // If there is no remote version, then simply return an empty stream.
    if (fail) {
      throw new IOException("No version has yet been checked in to the repository.");
    }
    else {
      return new ByteArrayInputStream(new byte[0]);
    }
  }
  return checkout(m_mostRecentVersion);
}
origin: org.apache.ace/org.apache.ace.repository.ext

public boolean commit() throws IOException {
  if (m_mostRecentVersion < 0) {
    throw new IllegalStateException("A commit should be preceded by a checkout.");
  }
  return commit(m_mostRecentVersion++);
}
origin: org.apache.ace/org.apache.ace.client.repository.impl

/**
 * Helper method for login.
 * @throws IOException
 */
private CachedRepository getCachedRepositoryFromPreferences(User user, Repository repository, Preferences repositoryPrefs) throws IOException {
  long mostRecentVersion = repositoryPrefs.getLong("version", CachedRepositoryImpl.UNCOMMITTED_VERSION);
  return new CachedRepositoryImpl(user, repository, getBackupFromPreferences(repositoryPrefs), mostRecentVersion);
}
origin: org.apache.ace/org.apache.ace.repository.ext

public boolean isCurrent() throws IOException {
  return highestRemoteVersion() == m_mostRecentVersion;
}
origin: org.apache.ace/org.apache.ace.repository.ext

  private long highestRemoteVersion() throws IOException {
    long result = 0;
    RangeIterator ri = getRange().iterator();
    while (ri.hasNext()) {
      result = ri.next();
    }
    return result;
  }
}
origin: org.apache.ace/org.apache.ace.configurator.useradmin.task

public void updated(Dictionary dict) throws ConfigurationException {
  if (dict != null) {
    String locationString = (String) dict.get(KEY_REPOSITORY_LOCATION);
    if (locationString == null) {
      throw new ConfigurationException(KEY_REPOSITORY_LOCATION, "Property missing.");
    }
    URL location;
    try {
      location = new URL(locationString);
    }
    catch (MalformedURLException e) {
      throw new ConfigurationException(KEY_REPOSITORY_LOCATION, "Location " + locationString + " is not a valid URL.");
    }
    String customer = (String) dict.get(KEY_REPOSITORY_CUSTOMER);
    if (customer == null) {
      throw new ConfigurationException(KEY_REPOSITORY_CUSTOMER, "Property missing.");
    }
    String name = (String) dict.get(KEY_REPOSITORY_NAME);
    if (name == null) {
      throw new ConfigurationException(KEY_REPOSITORY_NAME, "Property missing.");
    }
    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));
  }
}
origin: org.apache.ace/org.apache.ace.deployment.provider.repositorybased

@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());
    }
  }
}
origin: org.apache.ace/org.apache.ace.repository.ext

public boolean commit(InputStream data, long fromVersion) throws IOException, IllegalArgumentException {
  m_local.write(data);
  return commit(fromVersion);
}
origin: apache/ace

/**
 * There are two types of commit, one that takes an input stream, and one that simply flushes whatever is in the
 * current to the remote repository. After each commit, we should be able to renew the cached repository, and
 * checkout the data we put in before.
 */
@Test()
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);
}
origin: apache/ace

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' };
m_cachedRepository.commit(input, 0);
m_cachedRepository = new CachedRepositoryImpl(m_repository, m_backupRepository, 0);
input = m_cachedRepository.checkout(1);
origin: apache/ace

/**
 * Initial checkout: the remote repository contains some data for a given version, we make the cached repository do
 * a checkout, and check whether all data arrives at the right places: in getLocal, and in the backup repository.
 */
@Test()
public void testInitialCheckout() throws IllegalArgumentException, IOException {
  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);
}
org.apache.ace.repository.ext.implCachedRepositoryImpl

Javadoc

Provides a CachedRepository, which uses either a Repository and a BackupRepository as remote and local storage, or a URL location and two files, from which it will create a Repository and a FileBasedBackupRepository. Note that this class is not thread-safe, and should be synchronized by the caller.

Most used methods

  • <init>
    Creates a cached repository using.
  • checkout
  • commit
  • getRange
  • highestRemoteVersion

Popular in Java

  • Running tasks concurrently on multiple threads
  • putExtra (Intent)
  • getApplicationContext (Context)
  • compareTo (BigDecimal)
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • LinkedHashMap (java.util)
    LinkedHashMap is an implementation of Map that guarantees iteration order. All optional operations a
  • TreeSet (java.util)
    TreeSet is an implementation of SortedSet. All optional operations (adding and removing) are support
  • JList (javax.swing)
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.> This module, both source code and documentation, is in t
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now