// Path: shim/src/main/java/info/vancauwenberge/filedriver/Build.java
// public class Build {
// 
// 	/** The build of your driver. */
// 	public static final String BUILD_NO;
// 
// 	/** The version of your driver. */
// 	static public final String PRODUCT_VERSION;
// 
// 	/** Your company name. */
// 	static public final String COMPANY_NAME;
// 
// 	/** The name of your driver. */
// 	static public final String PRODUCT_NAME;
// 
// 	static{
// 		final Class<Build> clazz = Build.class;
// 		final String className = clazz.getSimpleName() + ".class";
// 		Manifest manifest = null;
// 		try {
// 			final URLConnection connection = clazz.getResource(className).openConnection();
// 			if (connection instanceof JarURLConnection){
// 				manifest = ((JarURLConnection)connection).getManifest();
// 			}else{
// 				// Class not from JAR, but from the file system.
// 				final String classPath = clazz.getResource(className).toString();
// 				final String packageName = clazz.getPackage().getName();
// 				final String manifestPath = classPath.substring(0, classPath.length()-className.length()-packageName.length()-1) + "META-INF" + File.separatorChar + "MANIFEST.MF";
// 				manifest = new Manifest(new URL(manifestPath).openStream());
// 			}
// 		} catch (final Exception e1) {
// 			e1.printStackTrace();
// 		}
// 		final Attributes attr  = manifest==null?null:manifest.getMainAttributes();
// 		BUILD_NO = getAttribute("Built-Date",attr);
// 		PRODUCT_VERSION = getProductVersion(BUILD_NO,getAttribute("Implementation-Version",attr));
// 		COMPANY_NAME  = getAttribute("Implementation-Vendor",attr);
// 		PRODUCT_NAME = getAttribute("Implementation-Title",attr);
// 	}
// 	/*
// 	 * Get an attribute from the manifest, or unknown if no manifest is defined.
// 	 */
// 	private static String getAttribute(final String name, final Attributes attr ){
// 		if (attr!= null){
// 			final String value = attr.getValue(name);
// 			if (value != null) {
// 				return value;
// 			}
// 		}
// 		return "unknown";
// 	}
// 
// 	/**
// 	 * We reformat the date time in buildNo to YYYYMMDD-HHMMSS and append that to the productVersion
// 	 * @param buildNo
// 	 * @param productVesion
// 	 * @return
// 	 */
// 	private static String getProductVersion(final String buildNo, final String productVesion) {
// 		final SimpleDateFormat fromDf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// 		fromDf.setTimeZone(TimeZone.getTimeZone("UTC"));
// 		final SimpleDateFormat toDf = new SimpleDateFormat("yyyyMMddHHmm");
// 		toDf.setTimeZone(TimeZone.getTimeZone("UTC"));
// 		try{
// 			return productVesion+"."+toDf.format(fromDf.parse(buildNo));
// 		}catch (final Exception e) {
// 			e.printStackTrace();
// 			return productVesion;
// 		}
// 	}
// }


