Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
HFTSoftwareProject
DTABackend
Commits
4c5aa346
Commit
4c5aa346
authored
Apr 08, 2024
by
Can
Browse files
SVN+SSH
parent
90e44805
Pipeline
#9151
passed with stage
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/de/hftstuttgart/dtabackend/utils/JGitUtil.java
View file @
4c5aa346
...
@@ -64,24 +64,7 @@ public class JGitUtil {
...
@@ -64,24 +64,7 @@ public class JGitUtil {
cloneCommand
.
call
().
close
();
cloneCommand
.
call
().
close
();
}
}
else
{
else
{
SVNURL
svnUrl
=
SVNURL
.
parseURIDecoded
(
config
.
group
(
1
));
SVNUtil
.
checkoutRepository
(
config
.
group
(
1
),
config
.
group
(
2
),
config
.
group
(
3
),
targetPath
);
final
SvnOperationFactory
svnOperationFactory
=
new
SvnOperationFactory
();
try
{
final
SvnCheckout
checkout
=
svnOperationFactory
.
createCheckout
();
checkout
.
setSingleTarget
(
SvnTarget
.
fromFile
(
checkoutDirectory
));
checkout
.
setSource
(
SvnTarget
.
fromURL
(
svnUrl
));
if
(!
config
.
group
(
2
).
equals
(
"none"
)
&&
!
config
.
group
(
3
).
equals
(
"none"
))
{
LOG
.
debug
(
"Setting credentials"
);
svnOperationFactory
.
setAuthenticationManager
(
new
BasicAuthenticationManager
(
config
.
group
(
2
),
config
.
group
(
3
)));
}
checkout
.
run
();
LOG
.
debug
(
"SVN checkout completed successfully."
);
}
finally
{
svnOperationFactory
.
dispose
();
}
}
}
//if an optional directory parameter was given
//if an optional directory parameter was given
...
@@ -98,8 +81,6 @@ public class JGitUtil {
...
@@ -98,8 +81,6 @@ public class JGitUtil {
catch
(
GitAPIException
e
)
{
catch
(
GitAPIException
e
)
{
LOG
.
error
(
String
.
format
(
"Error while cloning from %s: could not read from Git"
,
config
.
group
(
1
)),
e
);
LOG
.
error
(
String
.
format
(
"Error while cloning from %s: could not read from Git"
,
config
.
group
(
1
)),
e
);
}
}
catch
(
SVNException
e
)
{
LOG
.
error
(
String
.
format
(
"Error while cloning from %s: could not read from Svn"
,
config
.
group
(
1
)),
e
);
}
}
}
}
}
src/main/java/de/hftstuttgart/dtabackend/utils/SVNUtil.java
0 → 100644
View file @
4c5aa346
package
de.hftstuttgart.dtabackend.utils
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.tmatesoft.svn.core.SVNException
;
import
org.tmatesoft.svn.core.SVNURL
;
import
org.tmatesoft.svn.core.auth.BasicAuthenticationManager
;
import
org.tmatesoft.svn.core.auth.ISVNAuthenticationManager
;
import
org.tmatesoft.svn.core.auth.SVNAuthentication
;
import
org.tmatesoft.svn.core.auth.SVNSSHAuthentication
;
import
org.tmatesoft.svn.core.wc.SVNWCUtil
;
import
org.tmatesoft.svn.core.wc2.SvnCheckout
;
import
org.tmatesoft.svn.core.wc2.SvnOperationFactory
;
import
org.tmatesoft.svn.core.wc2.SvnTarget
;
import
java.io.File
;
public
class
SVNUtil
{
private
static
final
Logger
LOG
=
LogManager
.
getLogger
(
SVNUtil
.
class
);
public
static
void
checkoutRepository
(
String
svnUrl
,
String
username
,
String
password
,
String
targetPath
)
{
try
{
SVNURL
url
=
SVNURL
.
parseURIDecoded
(
svnUrl
);
SvnOperationFactory
operationFactory
=
new
SvnOperationFactory
();
SvnCheckout
checkout
=
operationFactory
.
createCheckout
();
checkout
.
setSingleTarget
(
SvnTarget
.
fromFile
(
new
File
(
targetPath
)));
checkout
.
setSource
(
SvnTarget
.
fromURL
(
url
));
String
protocol
=
url
.
getProtocol
();
if
(
protocol
.
equals
(
"https"
))
{
if
(
username
!=
null
&&
password
!=
null
)
{
LOG
.
debug
(
"Setting SVN credentials"
);
operationFactory
.
setAuthenticationManager
(
new
BasicAuthenticationManager
(
username
,
password
));
}
}
else
if
(
protocol
.
equals
(
"svn+ssh"
))
{
LOG
.
debug
(
"Setting credentials for SVN+SSH Authentication"
);
ISVNAuthenticationManager
authManager
=
new
BasicAuthenticationManager
(
new
SVNAuthentication
[]
{
new
SVNSSHAuthentication
(
username
,
password
,
-
1
,
false
)});
//SVNWCUtil.createDefaultAuthenticationManager(username, password);
operationFactory
.
setAuthenticationManager
(
authManager
);
}
checkout
.
run
();
LOG
.
debug
(
"SVN checkout completed successfully."
);
}
catch
(
SVNException
e
)
{
LOG
.
error
(
"Error during SVN checkout"
,
e
);
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment