public void testResourcePropertyVersioning() throws Exception {

    Resource r1 = registry.newResource();
    r1.setContent("content 1");
    r1.addProperty("p1", "v1");
    registry.put("/v4/r1", r1);

    Resource r1v2 = registry.get("/v4/r1");
    r1v2.addProperty("p2", "v2");
    registry.put("/v4/r1", r1v2);
    registry.put("/v4/r1", r1v2);

    String[] r1Versions = registry.getVersions("/v4/r1");

    Resource r1vv1 = registry.get(r1Versions[1]);

    assertEquals(
        "r1's first version should contain a property p1 with value v1",
        r1vv1.getProperty("p1"),
        "v1");

    Resource r1vv2 = registry.get(r1Versions[0]);

    assertEquals(
        "r1's second version should contain a property p1 with value v1",
        r1vv2.getProperty("p1"),
        "v1");

    assertEquals(
        "r1's second version should contain a property p2 with value v2",
        r1vv2.getProperty("p2"),
        "v2");
  }
示例#2
0
  public void testBackwardCompatibility() throws RegistryException {
    Registry rootRegistry = embeddedRegistryService.getSystemRegistry();
    Resource r1 = rootRegistry.newResource();
    r1.setContent("r1 content");
    rootRegistry.put("/test/comments/r1", r1);

    rootRegistry.addComment(
        "/test/comments/r1", new Comment("backward-compatibility1 on this resource :)"));
    rootRegistry.addComment(
        "/test/comments/r1", new Comment("backward-compatibility2 on this resource :)"));

    String sql =
        "SELECT REG_COMMENT_ID FROM REG_COMMENT C, REG_RESOURCE_COMMENT RC "
            + "WHERE C.REG_COMMENT_TEXT LIKE ? AND C.REG_ID=RC.REG_COMMENT_ID";

    Resource queryR = rootRegistry.newResource();
    queryR.setMediaType(RegistryConstants.SQL_QUERY_MEDIA_TYPE);
    queryR.addProperty(
        RegistryConstants.RESULT_TYPE_PROPERTY_NAME, RegistryConstants.COMMENTS_RESULT_TYPE);
    rootRegistry.put("/beep/x", queryR);
    Map<String, String> params = new HashMap<String, String>();
    params.put("query", sql);
    params.put(RegistryConstants.RESULT_TYPE_PROPERTY_NAME, RegistryConstants.COMMENTS_RESULT_TYPE);
    params.put("1", "backward-compatibility1%");
    Collection qResults = rootRegistry.executeQuery("/beep/x", params);

    String[] qPaths = (String[]) qResults.getContent();

    assertEquals("Query result count should be 1", qPaths.length, 1);
  }
示例#3
0
  private void multiValuedProperties() {
    String path = "/propTest/r1";
    Resource r1 = registry.newResource();

    try {
      r1.setContent("Some content for r1");

      r1.addProperty("p1", "p1v1");
      r1.addProperty("p1", "p1v2");
      registry.put(path, r1);

      Resource r1b = registry.get(path);
      List propValues = r1b.getPropertyValues("p1");

      assertTrue(
          "Property p1 of /propTest/r1 should contain the value p1v1", propValues.contains("p1v1"));

      assertTrue(
          "Property p1 of /propTest/r1 should contain the value p1v2", propValues.contains("p1v2"));

      deleteResources("/propTest");
      log.info("multiValuedProperties - Passed");
    } catch (RegistryException e) {

      log.error("multiValuedProperties RegistryException thrown :" + e.getMessage());
      Assert.fail("multiValuedProperties RegistryException thrown :" + e.getMessage());
    }
  }
