if (resourcePath != null) {
Map<String, ArtifactSerializer> artifactSerializers = TokenNameFinderModel
.createArtifactSerializers();
List<Element> elements = new ArrayList<Element>();
ArtifactSerializer serializer = null;
// TODO: If there is descriptor file, it should be consulted too
if (featureGenDescriptor != null) {
InputStream xmlDescriptorIn = CmdLineUtil.openInFile(featureGenDescriptor);
try {
artifactSerializers.putAll(GeneratorFactory.extractCustomArtifactSerializerMappings(xmlDescriptorIn));
} catch (IOException e) {
// TODO: Improve error handling!
e.printStackTrace();
}
InputStream inputStreamXML = CmdLineUtil.openInFile(featureGenDescriptor);
try {
elements = GeneratorFactory.getDescriptorElements(inputStreamXML);
} catch (IOException e) {
e.printStackTrace();
}
}
File resourceFiles[] = resourcePath.listFiles();
for (File resourceFile : resourceFiles) {
String resourceName = resourceFile.getName();
//gettting the serializer key from the element tag name
//if the element contains a dict attribute
for (Element xmlElement : elements) {
String dictName = xmlElement.getAttribute("dict");
if (dictName != null && dictName.equals(resourceName)) {
serializer = artifactSerializers.get(xmlElement.getTagName());
}
}
// TODO: Do different? For now just ignore ....
if (serializer == null)
continue;
InputStream resourceIn = CmdLineUtil.openInFile(resourceFile);
try {
resources.put(resourceName, serializer.create(resourceIn));
} catch (InvalidFormatException e) {
// TODO: Fix exception handling
e.printStackTrace();
} catch (IOException e) {
// TODO: Fix exception handling