use of org.tmatesoft.svn.core.SVNException in project intellij-community by JetBrains.
the class SvnAuthenticationTest method testPlaintextPromptAndSecondPrompt.
public void testPlaintextPromptAndSecondPrompt() throws Exception {
SVNJNAUtil.setJNAEnabled(false);
// yes, no
final TestListener listener = new TestListener(mySynchObject);
myAuthenticationManager.addListener(listener);
final SavedOnceListener savedOnceListener = new SavedOnceListener();
myAuthenticationManager.addListener(savedOnceListener);
myTestInteraction.setPlaintextAnswer(false);
final SVNURL url = SVNURL.parseURIEncoded("http://some.host.com/repo");
final SVNURL url2 = SVNURL.parseURIEncoded("http://some.other.host.com/repo");
final SVNException[] exception = new SVNException[1];
final Boolean[] result = new Boolean[1];
synchronousBackground(() -> {
try {
listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.interactive, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.without_pasword_save));
commonScheme(url, false, null);
long start = System.currentTimeMillis();
waitListenerStep(start, listener, 3);
Assert.assertEquals(1, myTestInteraction.getNumPlaintextPrompt());
// actually password not saved, but save was called
savedOnceListener.assertSaved(url, ISVNAuthenticationManager.PASSWORD);
savedOnceListener.reset();
myTestInteraction.reset();
listener.addStep(new Trinity<>(ProviderType.persistent, url2, Type.request));
listener.addStep(new Trinity<>(ProviderType.interactive, url2, Type.request));
listener.addStep(new Trinity<>(ProviderType.persistent, url2, Type.without_pasword_save));
commonScheme(url2, false, "anotherRealm");
start = System.currentTimeMillis();
waitListenerStep(start, listener, 6);
Assert.assertEquals(1, myTestInteraction.getNumPlaintextPrompt());
} catch (SVNException e) {
exception[0] = e;
}
result[0] = true;
});
Assert.assertTrue(result[0]);
Assert.assertEquals(1, myTestInteraction.getNumPlaintextPrompt());
Assert.assertEquals(6, listener.getCnt());
listener.assertForAwt();
savedOnceListener.assertForAwt();
// didn't called to save for 2nd time
savedOnceListener.assertNotSaved(url, ISVNAuthenticationManager.PASSWORD);
if (exception[0] != null) {
throw exception[0];
}
SVNJNAUtil.setJNAEnabled(true);
}
use of org.tmatesoft.svn.core.SVNException in project oxTrust by GluuFederation.
the class SubversionService method initSubversionService.
/*
* Initialize singleton instance during startup
*/
public void initSubversionService() {
String svnConfigurationStoreRoot = null;
if (appConfiguration.isPersistSVN()) {
svnConfigurationStoreRoot = appConfiguration.getSvnConfigurationStoreRoot();
}
SVNAdminAreaFactory.setSelector(new ISVNAdminAreaFactorySelector() {
@SuppressWarnings({ "unchecked", "rawtypes" })
public Collection getEnabledFactories(File path, Collection factories, boolean writeAccess) throws SVNException {
Collection enabledFactories = new TreeSet();
for (Iterator factoriesIter = factories.iterator(); factoriesIter.hasNext(); ) {
SVNAdminAreaFactory factory = (SVNAdminAreaFactory) factoriesIter.next();
int version = factory.getSupportedVersion();
if (version == SVNAdminAreaFactory.WC_FORMAT_16) {
enabledFactories.add(factory);
}
}
return enabledFactories;
}
});
if (StringHelper.isEmpty(svnConfigurationStoreRoot)) {
log.warn("The service which commit configuration files into SVN was disabled");
return;
}
SvnHelper.setupLibrary(svnConfigurationStoreRoot);
}
use of org.tmatesoft.svn.core.SVNException in project Gargoyle by callakrsos.
the class SVNLog method log.
public List<SVNLogEntry> log(String path, long startRevision, Date endDate, Consumer<Exception> exceptionHandler) {
SVNLogClient logClient = getSvnManager().getLogClient();
List<SVNLogEntry> result = new ArrayList<>();
try {
ISVNLogEntryHandler handler = logEntry -> {
LOGGER.debug("path :: {} rivision :: {} date :: {} author :: {} message :: {} ", path, logEntry.getRevision(), logEntry.getDate(), logEntry.getAuthor(), logEntry.getMessage());
result.add(logEntry);
};
logServer(path, startRevision, endDate, logClient, handler);
} catch (SVNException e) {
LOGGER.error(ValueUtil.toString(e));
if (exceptionHandler != null)
exceptionHandler.accept(e);
}
return result;
}
use of org.tmatesoft.svn.core.SVNException in project Gargoyle by callakrsos.
the class ScmCommitComposite method scmHistoryWalk.
private void scmHistoryWalk() throws SVNException {
List<GagoyleDate> periodDaysByWeek = DateUtil.getPeriodDaysByWeek(supplier.getWeekSize());
Collection<SVNLogEntry> allLogs = supplier.getAllLogs();
// supplier.createStream(allLogs);
TreeMap<String, Long> dayOfMonths = allLogs.stream().collect(Collectors.groupingBy(v -> FxSVNHistoryDataSupplier.YYYYMMDD_EEE_PATTERN.format(v.getDate()), () -> new TreeMap<>(), Collectors.counting()));
Map<String, Long> dayOfWeeks = new LinkedHashMap<>();
//초기값 세팅. [중요한건 정렬순서를 유지해아하므로. 초기값을 넣어준것.]
for (GagoyleDate d : DateUtil.getPeriodDaysByWeek()) {
String eee = FxSVNHistoryDataSupplier.EEE_PATTERN.format(d.toDate());
dayOfWeeks.put(eee, new Long(0));
}
//실제값 add
dayOfWeeks.putAll(allLogs.stream().collect(Collectors.groupingBy(v -> FxSVNHistoryDataSupplier.EEE_PATTERN.format(v.getDate()), Collectors.counting())));
{
BarChart<String, Long> barChartDayOfMonth = getBarChartDayOfMonth();
ObservableList<Data<String, Long>> convert = convert(FxSVNHistoryDataSupplier.YYYYMMDD_EEE_PATTERN, periodDaysByWeek, dayOfMonths, true);
Series<String, Long> series = new Series<>(SERIES_LABEL, convert);
barChartDayOfMonth.getData().add(series);
}
{
LineChart<String, Long> lineChartDayOfWeek = getLineChartDayOfWeek();
ObservableList<Data<String, Long>> convert = convert(FxSVNHistoryDataSupplier.EEE_PATTERN, DateUtil.getPeriodDaysByWeek(), dayOfWeeks, false);
Series<String, Long> series = new Series<>(SERIES_LABEL, convert);
lineChartDayOfWeek.getData().add(series);
}
}
use of org.tmatesoft.svn.core.SVNException in project Gargoyle by callakrsos.
the class DisplayFile method main.
/*
* args parameter is used to obtain a repository location URL, user's
* account name & password to authenticate him to the server, the file path
* in the rpository (the file path should be relative to the the
* path/to/repository part of the repository location URL).
*/
public static void main(String[] args) {
/*
* Default values:
*/
String url = "https://dev.naver.com/svn/gmes/AddressApp";
String name = "callakrsos";
String password = "zkffk88";
String filePath = ".classpath";
/*
* Initializes the library (it must be done before ever using the
* library itself)
*/
setupLibrary();
if (args != null) {
/*
* Obtains a repository location URL
*/
url = (args.length >= 1) ? args[0] : url;
/*
* Obtains a file path
*/
filePath = (args.length >= 2) ? args[1] : filePath;
/*
* Obtains an account name (will be used to authenticate the user to
* the server)
*/
name = (args.length >= 3) ? args[2] : name;
/*
* Obtains a password
*/
password = (args.length >= 4) ? args[3] : password;
}
SVNRepository repository = null;
try {
/*
* Creates an instance of SVNRepository to work with the repository.
* All user's requests to the repository are relative to the
* repository location used to create this SVNRepository. SVNURL is
* a wrapper for URL strings that refer to repository locations.
*/
repository = SVNRepositoryFactory.create(SVNURL.parseURIEncoded(url));
} catch (SVNException svne) {
/*
* Perhaps a malformed URL is the cause of this exception
*/
System.err.println("error while creating an SVNRepository for the location '" + url + "': " + svne.getMessage());
System.exit(1);
}
/*
* User's authentication information (name/password) is provided via an
* ISVNAuthenticationManager instance. SVNWCUtil creates a default
* authentication manager given user's name and password.
*
* Default authentication manager first attempts to use provided user
* name and password and then falls back to the credentials stored in
* the default Subversion credentials storage that is located in
* Subversion configuration area. If you'd like to use provided user
* name and password only you may use BasicAuthenticationManager class
* instead of default authentication manager:
*
* authManager = new BasicAuthenticationsManager(userName,
* userPassword);
*
* You may also skip this point - anonymous access will be used.
*/
ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(name, password);
repository.setAuthenticationManager(authManager);
/*
* This Map will be used to get the file properties. Each Map key is a
* property name and the value associated with the key is the property
* value.
*/
SVNProperties fileProperties = new SVNProperties();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
/*
* Checks up if the specified path really corresponds to a file. If
* doesn't the program exits. SVNNodeKind is that one who says what
* is located at a path in a revision. -1 means the latest revision.
*/
SVNNodeKind nodeKind = repository.checkPath(filePath, -1);
if (nodeKind == SVNNodeKind.NONE) {
System.err.println("There is no entry at '" + url + "'.");
System.exit(1);
} else if (nodeKind == SVNNodeKind.DIR) {
System.err.println("The entry at '" + url + "' is a directory while a file was expected.");
System.exit(1);
}
/*
* Gets the contents and properties of the file located at filePath
* in the repository at the latest revision (which is meant by a
* negative revision number).
*/
repository.getFile(filePath, -1, fileProperties, baos);
} catch (SVNException svne) {
System.err.println("error while fetching the file contents and properties: " + svne.getMessage());
System.exit(1);
}
/*
* Here the SVNProperty class is used to get the value of the
* svn:mime-type property (if any). SVNProperty is used to facilitate
* the work with versioned properties.
*/
String mimeType = fileProperties.getStringValue(SVNProperty.MIME_TYPE);
/*
* SVNProperty.isTextMimeType(..) method checks up the value of the
* mime-type file property and says if the file is a text (true) or not
* (false).
*/
boolean isTextType = SVNProperty.isTextMimeType(mimeType);
Iterator iterator = fileProperties.nameSet().iterator();
/*
* Displays file properties.
*/
while (iterator.hasNext()) {
String propertyName = (String) iterator.next();
String propertyValue = fileProperties.getStringValue(propertyName);
System.out.println("File property: " + propertyName + "=" + propertyValue);
}
/*
* Displays the file contents in the console if the file is a text.
*/
if (isTextType) {
System.out.println("File contents:");
System.out.println();
try {
baos.writeTo(System.out);
} catch (IOException ioe) {
ioe.printStackTrace();
}
} else {
System.out.println("File contents can not be displayed in the console since the mime-type property says that it's not a kind of a text file.");
}
/*
* Gets the latest revision number of the repository
*/
long latestRevision = -1;
try {
latestRevision = repository.getLatestRevision();
} catch (SVNException svne) {
System.err.println("error while fetching the latest repository revision: " + svne.getMessage());
System.exit(1);
}
System.out.println("");
System.out.println("---------------------------------------------");
System.out.println("Repository latest revision: " + latestRevision);
System.exit(0);
}
Aggregations