示例#4
0
  private void editingMultivaluedProperties() {
    String path = "/props/t3/r1";
    Resource r1 = registry.newResource();
    try {
      r1.setContent("r1 content");

      r1.addProperty("p1", "v1");
      r1.addProperty("p1", "v2");
      r1.setProperty("test", "value2");
      r1.setProperty("test2", "value2");
      registry.put(path, r1);

      Resource r1e1 = registry.get(path);
      r1e1.setContent("r1 content");
      r1e1.editPropertyValue("p1", "v1", "v3");

      registry.put(path, r1e1);

      Resource r1e2 = registry.get(path);
      assertFalse("Property is not edited.", r1e2.getPropertyValues("p1").contains("v1"));
      assertTrue("Property is not edited.", r1e2.getPropertyValues("p1").contains("v3"));
      assertTrue("Wrong property is removed.", r1e2.getPropertyValues("p1").contains("v2"));

      deleteResources("/props");
      log.info("editingMultivaluedProperties- Passed");
    } catch (RegistryException e) {

      log.error("editingMultivaluedProperties RegistryException thrown :" + e.getMessage());
      Assert.fail("editingMultivaluedProperties RegistryException thrown :" + e.getMessage());
    }
  }
示例#5
0
 /**
  * custom query for all the tags search is set as a resource and saved at the config
  * registry.space
  */
 private boolean setTagSearchQuery() {
   if (log.isDebugEnabled()) {
     log.debug("tag search customs query is set");
   }
   String tagsQueryPath =
       RegistryConstants.CONFIG_REGISTRY_BASE_PATH
           + RegistryConstants.QUERIES_COLLECTION_PATH
           + "/tags";
   try {
     if (!super.getUserRegistry().resourceExists(tagsQueryPath)) {
       // set-up query for tag-search.
       Resource resource = super.getUserRegistry().newResource();
       resource.setContent(
           "SELECT RT.REG_TAG_ID FROM REG_RESOURCE_TAG RT ORDER BY " + "RT.REG_TAG_ID");
       resource.setMediaType(RegistryConstants.SQL_QUERY_MEDIA_TYPE);
       resource.addProperty(
           RegistryConstants.RESULT_TYPE_PROPERTY_NAME, RegistryConstants.TAGS_RESULT_TYPE);
       super.getUserRegistry().put(tagsQueryPath, resource);
     }
     return true;
   } catch (RegistryException e) {
     log.error(e.getCause(), e);
     return false;
   }
 }
