updated resource handling in content canning. use IContentValidator
diff --git a/2.0/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/layout/DefaultContentValidator.java b/2.0/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/layout/DefaultContentValidator.java
index f427afe..0e48447 100644
--- a/2.0/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/layout/DefaultContentValidator.java
+++ b/2.0/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/layout/DefaultContentValidator.java
@@ -13,8 +13,11 @@
import java.io.File;
import java.io.PrintStream;
+import org.eclipse.epf.library.ILibraryResourceManager;
import org.eclipse.epf.library.LibraryResources;
+import org.eclipse.epf.library.util.ContentResourceScanner;
import org.eclipse.epf.library.util.LibraryUtil;
+import org.eclipse.epf.library.util.ResourceHelper;
import org.eclipse.epf.uma.MethodConfiguration;
import org.eclipse.epf.uma.MethodElement;
import org.eclipse.osgi.util.NLS;
@@ -76,6 +79,34 @@
return true; // default
}
+ public void scanContent(IElementLayout layout, String content) throws Exception {
+
+ MethodElement owner = layout.getElement();
+ String contentPath = layout.getFilePath();
+
+ ContentResourceScanner scanner = getScanner(owner);
+ if ( scanner != null ) {
+ scanner.resolveResources(owner, content, contentPath);
+ }
+ }
+
+ /**
+ * Returns the content resource scanner for the element.
+ */
+ private ContentResourceScanner getScanner(MethodElement owner) {
+ ILibraryResourceManager resMgr = ResourceHelper.getResourceMgr(owner);
+ if ( resMgr == null ) {
+ return null;
+ }
+
+ String rootContentPath = resMgr.getLogicalPluginPath(owner);
+ File src_root = new File(resMgr.getPhysicalPluginPath(owner));
+ File tgt_root = new File(pubDir, rootContentPath);
+ ContentResourceScanner scanner = new ContentResourceScanner(src_root, tgt_root, rootContentPath, this);
+
+ return scanner;
+ }
+
public LinkInfo validateLink(MethodElement owner, String attributes,
String text, MethodConfiguration config, String tag) {
diff --git a/2.0/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/layout/HtmlBuilder.java b/2.0/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/layout/HtmlBuilder.java
index 1f0b2f0..8c78b77 100644
--- a/2.0/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/layout/HtmlBuilder.java
+++ b/2.0/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/layout/HtmlBuilder.java
@@ -180,22 +180,22 @@
return this.mgr.getValidator();
}
- /**
- * Returns the content resource scanner for the element.
- */
- private ContentResourceScanner getScanner(MethodElement owner) {
- ILibraryResourceManager resMgr = ResourceHelper.getResourceMgr(owner);
- if ( resMgr == null ) {
- return null;
- }
-
- String rootContentPath = resMgr.getLogicalPluginPath(owner);
- File src_root = new File(resMgr.getPhysicalPluginPath(owner));
- File tgt_root = new File(getPublishDir(), rootContentPath);
- ContentResourceScanner scanner = new ContentResourceScanner(src_root, tgt_root, rootContentPath, getValidator());
-
- return scanner;
- }
+// /**
+// * Returns the content resource scanner for the element.
+// */
+// private ContentResourceScanner getScanner(MethodElement owner) {
+// ILibraryResourceManager resMgr = ResourceHelper.getResourceMgr(owner);
+// if ( resMgr == null ) {
+// return null;
+// }
+//
+// String rootContentPath = resMgr.getLogicalPluginPath(owner);
+// File src_root = new File(resMgr.getPhysicalPluginPath(owner));
+// File tgt_root = new File(getPublishDir(), rootContentPath);
+// ContentResourceScanner scanner = new ContentResourceScanner(src_root, tgt_root, rootContentPath, getValidator());
+//
+// return scanner;
+// }
/**
* Sets the flag to display the "Show tree browser" image/link.
@@ -409,8 +409,9 @@
content, getValidator(), layout.getLayoutMgr()
.getConfiguration());
if (contentScanEnabled()) {
- scanContentForResources(layout.getElement(), content, layout
- .getFilePath());
+// scanContentForResources(layout.getElement(), content, layout
+// .getFilePath());
+ getValidator().scanContent(layout, content);
}
if ( debug) {
@@ -495,16 +496,16 @@
return xml;
}
- /**
- * Scans the content for resource references.
- */
- private void scanContentForResources(MethodElement owner, String content,
- String contentPath) {
- ContentResourceScanner scanner = getScanner(owner);
- if ( scanner != null ) {
- scanner.resolveResources(owner, content, contentPath);
- }
- }
+// /**
+// * Scans the content for resource references.
+// */
+// private void scanContentForResources(MethodElement owner, String content,
+// String contentPath) {
+// ContentResourceScanner scanner = getScanner(owner);
+// if ( scanner != null ) {
+// scanner.resolveResources(owner, content, contentPath);
+// }
+// }
public void dispose() {
// if (validator != null) {
diff --git a/2.0/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/layout/IContentValidator.java b/2.0/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/layout/IContentValidator.java
index 3a1cb90..fc377b7 100644
--- a/2.0/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/layout/IContentValidator.java
+++ b/2.0/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/layout/IContentValidator.java
@@ -12,6 +12,7 @@
import java.io.File;
+import org.eclipse.epf.library.layout.resource.IResourceProcessor;
import org.eclipse.epf.uma.MethodConfiguration;
import org.eclipse.epf.uma.MethodElement;
@@ -22,20 +23,22 @@
* @since 1.0
*
*/
-public interface IContentValidator {
+public interface IContentValidator {
/**
* set publish dir
* @param pubDir String
*/
public void setPublishDir(String pubDir);
-
+
/**
* show broken links if true
* @return boolean
*/
public boolean showBrokenLinks();
+ public void scanContent(IElementLayout layout, String content) throws Exception;
+
/**
* validate the link attribute and linked text for the owning element within the configuration.
* Returns a LinkInfo object.