Package org.wso2.carbon.registry.core

Examples of org.wso2.carbon.registry.core.Resource


            String servicePath = RegistryResources.SERVICE_GROUPS
            + axisService.getAxisServiceGroup().getServiceGroupName()
            + RegistryResources.SERVICES + axisService.getName();

            Resource serviceResource = registry.get(servicePath);
            Association[] assoc = registry.getAssociations(servicePath, RegistryResources.Associations.PRIVATE_KEYSTORE);
           
            KeyStoreManager keyStoreManager = KeyStoreManager.getInstance(null);
           
            KeyStore keyStore = null;
            if(assoc.length < 1){

                boolean httpsEnabled = false;
                Association[] associations =
                    registry.getAssociations(servicePath, RegistryResources.Associations.EXPOSED_TRANSPORTS);
                for (Association association : associations) {
                    Resource resource = registry.get(association.getDestinationPath());
                    String transportProtocol = resource.getProperty(RegistryResources.Transports.PROTOCOL_NAME);
                    if(transportProtocol.equals("https")){
                        httpsEnabled = true;
                        break;
                    }
                    resource.discard();
                }
               
                if (httpsEnabled ||Boolean.valueOf(serviceResource.getProperty(RegistryResources.ServiceProperties.EXPOSED_ON_ALL_TANSPORTS))) {
                    keyStore = keyStoreManager.getPrimaryKeyStore();
                }
View Full Code Here


        configRegistry.put(path, resource);
        resource.discard();
    }

    public OMElement getTransportElement(String name, boolean listener) throws Exception {
        Resource resource = getTransportResource(configRegistry, name, listener);

        if (resource != null) {
            ByteArrayInputStream in = new ByteArrayInputStream((byte[]) resource.getContent());
            resource.discard();
            StAXOMBuilder builder = new StAXOMBuilder(in);
            return builder.getDocumentElement();
        }
        return null;
    }
View Full Code Here

            } else {
                childPath += TRANSPORT_SENDER;
            }

            if (configRegistry.resourceExists(childPath)) {
                Resource resource = configRegistry.get(childPath);
                if (Boolean.valueOf(resource.getProperty(RegistryResources.Transports.IS_ENABLED))) {
                    enabledTransports.add(resource.getProperty(RegistryResources.
                            Transports.PROTOCOL_NAME));
                }
            }
        }
View Full Code Here

    }

    public void setTransportEnabled(String name, boolean listener,
                                    boolean enabled) throws Exception {

        Resource resource = getTransportResource(configRegistry, name, listener);
        if (resource != null) {
            resource.setProperty(RegistryResources.Transports.IS_ENABLED, String.valueOf(enabled));
            configRegistry.put(resource.getPath(), resource);
            resource.discard();
        }
    }
View Full Code Here

     * @param policyResourceList - resource list
     * @return - policy resource if found, else null
     */
    public static Resource getPolicyResourceFromList(String policyId, List policyResourceList) {
        for (Object resource : policyResourceList) {
            Resource currentResource = (Resource) resource;
            if (currentResource.getProperty(RegistryResources.ServiceProperties.POLICY_UUID)
                    .equalsIgnoreCase(policyId)) {
                return currentResource;
            }
        }
        return null;
View Full Code Here

    public String getResourceContent(String regPath) throws Exception {
        String uepStr = "";
        registryService = new RemoteRegistryService("http://localhost:9763/registry", "admin", "admin");
        registry = registryService.getGovernanceUserRegistry("admin", "admin");
        Resource res = registry.get(regPath);

        if (res != null) {
            uepStr = new String((byte[]) res.getContent());
            //System.out.println("Res :" + new String((byte[]) res.getContent()));
        }

        return uepStr;
    }
View Full Code Here

    }

  public static void main(String[] args) throws Exception {
    WSRegistryServiceClient client;
    client = initialize();
    Resource resource = client.newResource();
    resource.setContent("Hello Out there!");

    String resourcePath = "/abc";
    registry.put(resourcePath, resource);

    System.out.println("A resource added to" + resourcePath);

    registry.rateResource(resourcePath, 3);

    System.out.println("Resource rated with 3 stars!");
    Comment comment = new Comment();
    comment.setText("Wow! A comment out there");
    registry.addComment(resourcePath, comment);
    System.out.println("Comment added to resource");

    Resource getResource = registry.get("/abc");
    System.out.println("Resource retrived");
    System.out.println("Printing retrieved resource content: " + new String((byte[])getResource.getContent()));

  }
View Full Code Here

                registry = getGovernanceRegistry();
                key = key.replace("gov:","");
            }
           
            if (!registry.resourceExists(key)) {
                Resource resource = registry.newResource();
                resource.setMediaType(UnifiedEndpointConstants.WSO2_UNIFIED_ENDPOINT_MEDIA_TYPE);
                resource.setContent(ele);
                registry.put(key, resource);
            } else {

                registry.delete(key);

                Resource resource = registry.newResource();
                resource.setMediaType(UnifiedEndpointConstants.WSO2_UNIFIED_ENDPOINT_MEDIA_TYPE);
                resource.setContent(ele);
                registry.put(key, resource);

                /*Resource r = registry.get(key);
                r.setContent(ele);*/
                System.out.println("Resource already exists");
View Full Code Here

            int uepPtr = 0;
            for (String key : info) {
                if (key.startsWith("conf:/")) {
                    String resourceKey = key.replaceFirst("conf:/", "");
                    if (resourceKey != null) {
                        Resource resource = registry.get(resourceKey);
                        if (resource != null) {
                            String strContent = new String((byte[]) resource.getContent());
                            uepStrArray[uepPtr++] = strContent;
                        }
                    }
                }
            }


           
            for (String key : info) {
                if (key.startsWith("gov:/")) {
                    org.wso2.carbon.registry.core.Registry govReg = getGovernanceRegistry();
                    String resourceKey = key.replaceFirst("gov:/", "");
                    if (resourceKey != null) {
                        Resource resource = govReg.get(resourceKey);
                        if (resource != null) {
                            String strContent = new String((byte[]) resource.getContent());
                            uepStrArray[uepPtr++] = strContent;
                        }
                    }
                }
            }
View Full Code Here

    private String[] getMimeTypeResult(org.wso2.carbon.registry.core.Registry targetRegistry) throws RegistryException {
        String sql = "SELECT REG_PATH_ID, REG_NAME FROM REG_RESOURCE WHERE REG_MEDIA_TYPE = ?";
        Map parameters = new HashMap();
        parameters.put("query",sql);
        parameters.put("1", UnifiedEndpointConstants.WSO2_UNIFIED_ENDPOINT_MEDIA_TYPE);
        Resource result = targetRegistry.executeQuery(null, parameters);
        return (String[]) result.getContent();
    }
View Full Code Here

TOP

Related Classes of org.wso2.carbon.registry.core.Resource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.