示例#6
0
  public void testDefaultQuery() throws Exception {
    Resource r1 = registry.newResource();
    String r1Content = "this is r1 content";
    r1.setContent(r1Content.getBytes());
    r1.setDescription("production ready.");
    String r1Path = "/c3/r1";
    registry.put(r1Path, r1);

    Resource r2 = registry.newResource();
    String r2Content = "content for r2 :)";
    r2.setContent(r2Content);
    r2.setDescription("ready for production use.");
    String r2Path = "/c3/r2";
    registry.put(r2Path, r2);

    Resource r3 = registry.newResource();
    String r3Content = "content for r3 :)";
    r3.setContent(r3Content);
    r3.setDescription("only for government use.");
    String r3Path = "/c3/r3";
    registry.put(r3Path, r3);

    registry.applyTag("/c3/r1", "java");
    registry.applyTag("/c3/r2", "jsp");
    registry.applyTag("/c3/r3", "ajax");

    String sql1 =
        "SELECT RT.REG_TAG_ID FROM REG_RESOURCE_TAG RT, REG_RESOURCE R "
            + "WHERE (R.REG_VERSION=RT.REG_VERSION OR "
            + "(R.REG_PATH_ID=RT.REG_PATH_ID AND R.REG_NAME=RT.REG_RESOURCE_NAME)) "
            + "AND R.REG_DESCRIPTION LIKE ? ORDER BY RT.REG_TAG_ID";

    Resource q1 = systemRegistry.newResource();
    q1.setContent(sql1);
    q1.setMediaType(RegistryConstants.SQL_QUERY_MEDIA_TYPE);
    q1.addProperty(RegistryConstants.RESULT_TYPE_PROPERTY_NAME, RegistryConstants.TAGS_RESULT_TYPE);
    systemRegistry.put("/qs/q3", q1);

    Map<String, String> parameters = new HashMap<String, String>();
    parameters.put("1", "%production%");
    Collection result = registry.executeQuery("/qs/q3", parameters);

    String[] tagPaths = result.getChildren();
    assertEquals("There should be two matching tags.", tagPaths.length, 2);

    Resource tag2 = registry.get(tagPaths[0]);
    assertEquals("First matching tag should be 'java'", (String) tag2.getContent(), "java");

    Resource tag1 = registry.get(tagPaths[1]);
    assertEquals("Second matching tag should be 'jsp'", (String) tag1.getContent(), "jsp");
  }
 private void addService(String nameSpace, String serviceName) throws RegistryException {
   ServiceManager serviceManager = new ServiceManager(governance);
   Service service;
   service = serviceManager.newService(new QName(nameSpace, serviceName));
   serviceManager.addService(service);
   for (String serviceId : serviceManager.getAllServiceIds()) {
     service = serviceManager.getService(serviceId);
     if (service.getPath().endsWith(serviceName)) {
       Resource resource = governance.get(service.getPath());
       resource.addProperty("x", "10");
       governance.put(service.getPath(), resource);
     }
   }
 }
 private void addSchema() throws IOException, RegistryException {
   SchemaManager schemaManager = new SchemaManager(governance);
   String schemaFilePath =
       ProductConstant.getResourceLocations(ProductConstant.GREG_SERVER_NAME)
           + File.separator
           + "schema"
           + File.separator;
   Schema schema =
       schemaManager.newSchema(
           FileManager.readFile(schemaFilePath + "Person.xsd").getBytes(), "Person.xsd");
   schemaManager.addSchema(schema);
   schema = schemaManager.getSchema(schema.getId());
   Resource resource = governance.get(schema.getPath());
   resource.addProperty("z", "30");
   governance.put(schema.getPath(), resource);
 }
 private void addPolicy() throws RegistryException, IOException {
   PolicyManager policyManager = new PolicyManager(governance);
   String policyFilePath =
       ProductConstant.getResourceLocations(ProductConstant.GREG_SERVER_NAME)
           + File.separator
           + "policy"
           + File.separator;
   Policy policy =
       policyManager.newPolicy(
           FileManager.readFile(policyFilePath + "UTPolicy.xml").getBytes(), "UTPolicy.xml");
   policyManager.addPolicy(policy);
   policy = policyManager.getPolicy(policy.getId());
   Resource resource = governance.get(policy.getPath());
   resource.addProperty("abcxyzpqr", "40");
   governance.put(policy.getPath(), resource);
 }
 private void addWSDL() throws IOException, RegistryException {
   WsdlManager wsdlManager = new WsdlManager(governance);
   Wsdl wsdl;
   String wsdlFilePath =
       ProductConstant.getResourceLocations(ProductConstant.GREG_SERVER_NAME)
           + File.separator
           + "wsdl"
           + File.separator;
   wsdl =
       wsdlManager.newWsdl(
           FileManager.readFile(wsdlFilePath + "echo.wsdl").getBytes(), "echo.wsdl");
   wsdlManager.addWsdl(wsdl);
   wsdl = wsdlManager.getWsdl(wsdl.getId());
   Resource resource = governance.get(wsdl.getPath());
   resource.addProperty("y", "20");
   governance.put(wsdl.getPath(), resource);
 }
示例#11
0
  private void rootLevelProperties() {
    Resource root;
    try {
      root = registry.get("/");
      root.addProperty("p1", "v1");
      registry.put("/", root);

      Resource rootb = registry.get("/");
      assertEquals(
          "Root should have a property named p1 with value v1", rootb.getProperty("p1"), "v1");
      log.info("rootLevelProperties() -Passed");

    } catch (RegistryException e) {
      log.error("rootLevelProperties RegistryException thrown :" + e.getMessage());
      Assert.fail("rootLevelProperties RegistryException thrown :" + e.getMessage());
    }
  }
