MigrationPaths
objects containing MigrationPath
instances created from a generic wrapper configuration Document.
@author Thomas Skou Hansen <tsh@statsbiblioteket.dk>
// Verify that all identifiers in commandLineIdentifiers are associated
// with a value in identifierMap
if (!identifierMap.keySet().containsAll(commandLineIdentifiers)) {
commandLineIdentifiers.removeAll(identifierMap.keySet());
throw new ConfigurationException("Cannot build the command line. "
+ "Missing values for these identifiers: "
+ commandLineIdentifiers);
}
// Replace the identifiers in the command line fragments with their
presetCategoryID = parameter.getName();
final Preset preset = toolPresets
.getPreset(presetCategoryID);
presetSetting = preset.getSetting(parameter.getValue());
if (presetSetting == null) {
throw new ConfigurationException(String.format(
"The preset '%s = %s' has not been defined"
+ " in the configuration.",
parameter.getName(), parameter.getValue()));
}
} else {
throw new ConfigurationException(String.format(
"More than one preset was specified in the "
+ "parameters. Found '%s"
+ " = %s' and '%s = %s'.",
presetCategoryID, presetSetting.getName(),
parameter.getName(), parameter.getValue()));
builder.properties(serviceProperties);
return builder.build();
} catch (XPathExpressionException xPathExpressionException) {
throw new ConfigurationException(String.format(
"Failed parsing the '%s' element in the '%s' element.",
ConfigurationFileTagsV1.SERVICE_DESCRIPTION_ELEMENT_XPATH,
this.configuration.getNodeName()), xPathExpressionException);
} catch (NullPointerException nullPointerException) {
throw new ConfigurationException(String.format(
"Failed parsing the '%s' element in the '%s' element.",
ConfigurationFileTagsV1.SERVICE_DESCRIPTION_ELEMENT_XPATH,
this.configuration.getNodeName()), nullPointerException);
}
}
return elementNode.getTextContent().trim();
} catch (Exception exception) {
// This is a mandatory element, thus no exceptions are tolerated.
throw new ConfigurationException(String.format(
"Failed parsing the '%s' element in the '%s' element.",
elementName, nodeWithMandatoryElement.getNodeName()),
exception);
}
}
} catch (XPathExpressionException xpee) {
// The URI element is optional, thus ignore exceptions.
} catch (NullPointerException npe) {
// The URI element is optional, thus ignore exceptions.
} catch (URISyntaxException uriSyntalException) {
throw new ConfigurationException(String.format(
"Failed parsing the '%s' element and creating a URI, in "
+ "the '%s' element.", elementName,
nodeWithOptionalURIElement.getNodeName()),
uriSyntalException);
}
} catch (XPathExpressionException xpee) {
// The URI element is optional, thus ignore exceptions.
} catch (NullPointerException npe) {
// The URI element is optional, thus ignore exceptions.
} catch (MalformedURLException malformedURLException) {
throw new ConfigurationException(String.format(
"Failed parsing the '%s' element and creating a URL, in "
+ "the '%s' element.", elementName,
nodeWithOptionalURLElement.getNodeName()),
malformedURLException);
}
properties.add(propertyBuilder.build());
}
return properties.toArray(new Property[properties.size()]);
} catch (Exception exception) {
throw new ConfigurationException(String.format(
"Failed parsing the '%s' element of the configuration"
+ " document.", serviceDescriptionNode
.getNodeName()), exception);
}
}
final Tool toolDescription = new Tool(identifierURI, name, version,
description, homePageURL);
return toolDescription;
} catch (XPathExpressionException xPathExpressionException) {
throw new ConfigurationException(String.format(
"Failed parsing the '%s' element in the element: %s",
ConfigurationFileTagsV1.TOOL_ELEMENT,
nodeWithToolDescription.getNodeName()),
xPathExpressionException);
}
Map<String, String> identifierMap,
Map<String, File> tempFileMappings) throws MigrationException {
for (String tempFileLabel : tempFileMappings.keySet()) {
if (identifierMap.containsKey(tempFileLabel)) {
throw new MigrationException(String.format(
"The identifier map already contains an element with "
+ "the key '%s'. Cannot add the temporay file "
+ "mapping '%s = %s'.", tempFileLabel,
tempFileLabel, tempFileMappings.get(tempFileLabel)));
}
try {
identifierMap.put(tempFileLabel, tempFileMappings.get(
tempFileLabel).getCanonicalPath());
} catch (SecurityException se) {
throw new MigrationException(
String.format(
"Failed accessing the canonical file path of the "
+ "temporary file labeled '%s'",
tempFileLabel), se);
} catch (IOException ioe) {
throw new MigrationException(
String.format(
"Failed accessing the canonical file path of the "
+ "temporary file labeled '%s'",
tempFileLabel), ioe);
}
temporaryFileMappings = createTemporaryFile(
temporaryFileMappings, tempFileLabel, desiredFileName);
}
} catch (IOException ioe) {
throw new MigrationException("Failed creating temporary files.",
ioe);
}
return temporaryFileMappings;
}
Related Classes of eu.planets_project.ifr.core.services.migration.genericwrapper2.DBMigrationPathFactory
Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.