Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.jharks.workflow.util;
 
 
An entity resolver used to allow DTD files to be specified using path relative to the user directory (NOT the directory where the XML file is located).
public class WorkFlowEntityResolver implements EntityResolver { 

    
The logger for the module.
    protected Log logger = LogFactory.getLog(getClass().getName());
    
    
The configuration file.
    private static WorkFlowConfig config = WorkFlowConfig.getInstance();
    
    
The "file://" prefix.
    private static final String FILE_PREFIX = "file://";
    
    
The ".dtd" suffix.
    private static final String DTD_SUFFIX = ".dtd";
    
    
Replaces the DTD entity, specified as a relative path, with a full path to the DTD file.

Parameters:
publicId the public ID of the entity.
systemId the system ID of the entity.
Returns:
an InputSource specifying the location of the DTD.
    public InputSource resolveEntity(String publicIdString systemId)
            throws SAXExceptionIOException {
        
        String relativePath;
        if (.isDebugEnabled())
            .debug("In EntityResolver: resolving " + systemId);
        
        if (systemId != null && systemId.equals("file://workflow.dtd")) {
            if (.isDebugEnabled())
                .debug("In EntityResolver: resolving workflow.dtd");
            InputStream is = BaseWorkFlowManagerImpl.class.getResourceAsStream("workflow.dtd");
                
            return new InputSource(is);
            
            
        } else if (systemId != null && systemId.startsWith() && 
                systemId.endsWith()) {
            relativePath = systemId.substring(.length());
            
        } else {
            relativePath = systemId;
        }
        
        relativePath = .getProperty("xml-base-directory") + 
                       System.getProperty("file.separator") + 
                       relativePath;
        
        return new InputSource(relativePath);
    }
New to GrepCode? Check out our FAQ X