示例#12
0
  public void testWithoutTableParamsQuery() throws Exception {
    Resource r1 = registry.newResource();
    String r1Content = "this is r1 content";
    r1.setContent(r1Content.getBytes());
    r1.setDescription("production ready.");
    String r1Path = "/c1/r1";
    registry.put(r1Path, r1);

    Resource r2 = registry.newResource();
    String r2Content = "content for r2 :)";
    r2.setContent(r2Content);
    r2.setDescription("ready for production use.");
    String r2Path = "/c2/r2";
    registry.put(r2Path, r2);

    Resource r3 = registry.newResource();
    String r3Content = "content for r3 :)";
    r3.setContent(r3Content);
    r3.setDescription("only for government use.");
    String r3Path = "/c2/r3";
    registry.put(r3Path, r3);

    String sql1 =
        "SELECT REG_PATH_ID, REG_NAME FROM REG_RESOURCE, " + "REG_TAG WHERE REG_DESCRIPTION LIKE ?";
    Resource q1 = systemRegistry.newResource();
    q1.setContent(sql1);
    q1.setMediaType(RegistryConstants.SQL_QUERY_MEDIA_TYPE);
    q1.addProperty(
        RegistryConstants.RESULT_TYPE_PROPERTY_NAME, RegistryConstants.RESOURCES_RESULT_TYPE);
    systemRegistry.put("/qs/q1", q1);

    Map<String, String> parameters = new HashMap<String, String>();
    parameters.put("1", "%production%");
    Resource result = registry.executeQuery("/qs/q1", parameters);

    assertTrue(
        "Search with result type Resource should return a directory.",
        result instanceof org.wso2.carbon.registry.core.Collection);

    List<String> matchingPaths = new ArrayList<String>();
    String[] paths = (String[]) result.getContent();
    matchingPaths.addAll(Arrays.asList(paths));

    assertTrue("Path /c1/r1 should be in the results.", matchingPaths.contains("/c1/r1"));
    assertTrue("Path /c2/r2 should be in the results.", matchingPaths.contains("/c2/r2"));
  }
  /**
   * Saves a swagger document in the registry.
   *
   * @param contentStream resource content.
   * @param path resource path.
   * @param documentVersion version of the swagger document.
   * @throws RegistryException If fails to add the swagger document to registry.
   */
  private boolean addSwaggerDocumentToRegistry(
      ByteArrayOutputStream contentStream, String path, String documentVersion)
      throws RegistryException {
    Resource resource;
    /*
    Checks if a resource is already exists in the given path.
    If exists,
    	Compare resource contents and if updated, updates the document, if not skip the updating process
    If not exists,
    	Creates a new resource and add to the resource path.
     */
    if (registry.resourceExists(path)) {
      resource = registry.get(path);
      Object resourceContentObj = resource.getContent();
      String resourceContent;
      if (resourceContentObj instanceof String) {
        resourceContent = (String) resourceContentObj;
        resource.setContent(RegistryUtils.encodeString(resourceContent));
      } else if (resourceContentObj instanceof byte[]) {
        resourceContent = RegistryUtils.decodeBytes((byte[]) resourceContentObj);
      } else {
        throw new RegistryException(CommonConstants.INVALID_CONTENT);
      }
      if (resourceContent.equals(contentStream.toString())) {
        log.info("Old content is same as the new content. Skipping the put action.");
        return false;
      }
    } else {
      // If a resource does not exist in the given path.
      resource = new ResourceImpl();
    }

    String resourceId =
        (resource.getUUID() == null) ? UUID.randomUUID().toString() : resource.getUUID();

    resource.setUUID(resourceId);
    resource.setMediaType(CommonConstants.SWAGGER_MEDIA_TYPE);
    resource.setContent(contentStream.toByteArray());
    resource.addProperty(RegistryConstants.VERSION_PARAMETER_NAME, documentVersion);
    CommonUtil.copyProperties(this.requestContext.getResource(), resource);
    registry.put(path, resource);

    return true;
  }
