Exemple #1
0
 /**
  * Finds all WSDL artifacts on the registry.
  *
  * @return all WSDL artifacts on the registry.
  * @throws GovernanceException if the operation failed.
  */
 public Wsdl[] getAllWsdls() throws GovernanceException {
   List<String> wsdlPaths =
       Arrays.asList(
           GovernanceUtils.getResultPaths(registry, GovernanceConstants.WSDL_MEDIA_TYPE));
   Collections.sort(
       wsdlPaths,
       new Comparator<String>() {
         public int compare(String o1, String o2) {
           // First order by name
           int result =
               RegistryUtils.getResourceName(o1)
                   .compareToIgnoreCase(RegistryUtils.getResourceName(o2));
           if (result != 0) {
             return result;
           }
           // Then order by namespace
           return o1.compareToIgnoreCase(o2);
         }
       });
   List<Wsdl> wsdls = new ArrayList<Wsdl>();
   for (String wsdlPath : wsdlPaths) {
     GovernanceArtifact artifact =
         GovernanceUtils.retrieveGovernanceArtifactByPath(registry, wsdlPath);
     wsdls.add((Wsdl) artifact);
   }
   return wsdls.toArray(new Wsdl[wsdls.size()]);
 }
  @Paginate("getPaginatedGovernanceArtifacts")
  public List<String> getPaginatedGovernanceArtifacts() throws GovernanceException {
    List<String> paths = Arrays.asList(GovernanceUtils.getResultPaths(registry, mediaType));
    Collections.sort(
        paths,
        new Comparator<String>() {
          public int compare(String o1, String o2) {
            Long l1 = -1l;
            Long l2 = -1l;

            String temp1 = RegistryUtils.getParentPath(o1);
            String temp2 = RegistryUtils.getParentPath(o2);
            try {
              l1 = Long.parseLong(RegistryUtils.getResourceName(temp1));
              l2 = Long.parseLong(RegistryUtils.getResourceName(temp2));
            } catch (NumberFormatException ignore) {

            }

            // First order by name
            int result =
                RegistryUtils.getResourceName(temp1)
                    .compareToIgnoreCase(RegistryUtils.getResourceName(temp2));
            if (result != 0) {
              return result;
            }
            // Then order by namespace
            result = temp1.compareToIgnoreCase(temp2);
            if (result != 0) {
              return result;
            }
            // Finally by version
            return l2.compareTo(l1);
          }
        });
    return paths;
  }