This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

Restore a Registry Resource Stored in a File to WSO2 Registry

The following code snippet shows how to programmetically take a registry resource that was written to a file and restore it to the WSO2 registry using Remote Registry.

import org.wso2.carbon.registry.app.RemoteRegistry;
import org.wso2.carbon.registry.core.exceptions.RegistryException;

import java.net.URL;
import java.net.MalformedURLException;
import java.io.FileWriter;
import java.io.FileReader;
import java.io.IOException;

public class RemoteRegistrySampleTest {
  public static void main(String[] args) {
    System.setProperty("javax.net.ssl.trustStore", "CARBON_HOME/resources/security/client-truststore.jks");
    System.setProperty("javax.net.ssl.trustStorePassword", "wso2carbon");
    System.setProperty("javax.net.ssl.trustStoreType", "JKS");

    RemoteRegistry esb2xRemoteRegistry = null;
    try {
       esb2xRemoteRegistry = new RemoteRegistry(new URL("https://localhost:9443/registry"), "admin", "admin");
       esb2xRemoteRegistry.restore("/esb-resources", new FileReader("/home/heshan/Dev/wso2_heshan/temp/registry.xml"));
    } catch (RegistryException e) {
             e.printStackTrace();
    } catch (MalformedURLException e) {
             e.printStackTrace();
    } catch (IOException e) {
             e.printStackTrace();
    }
 }
}