コード例 #1
0
  /** {@inheritDoc} */
  public void updateEntityReferences(String toContext, Map<String, String> transversalMap) {
    if (transversalMap != null && transversalMap.size() > 0) {
      Set<Entry<String, String>> entrySet = (Set<Entry<String, String>>) transversalMap.entrySet();

      try {
        String toSiteId = toContext;

        SyllabusItem fromSyllabusItem = syllabusManager.getSyllabusItemByContextId(toSiteId);

        if (fromSyllabusItem != null) {
          Set fromSyDataSet = syllabusManager.getSyllabiForSyllabusItem(fromSyllabusItem);

          Iterator fromSetIter = fromSyDataSet.iterator();

          while (fromSetIter.hasNext()) {
            SyllabusData fromSyllabusData = (SyllabusData) fromSetIter.next();

            String msgBody = fromSyllabusData.getAsset();
            StringBuffer msgBodyPreMigrate = new StringBuffer(msgBody);
            boolean updated = false;
            /*
            						Iterator<Entry<String, String>> entryItr = entrySet.iterator();
            						while(entryItr.hasNext()) {
            							Entry<String, String> entry = (Entry<String, String>) entryItr.next();
            							String fromContextRef = entry.getKey();
            							if(msgBody.contains(fromContextRef)){
            								msgBody = msgBody.replace(fromContextRef, entry.getValue());
            								updated = true;
            							}
            						}
            */
            msgBody = LinkMigrationHelper.editLinks(msgBody, "sam_pub");
            msgBody = LinkMigrationHelper.editLinks(msgBody, "/posts/");
            msgBody = LinkMigrationHelper.miagrateAllLinks(entrySet, msgBody);
            if (!msgBody.equals(msgBodyPreMigrate.toString())) {

              //						if(updated){
              fromSyllabusData.setAsset(msgBody);
              syllabusManager.saveSyllabus(fromSyllabusData);
            }
          }
        }
      } catch (Exception e) {
        logger.debug("Syllabus updateEntityReferences failed" + e);
      }
    }
  }