Search in sources :

Example 91 with SVNException

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);
}
Also used : SVNURL(org.tmatesoft.svn.core.SVNURL) SVNException(org.tmatesoft.svn.core.SVNException)

Example 92 with SVNException

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);
}
Also used : SVNAdminAreaFactory(org.tmatesoft.svn.core.internal.wc.admin.SVNAdminAreaFactory) TreeSet(java.util.TreeSet) Iterator(java.util.Iterator) ISVNAdminAreaFactorySelector(org.tmatesoft.svn.core.internal.wc.admin.ISVNAdminAreaFactorySelector) Collection(java.util.Collection) SVNException(org.tmatesoft.svn.core.SVNException) SubversionFile(org.gluu.oxtrust.model.SubversionFile) File(java.io.File)

Example 93 with SVNException

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;
}
Also used : ILogCommand(com.kyj.scm.manager.core.commons.ILogCommand) Properties(java.util.Properties) Logger(org.slf4j.Logger) URLDecoder(java.net.URLDecoder) SVNException(org.tmatesoft.svn.core.SVNException) Date(java.util.Date) Collection(java.util.Collection) LoggerFactory(org.slf4j.LoggerFactory) ValueUtil(com.kyj.fx.voeditor.visual.util.ValueUtil) File(java.io.File) ArrayList(java.util.ArrayList) Consumer(java.util.function.Consumer) SVNLogClient(org.tmatesoft.svn.core.wc.SVNLogClient) List(java.util.List) SVNRepository(org.tmatesoft.svn.core.io.SVNRepository) SVNLogEntry(org.tmatesoft.svn.core.SVNLogEntry) SVNRevision(org.tmatesoft.svn.core.wc.SVNRevision) ISVNLogEntryHandler(org.tmatesoft.svn.core.ISVNLogEntryHandler) SVNLogEntry(org.tmatesoft.svn.core.SVNLogEntry) ArrayList(java.util.ArrayList) ISVNLogEntryHandler(org.tmatesoft.svn.core.ISVNLogEntryHandler) SVNException(org.tmatesoft.svn.core.SVNException) SVNLogClient(org.tmatesoft.svn.core.wc.SVNLogClient)

Example 94 with SVNException

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);
    }
}
Also used : MouseButton(javafx.scene.input.MouseButton) ListView(javafx.scene.control.ListView) GagoyleDate(com.kyj.fx.voeditor.visual.framework.model.GagoyleDate) MouseEvent(javafx.scene.input.MouseEvent) LoggerFactory(org.slf4j.LoggerFactory) Series(javafx.scene.chart.XYChart.Series) SimpleDateFormat(java.text.SimpleDateFormat) XYChart(javafx.scene.chart.XYChart) LinkedHashMap(java.util.LinkedHashMap) LineChart(javafx.scene.chart.LineChart) ContextMenu(javafx.scene.control.ContextMenu) Map(java.util.Map) FxCollectors(com.kyj.fx.voeditor.visual.util.FxCollectors) Color(javafx.scene.paint.Color) Logger(org.slf4j.Logger) Label(javafx.scene.control.Label) MenuItem(javafx.scene.control.MenuItem) SVNException(org.tmatesoft.svn.core.SVNException) Data(javafx.scene.chart.XYChart.Data) Collection(java.util.Collection) Node(javafx.scene.Node) Set(java.util.Set) MasterSlaveChartComposite(com.kyj.fx.voeditor.visual.component.MasterSlaveChartComposite) BarChart(javafx.scene.chart.BarChart) Collectors(java.util.stream.Collectors) FxUtil(com.kyj.fx.voeditor.visual.util.FxUtil) List(java.util.List) TreeMap(java.util.TreeMap) SVNLogEntry(org.tmatesoft.svn.core.SVNLogEntry) ValueUtil(kyj.Fx.dao.wizard.core.util.ValueUtil) DateUtil(com.kyj.fx.voeditor.visual.util.DateUtil) ObservableList(javafx.collections.ObservableList) BorderPane(javafx.scene.layout.BorderPane) SVNLogEntry(org.tmatesoft.svn.core.SVNLogEntry) GagoyleDate(com.kyj.fx.voeditor.visual.framework.model.GagoyleDate) TreeMap(java.util.TreeMap) LinkedHashMap(java.util.LinkedHashMap) Series(javafx.scene.chart.XYChart.Series) ObservableList(javafx.collections.ObservableList) BarChart(javafx.scene.chart.BarChart) LineChart(javafx.scene.chart.LineChart)

Example 95 with SVNException

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);
}
Also used : SVNNodeKind(org.tmatesoft.svn.core.SVNNodeKind) ISVNAuthenticationManager(org.tmatesoft.svn.core.auth.ISVNAuthenticationManager) SVNProperties(org.tmatesoft.svn.core.SVNProperties) Iterator(java.util.Iterator) SVNRepository(org.tmatesoft.svn.core.io.SVNRepository) SVNException(org.tmatesoft.svn.core.SVNException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException)

Aggregations

SVNException (org.tmatesoft.svn.core.SVNException)95 File (java.io.File)37 SVNURL (org.tmatesoft.svn.core.SVNURL)37 VcsException (com.intellij.openapi.vcs.VcsException)18 SvnBindException (org.jetbrains.idea.svn.commandLine.SvnBindException)14 SVNConfigFile (org.tmatesoft.svn.core.internal.wc.SVNConfigFile)14 IOException (java.io.IOException)8 ArrayList (java.util.ArrayList)8 Collection (java.util.Collection)8 List (java.util.List)8 VirtualFile (com.intellij.openapi.vfs.VirtualFile)7 DefaultSVNOptions (org.tmatesoft.svn.core.internal.wc.DefaultSVNOptions)7 SVNRepository (org.tmatesoft.svn.core.io.SVNRepository)7 SVNRevision (org.tmatesoft.svn.core.wc.SVNRevision)7 Date (java.util.Date)6 NotNull (org.jetbrains.annotations.NotNull)6 SVNCancelException (org.tmatesoft.svn.core.SVNCancelException)6 SVNLogEntry (org.tmatesoft.svn.core.SVNLogEntry)6 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)5 ByteArrayInputStream (java.io.ByteArrayInputStream)5