Search in sources :

Example 1 with SVNProperties

use of org.tmatesoft.svn.core.SVNProperties in project intellij-community by JetBrains.

the class SvnRollbackTest method setProperty.

private void setProperty(final File file, final String name, final String value) throws SVNException {
    final SVNWCClient client = myVcs.getSvnKitManager().createWCClient();
    client.doSetProperty(file, (path, properties) -> {
        final SVNProperties result = new SVNProperties();
        result.put(name, SVNPropertyValue.create(value));
        return result;
    }, true, SVNDepth.EMPTY, null, null);
}
Also used : SVNProperties(org.tmatesoft.svn.core.SVNProperties) SVNWCClient(org.tmatesoft.svn.core.wc.SVNWCClient)

Example 2 with SVNProperties

use of org.tmatesoft.svn.core.SVNProperties in project Gargoyle by callakrsos.

the class SVNList method list.

/********************************
	 * 작성일 : 2016. 5. 4. 작성자 : KYJ
	 *
	 * path에 속하는 구성정보 조회
	 *
	 * @param path
	 * @param revision
	 * @param exceptionHandler
	 * @return
	 ********************************/
public List<String> list(String path, String revision, Consumer<Exception> exceptionHandler) {
    List<String> resultList = Collections.emptyList();
    try {
        SVNProperties fileProperties = new SVNProperties();
        SVNRepository repository = getRepository();
        Collection<SVNDirEntry> dir = repository.getDir(path, Long.parseLong(revision), fileProperties, new ArrayList<>());
        resultList = dir.stream().map(d -> {
            SVNNodeKind kind = d.getKind();
            if (SVNNodeKind.DIR == kind) {
                return d.getRelativePath().concat("/");
            } else {
                return d.getRelativePath();
            }
        }).collect(Collectors.toList());
    } catch (SVNException e) {
        LOGGER.error(ValueUtil.toString(e));
        if (exceptionHandler != null)
            exceptionHandler.accept(e);
    }
    return resultList;
}
Also used : SVNDirEntry(org.tmatesoft.svn.core.SVNDirEntry) SVNNodeKind(org.tmatesoft.svn.core.SVNNodeKind) SVNProperties(org.tmatesoft.svn.core.SVNProperties) SVNRepository(org.tmatesoft.svn.core.io.SVNRepository) SVNException(org.tmatesoft.svn.core.SVNException)

Example 3 with SVNProperties

use of org.tmatesoft.svn.core.SVNProperties in project intellij-community by JetBrains.

the class SvnRollbackTest method setProperty.

private void setProperty(final File file, final String name, final String value) throws SVNException {
    final SVNWCClient client = myVcs.getSvnKitManager().createWCClient();
    client.doSetProperty(file, (path, properties) -> {
        final SVNProperties result = new SVNProperties();
        result.put(name, SVNPropertyValue.create(value));
        return result;
    }, true, SVNDepth.EMPTY, null, null);
}
Also used : SVNProperties(org.tmatesoft.svn.core.SVNProperties) SVNWCClient(org.tmatesoft.svn.core.wc.SVNWCClient)

Example 4 with SVNProperties

use of org.tmatesoft.svn.core.SVNProperties in project Gargoyle by callakrsos.

the class SVNCat method cat.

/**
	 * @작성자 : KYJ
	 * @작성일 : 2016. 6. 13.
	 * @param path
	 * @param revision
	 * @param encoding
	 * @param exceptionHandler
	 * @return
	 */