import com.novell.nds.dirxml.driver.xds.XDSQueryDocument;
import com.novell.nds.dirxml.driver.xds.XDSResultDocument;
import com.novell.nds.dirxml.driver.xds.XDSSourceElement;
import info.vancauwenberge.filedriver.Build;
import java.lang.reflect.Method;
import java.util.Map;
import com.novell.nds.dirxml.driver.Trace;
import com.novell.nds.dirxml.driver.xds.Parameter;
import com.novell.nds.dirxml.driver.xds.WriteableDocument;
import com.novell.nds.dirxml.driver.xds.XDSCommandDocument;
import com.novell.nds.dirxml.driver.xds.XDSProductElement;
        		Method m =c.getMethod("put", String.class, String.class);
        		m.invoke(null, "Trace", header);
        		if (trace != null)
        			trace.trace("SLF4J MDC set to:"+header,3);
        	}catch (Exception e) {
        		if (trace != null)
        			trace.trace("SLF4J not found. MDC not configured.",3);
        	}
        }
    }//setTrace(String):void
    
	protected abstract String getDriverInstanceName();
	
    /**
     *  Appends a populated <code>&lt;source&gt;</code> element to
     *  <code>doc</code>.
     *  <p>
     *  @param doc may be <code>null</code>
     */
    public void appendSourceInfo(WriteableDocument doc)
    {
        if (doc != null)
        {
            XDSSourceElement source;
            XDSProductElement product;

            source = doc.appendSourceElement();
            product = source.appendProductElement();

            //TODO: MODIFY:  put the time and date your driver was built here
// Path: shim/src/main/java/info/vancauwenberge/filedriver/Build.java
// public class Build {
// 
// 	/** The build of your driver. */
// 	public static final String BUILD_NO;
// 
// 	/** The version of your driver. */
// 	static public final String PRODUCT_VERSION;
// 
// 	/** Your company name. */
// 	static public final String COMPANY_NAME;
// 
// 	/** The name of your driver. */
// 	static public final String PRODUCT_NAME;
// 
// 	static{
// 		final Class<Build> clazz = Build.class;
// 		final String className = clazz.getSimpleName() + ".class";
// 		Manifest manifest = null;
// 		try {
// 			final URLConnection connection = clazz.getResource(className).openConnection();
// 			if (connection instanceof JarURLConnection){
// 				manifest = ((JarURLConnection)connection).getManifest();
// 			}else{
// 				// Class not from JAR, but from the file system.
// 				final String classPath = clazz.getResource(className).toString();
// 				final String packageName = clazz.getPackage().getName();
// 				final String manifestPath = classPath.substring(0, classPath.length()-className.length()-packageName.length()-1) + "META-INF" + File.separatorChar + "MANIFEST.MF";
// 				manifest = new Manifest(new URL(manifestPath).openStream());
// 			}
// 		} catch (final Exception e1) {
// 			e1.printStackTrace();
// 		}
// 		final Attributes attr  = manifest==null?null:manifest.getMainAttributes();
// 		BUILD_NO = getAttribute("Built-Date",attr);
// 		PRODUCT_VERSION = getProductVersion(BUILD_NO,getAttribute("Implementation-Version",attr));
// 		COMPANY_NAME  = getAttribute("Implementation-Vendor",attr);
// 		PRODUCT_NAME = getAttribute("Implementation-Title",attr);
// 	}
// 	/*
// 	 * Get an attribute from the manifest, or unknown if no manifest is defined.
// 	 */
// 	private static String getAttribute(final String name, final Attributes attr ){
// 		if (attr!= null){
// 			final String value = attr.getValue(name);
// 			if (value != null) {
// 				return value;
// 			}
// 		}
// 		return "unknown";
// 	}
// 
// 	/**
// 	 * We reformat the date time in buildNo to YYYYMMDD-HHMMSS and append that to the productVersion
// 	 * @param buildNo
// 	 * @param productVesion
// 	 * @return
// 	 */
// 	private static String getProductVersion(final String buildNo, final String productVesion) {
// 		final SimpleDateFormat fromDf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// 		fromDf.setTimeZone(TimeZone.getTimeZone("UTC"));
// 		final SimpleDateFormat toDf = new SimpleDateFormat("yyyyMMddHHmm");
// 		toDf.setTimeZone(TimeZone.getTimeZone("UTC"));
// 		try{
// 			return productVesion+"."+toDf.format(fromDf.parse(buildNo));
// 		}catch (final Exception e) {
// 			e.printStackTrace();
// 			return productVesion;
// 		}
// 	}
// }


// Path: shim/src/main/java/info/vancauwenberge/filedriver/shim/AbstractShim.java
import com.novell.nds.dirxml.driver.xds.XDSQueryDocument;
import com.novell.nds.dirxml.driver.xds.XDSResultDocument;
import com.novell.nds.dirxml.driver.xds.XDSSourceElement;
import info.vancauwenberge.filedriver.Build;
import java.lang.reflect.Method;
import java.util.Map;
import com.novell.nds.dirxml.driver.Trace;
import com.novell.nds.dirxml.driver.xds.Parameter;
import com.novell.nds.dirxml.driver.xds.WriteableDocument;
import com.novell.nds.dirxml.driver.xds.XDSCommandDocument;
import com.novell.nds.dirxml.driver.xds.XDSProductElement;

        		Method m =c.getMethod("put", String.class, String.class);
        		m.invoke(null, "Trace", header);
        		if (trace != null)
        			trace.trace("SLF4J MDC set to:"+header,3);
        	}catch (Exception e) {
        		if (trace != null)
        			trace.trace("SLF4J not found. MDC not configured.",3);
        	}
        }
    }//setTrace(String):void
    
	protected abstract String getDriverInstanceName();
	
    /**
     *  Appends a populated <code>&lt;source&gt;</code> element to
     *  <code>doc</code>.
     *  <p>
     *  @param doc may be <code>null</code>
     */
    public void appendSourceInfo(WriteableDocument doc)
    {
        if (doc != null)
        {
            XDSSourceElement source;
            XDSProductElement product;

            source = doc.appendSourceElement();
            product = source.appendProductElement();

            //TODO: MODIFY:  put the time and date your driver was built here
            product.setBuild(Build.BUILD_NO);