@Override
public synchronized Locations getLocations(String application, String profile,
String label) {
if (label == null) {
label = this.defaultLabel;
}
SvnOperationFactory svnOperationFactory = new SvnOperationFactory();
if (hasText(getUsername())) {
svnOperationFactory
.setAuthenticationManager(new DefaultSVNAuthenticationManager(null,
false, getUsername(), getPassword()));
}
try {
String version;
if (new File(getWorkingDirectory(), ".svn").exists()) {
version = update(svnOperationFactory, label);
}
else {
version = checkout(svnOperationFactory);
}
return new Locations(application, profile, label, version,
getPaths(application, profile, label));
}
catch (SVNException e) {
throw new IllegalStateException("Cannot checkout repository", e);
}
finally {
svnOperationFactory.dispose();
}
}