* @since 4.0.0
*/
final class LocatableTransformHelper {
public static DataLocation cloneLocation(Locatable template) {
DataLocation original = template.getLocation();
DataLocationType type = original.getDataLocationType();
DataLocation clone = type.createLocation();
ExportableProperty[] properties = original.getExportableProperties();
for (ExportableProperty p : properties) {
p.exportTo(clone);
}
if (isPasswordMissing(original)) {
String password = askForPassword(template);
if (password != null) {
String propertyName = ((LoginProtectedResource) clone).getPasswordPropertyName();
clone.setProperty(propertyName, password);
}
}
return clone;
}