Package org.wso2.carbon.registry.core

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


        context.getRepository().put(resource.getPath(), resource);
    }

    public String[] getAvailableActions(RequestContext context) {
        ArrayList<String> actions = new ArrayList<String>();
        Resource resource = context.getResource();
        String currentState = resource.getProperty(stateProperty);

        Properties props = resource.getProperties();
        boolean allItemsAreChecked = true;
        for (Map.Entry<Object, Object> e : props.entrySet()) {
            if (((String) e.getKey()).startsWith("registry.custom_lifecycle.checklist.")) {
                List<String> propValues = (List<String>) e.getValue();
                String[] propertyValues = propValues.toArray(new String[propValues.size()]);
View Full Code Here


        }
        return actions.toArray(new String[actions.size()]);
    }

    public void dissociate(RequestContext context) {
        Resource resource = context.getResource();
        if (resource != null) {
            resource.removeProperty(stateProperty);
        }
    }
View Full Code Here

                + RegistryResources.SERVICES + axisService.getName();
        String policiesPath = servicePath + RegistryResources.POLICIES;

        String policyResourcePath = servicePath + RegistryResources.POLICIES + policy.getId();
        if (!registry.resourceExists(policyResourcePath)) {
            Resource policyResource = registry.newResource();
            policyResource.setProperty(RegistryResources.ServiceProperties.POLICY_UUID, policy
                    .getId());
            // do a performance improvement
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(baos);
            policy.serialize(writer);
            writer.flush();
            policyResource.setContent((String) baos.toString());
            policyResource.setProperty(RegistryResources.ServiceProperties.POLICY_TYPE, ""
                    + PolicyInclude.BINDING_POLICY);
            registry.put(policyResourcePath, policyResource);
        }

        Map endPointMap = axisService.getEndpoints();
        List<String> lst = new ArrayList<String>();
        for (Object o : endPointMap.entrySet()) {
            Map.Entry entry = (Map.Entry) o;
            AxisEndpoint point = (AxisEndpoint) entry.getValue();
            AxisBinding binding = point.getBinding();
            binding.getPolicySubject().attachPolicy(policy);
            String bindingName = binding.getName().getLocalPart();
            if (lst.contains(bindingName)) {
                continue;
            } else {
                lst.add(bindingName);
            }
            // Add the new policy to the registry
        }
        boolean transactionStarted = Transaction.isStarted();
        if (!transactionStarted) {
            registry.beginTransaction();
        }
        Iterator<String> ite = lst.iterator();
        while (ite.hasNext()) {
            String bindingName = ite.next();
            String bindingResourcePath = servicePath
                    + RegistryResources.ServiceProperties.BINDINGS + bindingName;

            Resource bindingResource = null;
            if(registry.resourceExists(bindingResourcePath)){
                bindingResource = registry.get(bindingResourcePath);
            }else{
                bindingResource = registry.newResource();
            }

            bindingResource.addProperty(RegistryResources.ServiceProperties.POLICY_UUID,
                    policy.getId());
            registry.put(bindingResourcePath, bindingResource);
        }
        if (!transactionStarted) {
            registry.commitTransaction();
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

        Iterator<String> ite = lst.iterator();
        while (ite.hasNext()) {
            String bindingName = ite.next();
            String bindingResourcePath = servicePath
                    + RegistryResources.ServiceProperties.BINDINGS + bindingName;
            Resource bindingResource = registry.get(bindingResourcePath);
            List uuids = bindingResource.getPropertyValues(RegistryResources.ServiceProperties.POLICY_UUID);
            uuids.remove(uuid);
            bindingResource.setProperty(RegistryResources.ServiceProperties.POLICY_UUID, uuids);
            registry.put(bindingResourcePath, bindingResource);
        }
        if (!transactionStarted) {
            registry.commitTransaction();
        }
View Full Code Here

    }

    public List<DatabaseInfo> getDatabaseList() throws RegistryException, XMLStreamException {
        try {
            if (this.registry.resourceExists(PATH_TO_URL_MAP)) {
                Resource resource = registry.get(PATH_TO_URL_MAP);
                List<DatabaseInfo> dbs;
                if (resource.getContent() != null) {
                    OMElement dbsElement = AXIOMUtil.stringToOM(
                            new String((byte[]) resource.getContent()));
                    dbs = new ArrayList<DatabaseInfo>();
                    Iterator dbElementIterator = dbsElement.getChildElements();

                    while (dbElementIterator.hasNext()) {
                        OMElement element = (OMElement) dbElementIterator.next();
View Full Code Here

    }

    public List<DatabaseInstanceInfo> getDatabaseInstanceList() throws RegistryException, XMLStreamException {
        try {
            if (this.registry.resourceExists(PATH_TO_INSTANCE_LIST)) {
                Resource resource = registry.get(PATH_TO_INSTANCE_LIST);
                List<DatabaseInstanceInfo> instances;
                if (resource.getContent() != null) {
                    String resourceContent = new String((byte[]) resource.getContent());
                    OMElement instancesElement = AXIOMUtil.stringToOM(resourceContent);
                    instances = new ArrayList<DatabaseInstanceInfo>();
                    Iterator dbInstanceElementIterator = instancesElement.getChildElements();

                    while (dbInstanceElementIterator.hasNext()) {
View Full Code Here

    }

    public List<DatabaseUserInfo> getDatabaseUserInfo() throws RegistryException, XMLStreamException {
        try {
            if (this.registry.resourceExists(PATH_TO_USER_LIST)) {
                Resource resource = registry.get(PATH_TO_USER_LIST);
                List<DatabaseUserInfo> users;
                if (resource.getContent() != null) {
                    OMElement usersElement = AXIOMUtil.stringToOM(new String((byte[]) resource.getContent()));
                    users = new ArrayList<DatabaseUserInfo>();
                    Iterator dbUserElementIterator = usersElement.getChildElements();

                    while (dbUserElementIterator.hasNext()) {
                        OMElement element = (OMElement) dbUserElementIterator.next();
View Full Code Here

    }

    private void writeDataToRegistry(String resourceContent,
                                     String resourcePath) throws RegistryException {
        if (registry != null) {
            Resource resource = registry.newResource();
            resource.setContent(resourceContent.getBytes());
            registry.put(resourcePath, resource);
        } else {
            throw new RegistryException("Registry Instance Cannot Be Obtained");
        }
    }
View Full Code Here

                                                            if (registry.get(mappingChild) instanceof Collection) {
                                                                Collection mapCollection = (Collection) registry.get(mappingChild);
                                                                if ((CEPConstants.CEP_REGISTRY_BS + CEPConstants.CEP_REGISTRY_XPATH_DEFS)
                                                                        .equals(mappingChild.substring(mappingChild.lastIndexOf(CEPConstants.CEP_REGISTRY_BS)))) {
                                                                    for (String defs : mapCollection.getChildren()) {
                                                                        Resource xpathDefResource = registry.get(defs);
                                                                        Hashtable propertiesHashtable = xpathDefResource.getProperties();
                                                                        Enumeration e = propertiesHashtable.keys();
                                                                        while (e.hasMoreElements()) {
                                                                            String key = (String) e.nextElement();
                                                                            ArrayList values = (ArrayList) propertiesHashtable.get(key);
                                                                            XpathDefinition xpathDefinition = new XpathDefinition();
                                                                            xpathDefinition.setPrefix(key);
                                                                            xpathDefinition.setNamespace(values.get(0).toString());
                                                                            mapping.addXpathDefinition(xpathDefinition);
                                                                        }
                                                                    }
                                                                } else if (
                                                                        (CEPConstants.CEP_REGISTRY_BS + CEPConstants.CEP_REGISTRY_PROPERTIES)
                                                                                .equals(mappingChild.substring(mappingChild.lastIndexOf(CEPConstants.CEP_REGISTRY_BS)))) {
                                                                    for (String defs : mapCollection.getChildren()) {
                                                                        Resource xpathDefResource = registry.get(defs);
                                                                        Hashtable propertiesHashtable = xpathDefResource.getProperties();
                                                                        Enumeration e = propertiesHashtable.keys();
                                                                        Property property = new Property();
                                                                        while (e.hasMoreElements()) {
                                                                            String key = (String) e.nextElement();
                                                                            ArrayList values = (ArrayList) propertiesHashtable.get(key);
                                                                            if (CEPConstants.CEP_REGISTRY_NAME.equals(key)) {
                                                                                property.setName(values.get(0).toString());
                                                                            } else if (CEPConstants.CEP_REGISTRY_TYPE.equals(key)) {
                                                                                property.setType(values.get(0).toString());
                                                                            } else if (CEPConstants.CEP_REGISTRY_XPATH.equals(key)) {
                                                                                property.setXpath(values.get(0).toString());
                                                                            }
                                                                        }
                                                                        mapping.addProperty(property);
                                                                    }
                                                                }
                                                            } else {
                                                                Resource resource = registry.get(mappingChild);
                                                                Hashtable propertiesHashtable = resource.getProperties();
                                                                Enumeration e = propertiesHashtable.keys();
                                                                while (e.hasMoreElements()) {
                                                                    String key = (String) e.nextElement();
                                                                    ArrayList values = (ArrayList) propertiesHashtable.get(key);
                                                                    if (CEPConstants.CEP_REGISTRY_STREAM.equals(key)) {
                                                                        mapping.setStream(values.get(0).toString());
                                                                    }
                                                                }
                                                            }
                                                        }
                                                        input.setMapping(mapping);
                                                    } else {
                                                        if ((CEPConstants.CEP_REGISTRY_BS + CEPConstants.CEP_REGISTRY_DETAILS)
                                                                .equals(names2.substring(names2.lastIndexOf(CEPConstants.CEP_REGISTRY_BS)))) {
                                                            Resource resource = registry.get(names2);
                                                            Hashtable propertiesHashtable = resource.getProperties();
                                                            Enumeration e = propertiesHashtable.keys();
                                                            while (e.hasMoreElements()) {
                                                                String key = (String) e.nextElement();
                                                                ArrayList values = (ArrayList) propertiesHashtable.get(key);
                                                                if (CEPConstants.CEP_REGISTRY_TOPIC.equals(key)) {
                                                                    input.setTopic(values.get(0).toString());
                                                                } else if (CEPConstants.CEP_CONF_ELE_BROKER_NAME.equals(key)) {
                                                                    input.setBrokerName(values.get(0).toString());
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                                bucket.addInput(input);
                                            } else if ((CEPConstants.CEP_REGISTRY_BS + CEPConstants.CEP_REGISTRY_QUERIES)
                                                    .equals(attirbute.substring(attirbute.lastIndexOf(CEPConstants.CEP_REGISTRY_BS)))) {
                                                query = new Query();
                                                Expression expression = new Expression();
                                                Output output = new Output();
                                                Collection collection3 = (Collection) registry.get(names);
                                                for (String names2 : collection3.getChildren()) {
                                                    if (registry.get(names2) instanceof Collection) {
                                                        Collection outputCollection = (Collection) registry.get(names2);
                                                        for (String outputS : outputCollection.getChildren()) {
                                                            if (registry.get(outputS) instanceof Collection) {
                                                                Collection outputMapping = (Collection) registry.get(outputS);
                                                                if ((CEPConstants.CEP_REGISTRY_BS + CEPConstants.CEP_REGISTRY_ELEMENT_MAPPING)
                                                                        .equals(outputS.substring(outputS.lastIndexOf(CEPConstants.CEP_REGISTRY_BS)))) {
                                                                    ElementMapping elementMapping = new ElementMapping();
                                                                    for (String mappingName : outputMapping.getChildren()) {
                                                                        if (registry.get(mappingName) instanceof Collection) {
                                                                            Collection propertyCollection = (Collection) registry.get(mappingName);
                                                                            for (String propertyName : propertyCollection.getChildren()) {
                                                                                Resource propertyResource = registry.get(propertyName);
                                                                                Hashtable propertiesHashtable = propertyResource.getProperties();
                                                                                Enumeration e = propertiesHashtable.keys();
                                                                                Property property = new Property();
                                                                                while (e.hasMoreElements()) {
                                                                                    String key = (String) e.nextElement();
                                                                                    ArrayList values = (ArrayList) propertiesHashtable.get(key);
                                                                                    if (CEPConstants.CEP_REGISTRY_NAME.equals(key)) {
                                                                                        property.setName(values.get(0).toString());
                                                                                    } else if (CEPConstants.CEP_REGISTRY_XML_FIELD_NAME.equals(key)) {
                                                                                        property.setXmlFieldName(values.get(0).toString());
                                                                                    } else if (CEPConstants.CEP_REGISTRY_XML_FIELD_TYPE.equals(key)) {
                                                                                        property.setXmlFieldType(values.get(0).toString());
                                                                                    }
                                                                                }
                                                                                elementMapping.addProperty(property);
                                                                            }
                                                                        } else {
                                                                            Resource outputdetailsResource = registry.get(mappingName);
                                                                            Hashtable propertiesHashtable = outputdetailsResource.getProperties();
                                                                            Enumeration e = propertiesHashtable.keys();
                                                                            while (e.hasMoreElements()) {
                                                                                String key = (String) e.nextElement();
                                                                                ArrayList values = (ArrayList) propertiesHashtable.get(key);
                                                                                if (CEPConstants.CEP_REGISTRY_DOC_ELEMENT.equals(key)) {
                                                                                    elementMapping.setDocumentElement(values.get(0).toString());
                                                                                } else if (CEPConstants.CEP_REGISTRY_NS.equals(key)) {
                                                                                    elementMapping.setNamespace(values.get(0).toString());
                                                                                }
                                                                            }
                                                                        }
                                                                        output.setElementMapping(elementMapping);
                                                                    }
                                                                } else {
                                                                    XMLMapping xmlMapping = null;
                                                                    for (String mappingName : outputMapping.getChildren()) {
                                                                        xmlMapping = new XMLMapping();
                                                                        if (registry.get(mappingName) instanceof Collection) {

                                                                        } else {
                                                                            Resource outputdetailsResource = registry.get(mappingName);
                                                                            Hashtable propertiesHashtable = outputdetailsResource.getProperties();
                                                                            Enumeration e = propertiesHashtable.keys();
                                                                            while (e.hasMoreElements()) {
                                                                                String key = (String) e.nextElement();
                                                                                ArrayList values = (ArrayList) propertiesHashtable.get(key);
                                                                                if (CEPConstants.CEP_REGISTRY_TEXT.equals(key)) {
                                                                                    xmlMapping.setMappingXMLText(values.get(0).toString());
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                    output.setXmlMapping(xmlMapping);
                                                                }
                                                            } else {
                                                                Resource outputdetailsResource = registry.get(outputS);
                                                                Hashtable propertiesHashtable = outputdetailsResource.getProperties();
                                                                Enumeration e = propertiesHashtable.keys();
                                                                while (e.hasMoreElements()) {
                                                                    String key = (String) e.nextElement();
                                                                    ArrayList values = (ArrayList) propertiesHashtable.get(key);
                                                                    if (CEPConstants.CEP_REGISTRY_TOPIC.equals(key)) {
                                                                        output.setTopic(values.get(0).toString());
                                                                    } else if (CEPConstants.CEP_CONF_ELE_BROKER_NAME.equals(key)) {
                                                                        output.setBrokerName(values.get(0).toString());
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    } else {
                                                        Resource detailsResource = registry.get(names2);
                                                        Hashtable propertiesHashtable = detailsResource.getProperties();
                                                        Enumeration e = propertiesHashtable.keys();
                                                        while (e.hasMoreElements()) {
                                                            String key = (String) e.nextElement();
                                                            ArrayList values = (ArrayList) propertiesHashtable.get(key);
                                                            if (CEPConstants.CEP_REGISTRY_NAME.equals(key)) {
                                                                query.setName(values.get(0).toString());
                                                            } else if (CEPConstants.CEP_REGISTRY_TYPE.equals(key)) {
                                                                expression.setType(values.get(0).toString());
                                                            } /*else if (CEPConstants.CEP_REGISTRY_EXPRESSION.equals(key)) {
                                                            expression.setText(values.get(0).toString());
                                                        }*/
                                                        }
                                                        String content = new String((byte[]) detailsResource.getContent());
                                                        expression.setText(content);
                                                    }
                                                }
                                                query.setExpression(expression);
                                                query.setOutput(output);
                                                bucket.addQuery(query);
                                            }
                                        }
                                    }
                                } else {
                                    Resource propertyResource = registry.get(attirbute);
                                    Hashtable propeHashtable = propertyResource.getProperties();
                                    Enumeration e = propeHashtable.keys();
                                    while (e.hasMoreElements()) {
                                        String key = (String) e.nextElement();
                                        ArrayList values = (ArrayList) propeHashtable.get(key);
                                        if (CEPConstants.CEP_CONF_ELE_NAME.equals(key)) {
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.