Пример #1
0
 @Override
 protected boolean filter(
     CDORevision revision,
     CDORevisionProvider revisionProvider,
     CDOBranchPoint securityContext,
     int level)
     throws Exception {
   EPackage actualPackage = revision.getEClass().getEPackage();
   EPackage applicablePackage = getApplicablePackage();
   return actualPackage == applicablePackage;
 }
Пример #2
0
  protected void checkDuplicateResources(CDORevision revision) throws IllegalStateException {
    final long folderID = CDOIDUtil.getLong((CDOID) revision.data().getContainerID());
    final long revisionID = CDOIDUtil.getLong(revision.getID());
    final String name =
        (String) revision.data().get(EresourcePackage.eINSTANCE.getCDOResourceNode_Name(), 0);

    ObjectSet<DB4ORevision> resultSet =
        getObjectContainer()
            .query(
                new Predicate<DB4ORevision>() {
                  private static final long serialVersionUID = 1L;

                  @Override
                  public boolean match(DB4ORevision revision) {
                    if (revision.isResourceNode()
                        && ObjectUtil.equals(revision.getContainerID(), folderID)) {
                      String candidateName =
                          (String) revision.getValues().get(EresourcePackage.CDO_RESOURCE__NAME);
                      if (StringUtil.compare(name, candidateName) == 0) {
                        if (!ObjectUtil.equals(revision.getID(), revisionID)) {
                          return true;
                        }
                      }
                    }

                    return false;
                  }
                });

    if (!resultSet.isEmpty()) {
      throw new IllegalStateException(
          "Duplicate resource or folder: "
              + name
              + " in folder "
              + folderID); //$NON-NLS-1$ //$NON-NLS-2$
    }
  }
Пример #3
0
  public boolean handleRevision(CDORevision revision) {
    if (revision.getVersion() < CDOBranchVersion.FIRST_VERSION - 1) {
      revision =
          new DetachedCDORevision(
              revision.getEClass(),
              revision.getID(),
              revision.getBranch(),
              -revision.getVersion(),
              revision.getTimeStamp(),
              revision.getRevised());
    }

    return delegate.handleRevision(revision);
  }
  /** See bug 315409. */
  @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
  public void _testInvalidationWithDeltas_SubBranch() throws Exception {
    CDOSession session = openSession();
    CDOTransaction transaction = session.openTransaction();

    Company company = getModel1Factory().createCompany();
    company.setName("main-v1");

    CDOResource resource = transaction.createResource(getResourcePath("/test1"));
    resource.getContents().add(company);

    transaction.commit();

    company.setName("main-v2");
    transaction.commit();

    CDOBranch subBranch = transaction.getBranch().createBranch("SUB_BRANCH");
    transaction.setBranch(subBranch);

    CDOView view = session.openView(subBranch);
    view.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
    Company company2 = view.getObject(company);
    company2.eAdapters().add(new AdapterImpl());

    company.setName("sub-v1");
    commitAndSync(transaction, view);

    CDORevision revision2 = CDOUtil.getCDOObject(company2).cdoRevision();
    assertEquals(1, revision2.getVersion());
    assertEquals(transaction.getBranch(), revision2.getBranch());
    assertEquals(transaction.getLastCommitTime(), revision2.getTimeStamp());

    company.setName("sub-v2");
    commitAndSync(transaction, view);

    revision2 = CDOUtil.getCDOObject(company2).cdoRevision();
    assertEquals(2, revision2.getVersion());
    assertEquals(transaction.getBranch(), revision2.getBranch());
    assertEquals(transaction.getLastCommitTime(), revision2.getTimeStamp());
  }
  /** See bug 315409. */
  public void testInvalidationWithDeltas_SameBranch() throws Exception {
    CDOSession session = openSession();
    CDOTransaction transaction = session.openTransaction();
    CDOView view = session.openView();

    Company company = getModel1Factory().createCompany();
    company.setName("main-v1");

    CDOResource resource = transaction.createResource(getResourcePath("/test1"));
    resource.getContents().add(company);

    commitAndSync(transaction, view);

    company.setName("main-v2");
    commitAndSync(transaction, view);

    view.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
    Company company2 = view.getObject(company);
    company2.eAdapters().add(new AdapterImpl());

    company.setName("main-v3");
    commitAndSync(transaction, view);

    CDORevision revision2 = CDOUtil.getCDOObject(company2).cdoRevision();
    assertEquals(3, revision2.getVersion());
    assertEquals(transaction.getBranch(), revision2.getBranch());
    assertEquals(transaction.getLastCommitTime(), revision2.getTimeStamp());

    company.setName("main-v4");
    commitAndSync(transaction, view);

    revision2 = CDOUtil.getCDOObject(company2).cdoRevision();
    assertEquals(4, revision2.getVersion());
    assertEquals(transaction.getBranch(), revision2.getBranch());
    assertEquals(transaction.getLastCommitTime(), revision2.getTimeStamp());
  }