Advertisement
Guest User

Untitled

a guest
May 10th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.58 KB | None | 0 0
  1.         FSRepositoryFactory.setup();
  2.  
  3.         final File repoPath = new File(System.getProperty("java.io.tmpdir", "/tmp"), "repos");
  4.         SVNFileUtil.deleteAll(repoPath, true);
  5.         final SVNURL repoURL = FSRepositoryFactory.createLocalRepository(repoPath, null, false, false, false, false);
  6.         System.out.println("Repository created at " + repoPath + ", using " + repoURL + " as repository root URL");
  7.         System.out.println();
  8.  
  9.         final String userName = "foo";
  10.         final String userPassword = "bar";
  11.  
  12.         final SVNRepository repository = SVNRepositoryFactory.create(repoURL);
  13.         final ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(userName, userPassword);
  14.         repository.setAuthenticationManager(authManager);
  15.  
  16.         final String path = "file";
  17.         final byte[] data = "This is a new file".getBytes();
  18.  
  19.         final ISVNEditor editor = repository.getCommitEditor("log message", null);
  20.        
  21.         editor.openRoot(-1);
  22.         editor.changeFileProperty(path, SVNProperty.MIME_TYPE, SVNPropertyValue.create("text/xml"));
  23.         editor.addFile(path, null, -1);
  24.         editor.applyTextDelta(path, null);
  25.         final SVNDeltaGenerator deltaGenerator = new SVNDeltaGenerator();
  26.         final String checksum = deltaGenerator.sendDelta(path, new ByteArrayInputStream(data), editor, true);
  27.         editor.closeFile(path, checksum);
  28.         editor.closeDir();
  29.         final SVNCommitInfo commitInfo = editor.closeEdit();
  30.         System.out.println("commit info: " + commitInfo.toString());
  31.         System.out.println();
  32.  
  33.         final SVNClientManager manager = SVNClientManager.newInstance(SVNWCUtil.createDefaultOptions(true), authManager);
  34.         final SVNLogClient logClient = manager.getLogClient();
  35.         System.out.println("Running log on " + repoURL);
  36.         System.out.println();
  37.         logClient.doLog(repoURL, new String[]{path}, SVNRevision.UNDEFINED, SVNRevision.create(0), SVNRevision.HEAD, false, true, -1, new ISVNLogEntryHandler(){
  38.             public void handleLogEntry(SVNLogEntry logEntry) throws SVNException {
  39.                 System.out.println(logEntry);
  40.             }
  41.         });
  42.         System.out.println();        
  43.  
  44.         final SVNWCClient wcClient = manager.getWCClient();
  45.         final SVNURL fileURL = repoURL.appendPath(path, false);
  46.         final SVNPropertyData propData = wcClient.doGetProperty(fileURL, SVNProperty.MIME_TYPE, SVNRevision.HEAD, SVNRevision.HEAD);
  47.         System.out.println(SVNProperty.MIME_TYPE + " property on " + fileURL + " is " + propData.getValue());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement