コード例 #1
0
 @Test
 public void shouldGetCmServer() throws CMException {
   Policy policy = mock(Policy.class);
   doReturn(policy).when(target).getPolicy();
   when(policy.getCMServer()).thenReturn(policyCMServer);
   assertEquals(policyCMServer, target.getCmServer());
 }
コード例 #2
0
 @Test
 public void shouldGetCurrentRootSiteId() throws CMException {
   doReturn(policyCMServer).when(target).getCmServer();
   doReturn(configUtil).when(target).getConfiguration(policyCMServer);
   Policy topPolicy = mock(Policy.class);
   VersionedContentId id = mock(VersionedContentId.class);
   when(contentSession.getTopPolicy()).thenReturn(topPolicy);
   when(topPolicy.getContentId()).thenReturn(id);
   when(configUtil.getCurrentRootSiteId(id)).thenReturn(siteId);
   assertEquals(siteId, target.getCurrentRootSiteId());
 }
コード例 #3
0
 public void add(int index, Policy policy, ReferenceMetaDataPolicy referenceMetaData) {
   contentIds()
       .add(
           index,
           policy.getContentId().getContentId(),
           (referenceMetaData != null ? referenceMetaData.getContentId().getContentId() : null));
 }
コード例 #4
0
  public int indexOf(Policy policy) {
    VersionedContentId policyId = policy.getContentId();

    for (int i = size() - 1; i >= 0; i--) {
      ContentIdUtil referredContentId = getEntry(i).getReferredContentId();

      if (referredContentId == null) {
        LOGGER.log(WARNING, "There was a null ID added to the content list " + this + ".");
        continue;
      }

      if (referredContentId.equalsIgnoreVersion(policyId)) {
        return i;
      }
    }

    return -1;
  }
コード例 #5
0
ファイル: ValueField.java プロジェクト: polopolyps/pcmd
  public String get(Policy policy, PolopolyContext context) {
    if (policy instanceof SingleValued) {
      try {
        return '"' + ((SingleValued) policy).getValue() + '"';
      } catch (CMException e) {
        System.err.println(e.toString());
        return "";
      }
    }
    // ContentPolicy implements ContentListAware but does not generally represent a content list.
    else if (policy instanceof ContentListAware && !(policy.getClass() == ContentPolicy.class)) {
      try {
        ContentList contentList = ((ContentListAware) policy).getContentList();

        StringBuffer result = new StringBuffer(100);

        result.append("[");

        boolean first = true;

        for (ContentId contentId : new ContentListIterator(contentList)) {
          if (!first) {
            result.append(", ");
          }

          result.append(AbstractContentIdField.get(contentId, context));

          first = false;
        }

        result.append("]");

        return result.toString();
      } catch (CMException e) {
        System.err.println(e);

        return "";
      }
    } else {
      return "";
    }
  }
コード例 #6
0
 public void remove(Policy policy) {
   contentIds().remove(policy.getContentId());
 }
コード例 #7
0
 public void add(int index, Policy policy) {
   contentIds().add(index, policy.getContentId().getContentId());
 }