Search in sources :

Example 1 with SVNRepository

use of com.kyj.fx.voeditor.visual.component.scm.SVNRepository 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

SVNRepository (com.kyj.fx.voeditor.visual.component.scm.SVNRepository)1 JavaSVNManager (com.kyj.scm.manager.svn.java.JavaSVNManager)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Properties (java.util.Properties)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