public void verifyWSDL() throws GovernanceException {
   WsdlManager wsdlManager = new WsdlManager(governance);
   Wsdl[] wsdls = wsdlManager.getAllWsdls();
   boolean resourceFound = false;
   for (Wsdl wsdl : wsdls) {
     if (wsdl.getQName().getLocalPart().equals("wsdl_with_EncrOnlyAnonymous.wsdl")) {
       resourceFound = true;
     }
   }
   Assert.assertTrue(resourceFound);
 }
Exemplo n.º 2
0
  /**
   * Adds the given WSDL artifact to the registry.
   *
   * @param wsdl the WSDL artifact.
   * @throws GovernanceException if the operation failed.
   */
  public void addWsdl(Wsdl wsdl) throws GovernanceException {
    boolean succeeded = false;
    try {
      registry.beginTransaction();
      String url = wsdl.getUrl();
      Resource wsdlResource = registry.newResource();
      wsdlResource.setMediaType(GovernanceConstants.WSDL_MEDIA_TYPE);

      // setting the wsdl content
      setContent(wsdl, wsdlResource);
      wsdlResource.setUUID(wsdl.getId());

      String tmpPath;
      if (wsdl.getQName() != null) {
        tmpPath = "/" + wsdl.getQName().getLocalPart();
      } else if (url != null && !url.startsWith("name://")) {
        tmpPath = RegistryUtils.getResourceName(new URL(url).getFile().replace("~", ""));
      } else if (url != null) {
        tmpPath = url.substring("name://".length());
      } else {
        tmpPath = wsdl.getId() + ".wsdl";
      }
      // OK this is a hack to get the UUID of the newly added artifact. This needs to be fixed
      // properly with the fix for UUID support at Kernel-level - Janaka.
      //            Resource resource;
      if (url == null || url.startsWith("name://")) {
        //                resource = registry.get(registry.put("/" + tmpPath, wsdlResource));
        registry.put("/" + tmpPath, wsdlResource);
      } else {
        //                resource = registry.get(registry.importResource(tmpPath, url,
        // wsdlResource));
        registry.importResource(tmpPath, url, wsdlResource);
      }
      //            wsdl.setId(resource.getUUID());
      wsdl.updatePath();
      //    wsdl.loadWsdlDetails();
      succeeded = true;
    } catch (RegistryException e) {
      String msg = "Error in adding the wsdl. wsdl id: " + wsdl.getId() + ".";
      log.error(msg, e);
      throw new GovernanceException(msg, e);
    } catch (MalformedURLException e) {
      String msg = "Malformed policy url provided. url: " + wsdl.getUrl() + ".";
      log.error(msg, e);
      throw new GovernanceException(msg, e);
    } finally {
      if (succeeded) {
        try {
          registry.commitTransaction();
        } catch (RegistryException e) {
          String msg =
              "Error in committing transactions. Add wsdl failed: wsdl id: "
                  + wsdl.getId()
                  + ", path: "
                  + wsdl.getPath()
                  + ".";
          log.error(msg, e);
        }
      } else {
        try {
          registry.rollbackTransaction();
        } catch (RegistryException e) {
          String msg =
              "Error in rolling back transactions. Add wsdl failed: wsdl id: "
                  + wsdl.getId()
                  + ", path: "
                  + wsdl.getPath()
                  + ".";
          log.error(msg, e);
        }
      }
    }
  }