Exemple #1
0
  /** Clone the data from the src type to the target */
  @Override
  public void copyDocumentRepo(
      CallingContext context, String srcAuthority, String targAuthority, final Boolean wipe) {
    Repository srcRepo = Kernel.getKernel().getRepo(srcAuthority); // $NON-NLS-1$
    final Repository targRepo = Kernel.getKernel().getRepo(targAuthority); // $NON-NLS-1$
    if (wipe) {
      targRepo.drop();
    }

    srcRepo.visitAll(
        "",
        null,
        new RepoVisitor() { //$NON-NLS-1$

          @Override
          public boolean visit(String name, JsonContent content, boolean isFolder) {
            try {
              log.info(Messages.getString("Admin.Copying") + name); // $NON-NLS-1$
              targRepo.addDocument(
                  name,
                  content.getContent(),
                  "$copy", //$NON-NLS-1$
                  Messages.getString("Admin.CopyRepo"),
                  wipe); //$NON-NLS-1$
            } catch (RaptureException e) {
              log.info(Messages.getString("Admin.NoAddDoc") + name); // $NON-NLS-1$
            }
            return true;
          }
        });
  }
Exemple #2
0
  /** This method is used to setup a link between a local repo and a remote one. The remoteName */
  @Override
  public void setRemote(
      CallingContext context, String raptureURIString, String remote, String remoteURIString) {
    RaptureURI internalURI = new RaptureURI(raptureURIString, Scheme.DOCUMENT);
    if (internalURI.hasDocPath()) {
      throw RaptureExceptionFactory.create(
          HttpURLConnection.HTTP_BAD_REQUEST,
          apiMessageCatalog.getMessage("NoDocPath", internalURI.toShortString())); // $NON-NLS-1$
    }
    checkParameter(NAME, internalURI.getAuthority());
    checkParameter("Remote", remote); // $NON-NLS-1$
    RaptureURI remoteURI = new RaptureURI(raptureURIString, Scheme.DOCUMENT);
    if (remoteURI.hasDocPath()) {
      throw RaptureExceptionFactory.create(
          HttpURLConnection.HTTP_BAD_REQUEST,
          apiMessageCatalog.getMessage("NoDocPath", remoteURI.toShortString())); // $NON-NLS-1$
    }
    checkParameter(NAME, remoteURI.getAuthority());

    // This is set in the repo
    Repository repository = getKernel().getRepo(internalURI.getAuthority()); // $NON-NLS-1$
    repository.setRemote(remote, remoteURI.getAuthority());
    Kernel.typeChanged(internalURI);
  }