Exemple #1
0
 public void filter(Collection list) throws Exception {
   resetStorage();
   initializeStorage(new Vector());
   Iterator i, j;
   Metadata data;
   MetadataBase newData;
   String criteria;
   i = list.iterator();
   while (i.hasNext()) {
     data = (Metadata) i.next();
     criteria = defineCriteria(data);
     if (null != criteria) {
       agent.setCriteria(criteria);
       agent.search();
       if (0 == agent.getResults().size()) store(data);
       else {
         j = agent.getResults().iterator();
         while (j.hasNext()) {
           newData = new MetadataBase();
           newData.setOrigin(data.getOrigin());
           newData.setName(data.getName());
           newData.merge(agent.getName(), (Metadata) j.next());
           newData.merge(data);
           store(newData);
         }
       }
     }
   }
 }
Exemple #2
0
  /**
   * @throws Exception Exception
   * @see zws.pen.policy.op.PENDataOpBase#execute()
   */
  public void execute() throws Exception {
    {
    } // Logwriter.printOnConsole("CompareAttributeOP execute....");
    String finalString = null;
    String metaDataAttrValue = null;
    try {

      finalString = new Boolean(false).toString();
      Metadata metaData = getMetaData();
      // printValues(metaData);
      {
      } // Logwriter.printOnConsole("Attribute name .... " + getAttributeName());
      {
      } // Logwriter.printOnConsole("Attribute value .... " + getAttributeValue());
      metaDataAttrValue = metaData.get(getAttributeName());
      if (metaDataAttrValue != null) {
        if (metaDataAttrValue.startsWith(getAttributeValue())) {
          finalString = new Boolean(true).toString();
          {
          } // Logwriter.printOnConsole("Attribute value matches.... ");
        } else {
          {
          } // Logwriter.printOnConsole("Attribute value not matched.... ");
        }
      }
      {
      } // Logwriter.printOnConsole("finalString in CompareAttributeOP.... " + finalString);
      setResult(finalString);
    } catch (Exception e) {
      e.printStackTrace();
      throw e;
    }
  }
Exemple #3
0
 public boolean hasBeenRenumbered(Origin sourceOrigin) {
   try {
     SynchronizationService s = SynchronizationClient.getClient();
     Origin lastSynchronization =
         s.lastSynchronization(
             sourceOrigin.getDomainName(),
             sourceOrigin.getServerName(),
             sourceOrigin.getRepositoryName(),
             sourceOrigin.getName());
     if (null == lastSynchronization) return false;
     Collection c = s.findAllSynchronizationOrigins(lastSynchronization);
     Iterator i = c.iterator();
     Origin t;
     Repository targetRepository = getPenPolicy().getTargetRepository();
     while (i.hasNext()) {
       t = (Origin) i.next();
       if (!t.getDomainName().equals(targetRepository.getDomainName())) continue;
       else if (!t.getServerName().equals(targetRepository.getServerName())) continue;
       else if (!t.getRepositoryName().equals(targetRepository.getRepositoryName())) continue;
       else {
         Metadata txData = lookupTxMetadata(getCurrentItem());
         if (t.getName().equalsIgnoreCase(txData.getName())) return false;
         else return true;
       }
     }
   } catch (Exception e) {
     e.printStackTrace();
     return false;
   }
   return false;
 }
Exemple #4
0
  /**
   * @throws Exception Exception
   * @see zws.pen.policy.old.op.PENDataOpBase#execute()
   */
  public void setItemStatus(StatusElement statusElement) throws Exception {
    boolean isSynchronized = false;
    boolean isModified = false;
    boolean isRenumbered = false;
    Metadata sourceData = this.getPenData().lookupSrcMetaData(getCurrentItem());
    Origin sourceOrigin = sourceData.getOrigin();
    SynchronizationService r = SynchronizationClient.getClient();
    Collection c = r.findAllSynchronizationOrigins(sourceOrigin);
    /*if(null == c || c.isEmpty()) isModifed = hasBeenModified(sourceOrigin);
        else isSynchronized = hasBeenSynchronized(c);
    */
    if (null != c && !c.isEmpty()) isSynchronized = hasBeenSynchronized(c);
    if (!isSynchronized) isModified = hasBeenModified(sourceOrigin);
    if (isModified) isRenumbered = hasBeenRenumbered(sourceOrigin);

    // See if this origin is already synchronized to the target repository
    // if not see if an earlier version was previously published
    if (isSynchronized) statusElement.setItemStatus(STAT_SYNC_STATUS, OPT_SYNCHRONIZED);
    else if (isRenumbered) statusElement.setItemStatus(STAT_SYNC_STATUS, OPT_RENUMBERED);
    else if (isModified) statusElement.setItemStatus(STAT_SYNC_STATUS, OPT_MODIFIED);
    else statusElement.setItemStatus(STAT_SYNC_STATUS, OPT_NEW_ITEM);
  }
Exemple #5
0
 private String defineCriteria(Metadata data) {
   StringTokenizer tokens = new StringTokenizer(criteriaSpec, Names.VALUE_REF_START);
   StringBuffer c = new StringBuffer();
   String fieldRef, token, value = null;
   int idx;
   if (tokens.hasMoreTokens()) c.append(tokens.nextToken());
   while (tokens.hasMoreTokens()
       && null != value) { // parameterize rule for what to do if the value is null
     token = tokens.nextToken();
     idx = token.indexOf(Names.VALUE_REF_END);
     fieldRef = (token.substring(0, idx));
     value = data.get(fieldRef);
     if ("".equals(value)) value = null;
     c.append(value);
     c.append(token.substring(idx + 1));
   }
   if (null == value) return null;
   return c.toString();
 }