Project

General

Profile

« Previous | Next » 

Revision c01d683c

Added by Cherian Mathew over 9 years ago

added sanity checks for delimiters

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/PreferencesUtil.java
670 670
        StringBuilder sb = new StringBuilder();
671 671
        for(MetadataRepositoryElement p2Repo : p2Repos) {
672 672
            sb.append(P2_REPOSITORIES_DELIM);
673
            sb.append(p2Repo.getName());
673
            if(p2Repo.getName() == null || p2Repo.getName().isEmpty()) {
674
                sb.append("-");
675
            } else {
676
                sb.append(p2Repo.getName());
677
            }
674 678
            sb.append(P2_REPOSITORY_FIELDS_DELIM);
675 679
            sb.append(p2Repo.getLocation().toString());
676 680
            sb.append(P2_REPOSITORY_FIELDS_DELIM);
......
690 694
        String p2ReposPref =  getPreferenceStore().getString(P2_REPOSITORY_LIST);
691 695
        if(p2ReposPref != null && !p2ReposPref.isEmpty()) {
692 696
            StringTokenizer p2ReposPrefST = new StringTokenizer(p2ReposPref,P2_REPOSITORIES_DELIM);
697

  
693 698
            while(p2ReposPrefST.hasMoreTokens()) {
694 699
                String p2RepoStr = p2ReposPrefST.nextToken();
695 700
                StringTokenizer p2ReposStrST = new StringTokenizer(p2RepoStr,P2_REPOSITORY_FIELDS_DELIM);
696
                String nickname = p2ReposStrST.nextToken();
697
                URI uri = null;
698
                try {
699
                    uri = new URI(p2ReposStrST.nextToken());
700
                } catch (URISyntaxException e) {
701
                    continue;
701
                if(p2ReposStrST.countTokens()==3) {
702
                    String nickname = p2ReposStrST.nextToken();
703
                    URI uri = null;
704
                    try {
705
                        uri = new URI(p2ReposStrST.nextToken());
706
                    } catch (URISyntaxException e) {
707
                        continue;
708
                    }
709
                    boolean enabled = Boolean.parseBoolean(p2ReposStrST.nextToken());
710
                    MetadataRepositoryElement mre = new MetadataRepositoryElement(null, uri, true);
711
                    mre.setNickname(nickname);
712
                    mre.setEnabled(enabled);
713
                    p2Repos.add(mre);
702 714
                }
703
                boolean enabled = Boolean.parseBoolean(p2ReposStrST.nextToken());
704
                MetadataRepositoryElement mre = new MetadataRepositoryElement(null, uri, true);
705
                mre.setNickname(nickname);
706
                mre.setEnabled(enabled);
707
                p2Repos.add(mre);
708 715
            }
709 716
        }
710 717

  

Also available in: Unified diff