コード例 #1
0
 public void validate(Form<?> form) {
   String commonName = this.commonNameTextField.getInput();
   if (commonName != null) {
     commonName = commonName.toLowerCase();
     if (commonNameTextField.getModelObject() != null
         && commonName.equals(commonNameTextField.getModelObject().toLowerCase())) return;
     for (TransferCapability transferCapability :
         this.applicationEntity.getTransferCapabilities()) {
       if (transferCapability.getCommonName() != null
           && commonName.equals(transferCapability.getCommonName().toLowerCase()))
         commonNameTextField.error(
             new StringResourceModel("TransferCapabilityValidator.commonName.invalid", form, null)
                 .getObject());
     }
   }
   String sopClass = this.sopClassTextField.getInput();
   String role = this.roleDropDown.getInput().equals("0") ? "SCP" : "SCU";
   if (sopClass.equals(sopClassTextField.getModelObject())
       && role.equals(roleDropDown.getModelObject().name())) return;
   for (TransferCapability transferCapability : this.applicationEntity.getTransferCapabilities()) {
     if (sopClass.equals(transferCapability.getSopClass())
         && role.equals(transferCapability.getRole().name()))
       sopClassTextField.error(
           new StringResourceModel("TransferCapabilityValidator.sopClass-role.invalid", form, null)
               .getObject());
   }
 }
コード例 #2
0
 public void updateChoices(boolean reportError, Form<?> form) {
   final String repoUriStr = repositoryUriModel.getObject();
   if (REPOSITORY.sample != null && REPOSITORY.sample.equals(repoUriStr)) {
     return;
   }
   List<String> branchNames = new ArrayList<>();
   if (repoUriStr != null) {
     try {
       RepositoryManager manager = this.manager.get();
       URI repoURI = new URI(repoUriStr);
       RepositoryResolver resolver = RepositoryResolver.lookup(repoURI);
       String repoName = resolver.getName(repoURI);
       RepositoryInfo repoInfo = manager.getByRepoName(repoName);
       String repoId = repoInfo.getId();
       List<Ref> branchRefs = manager.listBranches(repoId);
       for (Ref branch : branchRefs) {
         branchNames.add(branch.localName());
       }
     } catch (IOException | URISyntaxException e) {
       if (reportError) {
         form.error("Could not list branches: " + e.getMessage());
       }
       branchNames = new ArrayList<String>();
     }
     String current = (String) choice.getModelObject();
     if (current != null && !branchNames.contains(current)) {
       branchNames.add(0, current);
     }
   }
   choice.setChoices(branchNames);
 }