示例#14
0
  public void testWithoutWhereQuery() throws Exception {
    Resource r1 = registry.newResource();
    String r1Content = "this is r1 content";
    r1.setContent(r1Content.getBytes());
    r1.setDescription("production ready.");
    String r1Path = "/c1/r1";
    registry.put(r1Path, r1);

    Resource r2 = registry.newResource();
    String r2Content = "content for r2 :)";
    r2.setContent(r2Content);
    r2.setDescription("ready for production use.");
    String r2Path = "/c2/r2";
    registry.put(r2Path, r2);

    Resource r3 = registry.newResource();
    String r3Content = "content for r3 :)";
    r3.setContent(r3Content);
    r3.setDescription("only for government use.");
    String r3Path = "/c2/r3";
    registry.put(r3Path, r3);

    String sql1 = "SELECT REG_PATH_ID, REG_NAME FROM REG_RESOURCE, REG_TAG";
    Resource q1 = systemRegistry.newResource();
    q1.setContent(sql1);
    q1.setMediaType(RegistryConstants.SQL_QUERY_MEDIA_TYPE);
    q1.addProperty(
        RegistryConstants.RESULT_TYPE_PROPERTY_NAME, RegistryConstants.RESOURCES_RESULT_TYPE);
    systemRegistry.put("/qs/q1", q1);

    Map parameters = new HashMap();
    Resource result = registry.executeQuery("/qs/q1", parameters);

    assertTrue(
        "Search with result type Resource should return a directory.",
        result instanceof org.wso2.carbon.registry.core.Collection);

    String[] paths = (String[]) result.getContent();
    assertTrue("Should return all the resources", paths.length >= 3);
  }
  /**
   * Persist the keystore in the gov.registry
   *
   * @param keyStore created Keystore of the tenant
   * @param PKCertificate pub. key of the tenant
   * @throws KeyStoreMgtException Exception when storing the keystore in the registry
   */
  private void persistKeyStore(KeyStore keyStore, X509Certificate PKCertificate)
      throws KeyStoreMgtException {
    try {
      ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
      keyStore.store(outputStream, password.toCharArray());
      outputStream.flush();
      outputStream.close();

      String keyStoreName = generateKSNameFromDomainName();
      // Use the keystore using the keystore admin
      KeyStoreAdmin keystoreAdmin = new KeyStoreAdmin(tenantId, govRegistry);
      keystoreAdmin.addKeyStore(
          outputStream.toByteArray(), keyStoreName, password, " ", "JKS", password);

      // Create the pub. key resource
      Resource pubKeyResource = govRegistry.newResource();
      pubKeyResource.setContent(PKCertificate.getEncoded());
      pubKeyResource.addProperty(
          SecurityConstants.PROP_TENANT_PUB_KEY_FILE_NAME_APPENDER,
          generatePubKeyFileNameAppender());

      govRegistry.put(RegistryResources.SecurityManagement.TENANT_PUBKEY_RESOURCE, pubKeyResource);

      // associate the public key with the keystore
      govRegistry.addAssociation(
          RegistryResources.SecurityManagement.KEY_STORES + "/" + keyStoreName,
          RegistryResources.SecurityManagement.TENANT_PUBKEY_RESOURCE,
          SecurityConstants.ASSOCIATION_TENANT_KS_PUB_KEY);

    } catch (RegistryException e) {
      String msg = "Error when writing the keystore/pub.cert to registry";
      log.error(msg, e);
      throw new KeyStoreMgtException(msg, e);
    } catch (Exception e) {
      String msg = "Error when processing keystore/pub. cert to be stored in registry";
      log.error(msg, e);
      throw new KeyStoreMgtException(msg, e);
    }
  }
示例#16
0
  private void singleValuedProperties() {
    String path = "/propTest/r2";
    Resource r2 = registry.newResource();
    try {
      r2.setContent("Some content for r2");

      r2.addProperty("p1", "p1v1");
      registry.put(path, r2);

      Resource r2b = registry.get(path);
      String p1Value = r2b.getProperty("p1");

      assertEquals("Property p1 of /propTest/r2 should contain the value p1v1", p1Value, "p1v1");

      deleteResources("/propTest");
      log.info("singleValuedProperties - Passed");
    } catch (RegistryException e) {

      log.error("singleValuedProperties RegistryException thrown :" + e.getMessage());
      Assert.fail("singleValuedProperties RegistryException thrown :" + e.getMessage());
    }
  }
示例#17
0
  public boolean addDomainMappingToRegistry(String hostName, String actualHost)
      throws ADCException, RegistryException {
    boolean successfullyAdded = false;
    try {

      registry.beginTransaction();
      Resource hostResource = registry.newResource();
      hostResource.addProperty(CartridgeConstants.DomainMappingInfo.ACTUAL_HOST, actualHost);
      if (!registry.resourceExists(CartridgeConstants.DomainMappingInfo.HOSTINFO + hostName)) {
        registry.put(CartridgeConstants.DomainMappingInfo.HOSTINFO + hostName, hostResource);
        successfullyAdded = true;
      } else {
        registry.rollbackTransaction();
        String msg = "Requested domain is already taken!";
        log.error(msg);
        throw new ADCException(msg);
      }
      registry.commitTransaction();
    } catch (RegistryException e) {
      registry.rollbackTransaction();
    }
    return successfullyAdded;
  }
  /**
   * method to persist credentials of a jira account
   *
   * @param registry Registry
   * @param accountInfo AccountInfo
   * @throws IssueTrackerException thrown id unable to store resources in the registry
   */
  public static void persistCredentials(Registry registry, AccountInfo accountInfo)
      throws IssueTrackerException {

    Resource resource = null;

    String path = IssueTrackerConstants.ISSUE_TRACKERS_RESOURCE_PATH + accountInfo.getKey();

    try {
      // if the collection does not exist create one
      if (!registry.resourceExists(IssueTrackerConstants.ISSUE_TRACKERS_RESOURCE_PATH)) {
        Collection collection = registry.newCollection();
        registry.put(IssueTrackerConstants.ISSUE_TRACKERS_RESOURCE_PATH, collection);
      }

      // get registry resource
      if (registry.resourceExists(path)) {
        resource = registry.get(path);
      } else {
        resource = registry.newResource();
      }
    } catch (RegistryException e) {
      ExceptionHandler.handleException("Error accessing registry", e, log);
    }

    // get credentials from account info
    GenericCredentials credentials;
    credentials = accountInfo.getCredentials();

    // set properties of the registry resources
    if (resource != null) {
      resource.addProperty(IssueTrackerConstants.ACCOUNT_KEY, accountInfo.getKey());
      resource.addProperty(IssueTrackerConstants.ISSUE_TRACKER_URL, credentials.getUrl());
      resource.addProperty(IssueTrackerConstants.ACCOUNT_LOGIN_USERNAME, credentials.getUsername());
      resource.addProperty(IssueTrackerConstants.ACCOUNT_EMAIL, accountInfo.getEmail());
      resource.addProperty(IssueTrackerConstants.ACCOUNT_UID, accountInfo.getUid());
      resource.addProperty(
          IssueTrackerConstants.HAS_SUPPORT_ACCOUNT,
          String.valueOf(accountInfo.isHasSupportAccount()));

      // set properties related with automatic reporting
      if (accountInfo.isAutoReportingEnable()) {

        AutoReportingSettings settings = accountInfo.getAutoReportingSettings();
        resource.addProperty(
            IssueTrackerConstants.AUTO_REPORTING, IssueTrackerConstants.IS_AUTO_REPORTING_ENABLED);
        resource.addProperty(
            IssueTrackerConstants.AUTO_REPORTING_PROJECT, settings.getProjectName());
        resource.addProperty(IssueTrackerConstants.AUTO_REPORTING_PRIORITY, settings.getPriority());
        resource.addProperty(
            IssueTrackerConstants.AUTO_REPORTING_ISSUE_TYPE, settings.getIssueType());

      } else {
        resource.addProperty(
            IssueTrackerConstants.AUTO_REPORTING, IssueTrackerConstants.IS_AUTO_REPORTING_DISABLED);
      }

      // encrypt and store password
      String password = credentials.getPassword();

      if (null != password && !"".equals(password)) {
        byte[] bytes = (password).getBytes();

        try {
          String base64String = CryptoUtil.getDefaultCryptoUtil().encryptAndBase64Encode(bytes);
          resource.addProperty(
              IssueTrackerConstants.ACCOUNT_PASSWORD_HIDDEN_PROPERTY, base64String);
        } catch (org.wso2.carbon.core.util.CryptoException e) {
          ExceptionHandler.handleException("Error accessing registry", e, log);
        }
      }
    }

    // put resource to registry
    try {
      registry.put(path, resource);
    } catch (RegistryException e) {
      ExceptionHandler.handleException("Error while persisting accountInfo", e, log);
    }
  }
