Additional Windchill Capabilities > Service Information Management > Customizing Windchill Service Information Manager and Windchill Service Parts > Custom Hook to Validate Incoming Translated Content
  
Custom Hook to Validate Incoming Translated Content
The CustomXMLValidationHook can validate incoming translated content received from translation vendors with an XML file before importing the content into Service Information Manager. If the validation is successful, the import process continues. If the validation generates an exception, SIM Translation fails the import process and the information from the exception is added to the import failure log file. In addition to the exception, the contents of the translation package are not imported, even if the translation package contained any files that may have passed the CustomXMLValidationHook validation.
The implementation of this hook requires you to specify the following details:
State when to fail the Import Translation Packages process—on the first XML validation failure or after the last XML validation failure.
Populate error message for files that failed XML validation in the import log file.
In the Import Translation Packages process, the CustomXMLValidationHook validation takes place after the translated package has been checked for malformed XML file contents but before the translated content is checked in.
Interface
package com.ptc.tml.validation;
import java.io.InputStream;
/**The interface provides the custom XML validation service for the translation *contents. The interface receives the file name and input stream of the file which is to be validated for the XML and need to throw the exception to indicate the XML validation
*failure for given file. The implementation must state whether the Import Translation Process should fail if the first XML validation failure has *encountered or after the last XML validation failure. The implementation also needs to populate the error message
*for failed XML validation for logging purpose.
*/
public interface CustomXMLValidationHook {
/**
* @return boolean Boolean value to indicate whether the translation process should be failed when the first XML validation failure is encountered
*/
public boolean failOnFirstError();
/**
* @param fileName Name of file in the translation zip to validated for XML
* @param is InputStream of the file to be validated for XML
* @throws TranslationException
*/
public void validateXML (String fileName, InputStream is) throws TranslationException;
/**
* @return Error message to be logged for XML validation failures
*/
public String getErrorMessage();
}
See also, SampleCustomXMLValidationFailFastHookImpl.java and SampleCustomXMLValidationHookImpl.java which are sample implementations that have been provided for reference. These are available at $WT_HOME\codebase\com\ptc\tml\sample location.
Registry
1. Use the xconfmanager utility to edit translation.service.properties.xconf. You can also register it in the components.service.properties file located at <Windchill>/codebase/com/ptc/core/components. For information on using the xconfmanager utility, see About the xconfmanager Utility.
2. Add the following property:
<Service context="default"
name="com.ptc.tml.validation.CustomXMLValidationHook">
<Option serviceClass="YourCustomXMLValidationHookClassName"
selector="null"/>
</Service>
3. Save the file.
4. Propagate your changes using the xconfmanager utility. From the <Windchill>\bin directory, enter the following command:
xconfmanager -pF
5. Restart the method server.