public String cat(String path, String revision, String encoding, Consumer<Exception> exceptionHandler) {
    String result = "";
    SVNProperties fileProperties = new SVNProperties();
    try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
        /*
			 * 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.
			 */
        String _path = path;
        try {
            _path = URLDecoder.decode(_path, "UTF-8");
        } catch (Exception e) {
            e.printStackTrace();
        }
        SVNRepository repository = getRepository();
        SVNNodeKind nodeKind = repository.checkPath(_path, -1);
        if (nodeKind == SVNNodeKind.NONE) {
            if (exceptionHandler != null) {
                exceptionHandler.accept(new RuntimeException("There is no entry at '" + getUrl() + "'."));
            } else
                throw new RuntimeException("There is no entry at '" + getUrl() + "'.");
        } else if (nodeKind == SVNNodeKind.DIR) {
            if (exceptionHandler != null) {
                exceptionHandler.accept(new RuntimeException("The entry at '" + getUrl() + "' is a directory while a file was expected."));
            } else
                throw new RuntimeException("The entry at '" + getUrl() + "' is a directory while a file was expected.");
        }
        /*
			 * 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).
			 */
        long parseLong = -1;
        try {
            parseLong = Long.parseLong(revision);
        } catch (NumberFormatException e) {
        }
        repository.getFile(_path, parseLong, fileProperties, baos);
        /*
			 * 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<String> iterator = fileProperties.nameSet().iterator();
        /*
			 * Displays file properties.
			 */
        while (iterator.hasNext()) {
            String propertyName = iterator.next();
            String propertyValue = fileProperties.getStringValue(propertyName);
            LOGGER.debug("File property: " + propertyName + "=" + propertyValue);
        }
        /*
			 * Displays the file contents in the console if the file is a text.
			 */
        if (isTextType) {
            //				try (StringOutputStream out = new StringOutputStream()) {
            //					baos.writeTo(out);
            // out.getString();
            result = baos.toString(encoding);
        //				}
        } else /*
			 * 2017.2.28
			 * binay type은 무거운 데이터를 읽어들일수있는 가능성때문에 여기서 제외시켜놓겠음.
			 */
        if (SVNProperty.isBinaryMimeType(mimeType)) {
            //baos.toString(encoding);
            result = mimeType + " is not support.";
        } else {
            LOGGER.debug("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.");
        }
    } catch (Exception e) {
        LOGGER.error(ValueUtil.toString(e));
        if (exceptionHandler != null)
            exceptionHandler.accept(e);
    }
    return result;
}
Also used : SVNNodeKind(org.tmatesoft.svn.core.SVNNodeKind) RuntimeException(com.sun.star.uno.RuntimeException) SVNProperties(org.tmatesoft.svn.core.SVNProperties) SVNRepository(org.tmatesoft.svn.core.io.SVNRepository) ByteArrayOutputStream(java.io.ByteArrayOutputStream) RuntimeException(com.sun.star.uno.RuntimeException) IOException(java.io.IOException)

Example 5 with SVNProperties

use of org.tmatesoft.svn.core.SVNProperties in project Gargoyle by callakrsos.

the class SVNCommit method getDefaultSVNEditor.

/**
	 * DefaultSVNEditor
	 *
	 * Commit행위 처리를 위한 SVN Low Level API.
	 *
	 * @작성자 : KYJ
	 * @작성일 : 2016. 7. 12.
	 * @param commitMessage
	 *   Commit Message
	 * @return
	 * @throws SVNException
	 */
private ISVNEditor getDefaultSVNEditor(String commitMessage) throws SVNException {
    String convertCommitMessage = getCommitMessage(commitMessage);
    convertCommitMessage = SVNCommitUtil.validateCommitMessage(convertCommitMessage);
    SVNProperties revisionProperties = new SVNProperties();
    revisionProperties.put("exec.ip.addr", getIpAddr());
    revisionProperties.put("exec.client.date", getCurrentDateTime());
    revisionProperties.put("exec.user", getUserId());
    return getRepository().getCommitEditor(convertCommitMessage, null, /*locks*/
    true, /*keepLocks*/
    revisionProperties, null);
}
Also used : SVNProperties(org.tmatesoft.svn.core.SVNProperties)

Aggregations

SVNProperties (org.tmatesoft.svn.core.SVNProperties)8 SVNNodeKind (org.tmatesoft.svn.core.SVNNodeKind)3 SVNRepository (org.tmatesoft.svn.core.io.SVNRepository)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 IOException (java.io.IOException)2 SVNException (org.tmatesoft.svn.core.SVNException)2 SVNWCClient (org.tmatesoft.svn.core.wc.SVNWCClient)2 RuntimeException (com.sun.star.uno.RuntimeException)1 Iterator (java.util.Iterator)1 SVNCommitInfo (org.tmatesoft.svn.core.SVNCommitInfo)1 SVNDirEntry (org.tmatesoft.svn.core.SVNDirEntry)1 ISVNAuthenticationManager (org.tmatesoft.svn.core.auth.ISVNAuthenticationManager)1 SVNCommitClient (org.tmatesoft.svn.core.wc.SVNCommitClient)1 SVNCopyClient (org.tmatesoft.svn.core.wc.SVNCopyClient)1 SVNCopySource (org.tmatesoft.svn.core.wc.SVNCopySource)1