示例#19
0
文件: Test.java 项目: ww102111/tools
  /**
   * @param args
   * @throws RegistryException
   * @throws IOException
   */
  public static void main(String[] args) throws RegistryException, IOException {

    System.setProperty(
        "javax.net.ssl.trustStore",
        "/home/saminda/Downloads/wso2esb-3.0.0-SNAPSHOT/resources/security/client-truststore.jks");
    System.setProperty("javax.net.ssl.trustStorePassword", "wso2carbon");
    System.setProperty("javax.net.ssl.trustStoreType", "JKS");

    RemoteRegistry registry =
        new RemoteRegistry(new URL("https://localhost:9443/registry"), "admin", "admin");
    Resource resource3 =
        registry.get("/repository/components/org.wso2.carbon.event/index/TopicIndex;version:600");
    new FileOutputStream(new File("/home/saminda/tmp/test123356.txt"))
        .write((byte[]) resource3.getContent());
    System.exit(0);

    //      Map parameters2 = new HashMap();
    //      parameters2.put("query", "SELECT A.REG_PATH_ID, A.REG_NAME FROM REG_RESOURCE A WHERE
    // A.REG_NAME LIKE ?");
    //      parameters2.put("1","%wsdl%");
    //      Resource result2 = registry.executeQuery("/custom-queries3", parameters2);
    //
    //      System.exit(1);
    String sql1 =
        "SELECT A.REG_PATH_ID, A.REG_NAME FROM REG_PATH B, REG_RESOURCE A WHERE ((A.REG_NAME LIKE 'abc') OR ((A.REG_NAME IS NULL) AND (B.REG_PATH_VALUE LIKE 'abc') AND (A.REG_PATH_ID=B.REG_PATH_ID)))";

    Resource q1 = registry.newResource();

    q1.setContent(sql1);

    q1.setMediaType(RegistryConstants.SQL_QUERY_MEDIA_TYPE);

    q1.addProperty(
        RegistryConstants.RESULT_TYPE_PROPERTY_NAME, RegistryConstants.RESOURCES_RESULT_TYPE);

    registry.put("/custom-queries", q1);

    // then you should give the parameters and the query location you just put

    Map parameters = new HashMap();

    //        parameters.put("1", "%coll%ctio%");

    Resource result = registry.executeQuery("/custom-queries", parameters);

    String[] paths = (String[]) result.getContent();

    for (String path : paths) {
      System.out.println(path);
    }

    //		ResourceImpl r=(ResourceImpl)registry.get("/AuthenticationAdminService.wsdl");
    ////		System.out.println(r.get);
    //		String[] versions = registry.getVersions("/AuthenticationAdminService.wsdl");
    //		for (String v : versions) {
    //			System.out.println(v);
    //		}
    System.exit(0);

    Resource resource = registry.get("/carbon");
    // ResourceImpl r=(ResourceImpl)resource;

    System.out.println(resource.getMediaType());
    resource.setMediaType("samindaaaaaaaaaaaaa");
    registry.put("/carbon", resource);
    resource = registry.get("/carbon");
    System.out.println(resource.getMediaType());

    System.exit(0);
    File file = new File("/home/saminda/tmp/testexport");
    registry.get("/");
    // RegistryClientUtils.exportFromRegistry(file, "/carbon", registry);

    //		ClientOptions.getClientOptions().setUsername("admin");
    //		ClientOptions.getClientOptions().setPassword("admin");
    //		ClientOptions.getClientOptions().setWorkingDir(file.getAbsolutePath());
    //		ClientOptions.getClientOptions().setRegistryUrl("https://localhost:9445/registry");
    //		ClientOptions.getClientOptions().setCheckoutPath("/carbon");
    //
    ////		ClientOptions.getClientOptions().setUserUrl("https://localhost:9445/registry/carbon");
    //
    //	ClientOptions.getClientOptions().setUserUrl(ClientOptions.getClientOptions().getRegistryUrl()+ClientOptions.getClientOptions().getCheckoutPath());
    //
    //
    //		new Checkout().execute();
    //		Object content = registry.get("/carbon/xslt/LocalEntry.xslt").getContent();
    //		byte[] b=(byte[])content;
    //
    //		FileOutputStream fos = new FileOutputStream("/home/saminda/tmp/abc.txt");
    //		fos.write(b);
    //		fos.close();
    //		String a="/carbon/";
    //		String[] s = a.split("/");
    //		for (String p : s) {
    //			System.out.println(p);
    //		}
  }