Search in sources :

Example 6 with JavaSVNManager

use of com.kyj.scm.manager.svn.java.JavaSVNManager in project Gargoyle by callakrsos.

the class SVNInitLoader method load.

@Override
public <T extends SVNItem> List<T> load() {
    String jsonArray = ResourceLoader.getInstance().get(ResourceLoader.SVN_REPOSITORIES);
    if (jsonArray == null || jsonArray.length() == 0)
        return null;
    JSONArray parse = null;
    try {
        parse = (JSONArray) new JSONParser().parse(jsonArray);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    List<SVNRepository> repositorys = new ArrayList<>();
    int size = parse.size();
    for (int i = 0; i < size; i++) {
        Object obj = parse.get(i);
        JSONObject jsonObject = (JSONObject) obj;
        Object url = jsonObject.get(SVNTreeView.SVN_URL);
        Object id = jsonObject.get(SVNTreeView.SVN_USER_ID);
        Object pass = jsonObject.get(SVNTreeView.SVN_USER_PASS);
        if (url == null)
            continue;
        Properties properties = new Properties();
        properties.put(SVNTreeView.SVN_URL, url.toString());
        if (id != null && !id.toString().isEmpty())
            properties.put(SVNTreeView.SVN_USER_ID, id.toString());
        if (pass != null && !pass.toString().isEmpty()) {
            try {
                properties.put(SVNTreeView.SVN_USER_PASS, EncrypUtil.decryp(pass.toString()));
            } catch (Exception e) {
                properties.put(SVNTreeView.SVN_USER_PASS, pass.toString());
                ValueUtil.toString(e);
            }
        }
        JavaSVNManager manager = new JavaSVNManager(properties);
        SVNRepository svnRepository = new SVNRepository("", url.toString(), manager);
        repositorys.add(svnRepository);
    }
    return (List<T>) repositorys;
}
Also used : JSONArray(org.json.simple.JSONArray) ArrayList(java.util.ArrayList) Properties(java.util.Properties) ParseException(org.json.simple.parser.ParseException) JavaSVNManager(com.kyj.scm.manager.svn.java.JavaSVNManager) JSONObject(org.json.simple.JSONObject) JSONParser(org.json.simple.parser.JSONParser) SVNRepository(com.kyj.fx.voeditor.visual.component.scm.SVNRepository) JSONObject(org.json.simple.JSONObject) ArrayList(java.util.ArrayList) List(java.util.List) ParseException(org.json.simple.parser.ParseException)

Aggregations

JavaSVNManager (com.kyj.scm.manager.svn.java.JavaSVNManager)6 Properties (java.util.Properties)6 Scene (javafx.scene.Scene)3 IOException (java.io.IOException)2 FXMLLoader (javafx.fxml.FXMLLoader)2 BorderPane (javafx.scene.layout.BorderPane)2 Stage (javafx.stage.Stage)2 FxSVNHistoryDataSupplier (com.kyj.fx.voeditor.visual.component.scm.FxSVNHistoryDataSupplier)1 SVNRepository (com.kyj.fx.voeditor.visual.component.scm.SVNRepository)1 ScmCommitComposite (com.kyj.fx.voeditor.visual.component.scm.ScmCommitComposite)1 SvnChagnedCodeComposite (com.kyj.fx.voeditor.visual.component.scm.SvnChagnedCodeComposite)1 ProxyInitializable (com.kyj.fx.voeditor.visual.main.initalize.ProxyInitializable)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Tab (javafx.scene.control.Tab)1 TabPane (javafx.scene.control.TabPane)1 JSONArray (org.json.simple.JSONArray)1 JSONObject (org.json.simple.JSONObject)1 JSONParser (org.json.simple.parser.JSONParser)1 ParseException (org.json.simple.parser.ParseException)1