Package org.wso2.carbon.registry.core

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


     *
     * @return The Key Store Type
     */
    private String getKeyStoreType(String ksId) throws Exception {
        String path = SecurityConstants.KEY_STORES + "/" + ksId;
        Resource resource = (Resource) registry.get(path);
        return resource.getProperty(SecurityConstants.PROP_TYPE);

    }
View Full Code Here


     *
     * @return The Key Store Provider
     */
    private String getKeyStoreProvider(String ksId) throws Exception {
        String path = SecurityConstants.KEY_STORES + "/" + ksId;
        Resource resource = (Resource) registry.get(path);
        return resource.getProperty(SecurityConstants.PROP_PROVIDER);

    }
View Full Code Here

            if (!registry.resourceExists(secretKeyPath)) {
                String msg = "Email verification failed.";
                log.error(msg);
                throw new Exception(msg);
            }
            Resource resource = registry.get(secretKeyPath);

            // just get the properties of that
            Properties props = resource.getProperties();
            for (Object o : props.keySet()) {
                String key = (String) o;
                OMElement internal = fac.createOMElement(key, null);
                internal.setText(resource.getProperty(key));
                data.addChild(internal);
                if (key.equals("redirectPath")) {
                    confirmationBean.setRedirectPath(resource.getProperty(key));
                }
            }
            registry.delete(resource.getPath());// remove the temporaraly store resource from registry
            confirmationBean.setData(data.toString());
            success = true;

        } finally {
            if (success) {
View Full Code Here

            String secretKey = UUID.randomUUID().toString();

            //User suppose to give where he wants to store interemdiate data to them after confirmation
            //here there's not tenant registration happened yet so get the super tenant registry instance
            Registry registry = Util.getConfigSystemRegistry(0);
            Resource resource = registry.newResource();
            // store the redirector url
            resource.setProperty("redirectPath", serviceConfig.getRedirectPath());
            // store the user data, redirectPath can be overwritten here.
            for (String s : data.keySet()) {
                resource.setProperty(s, data.get(s));
            }

            ((ResourceImpl)resource).setVersionableChange(false);
            String secretKeyPath = EMAIL_VERIFICATION_COLLECTION + "/" + secretKey;
            registry.put(secretKeyPath, resource);
View Full Code Here

            if (registry.resourceExists(parentCollectionPath) == true) {
                return;
            }
            registry.put(parentCollectionPath, registry.newCollection());

            Resource bucketProperties = registry.newResource();
            bucketProperties.addProperty(CEPConstants.CEP_CONF_ELE_NAME, bucket.getName());
            bucketProperties.addProperty(CEPConstants.CEP_CONF_ELE_DESCRIPTION, bucket.getDescription());
            bucketProperties.addProperty(CEPConstants.CEP_CONF_ELE_CEP_ENGINE_PROVIDER, bucket.getEngineProvider());
            bucketProperties.addProperty(CEPConstants.CEP_CONF_ELE_CEP_BUCKET_OWNER, bucket.getOwner());
            registry.put(parentCollectionPath + CEPConstants.CEP_REGISTRY_BS + CEPConstants.CEP_REGISTRY_PROPERTIES, bucketProperties);

            String inputsCollectionPath = parentCollectionPath + CEPConstants.CEP_REGISTRY_BS + CEPConstants.CEP_REGISTRY_INPUTS;
            registry.put(inputsCollectionPath, registry.newCollection());
            for (Input input : bucket.getInputs()) {
                String inputResourcePath = inputsCollectionPath + "/" + input.getTopic();

                registry.put(inputResourcePath, registry.newCollection());

                Resource inputTopic = registry.newResource();
                inputTopic.addProperty(CEPConstants.CEP_CONF_ELE_TOPIC, input.getTopic());
                inputTopic.addProperty(CEPConstants.CEP_CONF_ELE_BROKER_NAME, input.getBrokerName());
                registry.put(inputResourcePath + CEPConstants.CEP_REGISTRY_BS + CEPConstants.CEP_REGISTRY_DETAILS, inputTopic);
                registry.put(inputResourcePath + CEPConstants.CEP_REGISTRY_BS + CEPConstants.CEP_REGISTRY_MAPPING, registry.newCollection());
                String mappingPath = inputResourcePath + CEPConstants.CEP_REGISTRY_BS + CEPConstants.CEP_REGISTRY_MAPPING + CEPConstants.CEP_REGISTRY_BS;

                Resource streamResource = registry.newResource();
                streamResource.addProperty(CEPConstants.CEP_REGISTRY_STREAM, input.getMapping().getStream());
                registry.put(mappingPath + CEPConstants.CEP_REGISTRY_STREAM, streamResource);

              /*  Map<String, String> xpathDefinitionsTable = input.getMapping().getXpathNamespacePrefixes();
                if (xpathDefinitionsTable != null && xpathDefinitionsTable.size() > 0) {
                    Set set = xpathDefinitionsTable.keySet();
                    Iterator it = set.iterator();
                    while (it.hasNext()) {
                        String key = (String) it.next();
                        String value = xpathDefinitionsTable.get(key);
                        Resource xpathDef = registry.newResource();
                        xpathDef.addProperty(key, value);
                        registry.put(mappingPath + CEPConstants.CEP_REGISTRY_XPATH_DEFS + CEPConstants.CEP_REGISTRY_BS + key, xpathDef);
                    }
                }*/
                List<XpathDefinition> xpathDefinitionList = input.getMapping().getXpathNamespacePrefixes();
                if(xpathDefinitionList != null && xpathDefinitionList.size() >0){
                    for(XpathDefinition xpathDefinition : xpathDefinitionList){
                        String key = xpathDefinition.getPrefix();
                        String value = xpathDefinition.getNamespace();
                        Resource xpathDef = registry.newResource();
                        xpathDef.addProperty(key, value);
                        registry.put(mappingPath + CEPConstants.CEP_REGISTRY_XPATH_DEFS + CEPConstants.CEP_REGISTRY_BS + key, xpathDef);
                    }
                }


                if (input.getMapping().getProperties() != null) {
                    for (Property property : input.getMapping().getProperties()) {
                        Resource propertyResource = registry.newResource();
                        propertyResource.addProperty(CEPConstants.CEP_REGISTRY_NAME, property.getName());
                        propertyResource.addProperty(CEPConstants.CEP_REGISTRY_TYPE, property.getType());
                        propertyResource.addProperty(CEPConstants.CEP_REGISTRY_XPATH, property.getXpath());
                        registry.put(mappingPath + CEPConstants.CEP_REGISTRY_PROPERTIES + CEPConstants.CEP_REGISTRY_BS + property.getName(), propertyResource);
                    }
                }
            }
            String queriesCollectionPath = parentCollectionPath + CEPConstants.CEP_REGISTRY_BS + CEPConstants.CEP_REGISTRY_QUERIES;
            registry.put(queriesCollectionPath, registry.newCollection());
            for (Query query : bucket.getQueries()) {
                String queryPath = queriesCollectionPath + "/" + query.getName();
                registry.put(queryPath, registry.newCollection());
                Resource queryResource = registry.newResource();
                queryResource.setProperty(CEPConstants.CEP_REGISTRY_NAME, query.getName());
                queryResource.setProperty(CEPConstants.CEP_REGISTRY_TYPE, query.getExpression().getType());
//                queryResource.setProperty(CEPConstants.CEP_REGISTRY_EXPRESSION,query.getExpression().getText());
                queryResource.setContent(query.getExpression().getText());
                registry.put(queryPath + CEPConstants.CEP_REGISTRY_BS + CEPConstants.CEP_REGISTRY_DETAILS, queryResource);

                registry.put(queryPath + CEPConstants.CEP_REGISTRY_BS + CEPConstants.CEP_REGISTRY_OUTPUT, registry.newCollection());

                Output output = query.getOutput();
                Resource outputResource = registry.newResource();
                outputResource.addProperty(CEPConstants.CEP_REGISTRY_TOPIC, output.getTopic());
                outputResource.addProperty(CEPConstants.CEP_CONF_ELE_BROKER_NAME, output.getBrokerName());
                outputResource.addProperty(CEPConstants.CEP_REGISTRY_TYPE,
                        output.getElementMapping() == null ? CEPConstants.CEP_REGISTRY_XML_MAPPING : CEPConstants.CEP_REGISTRY_ELEMENT_MAPPING);
                registry.put(queryPath + CEPConstants.CEP_REGISTRY_BS + CEPConstants.CEP_REGISTRY_OUTPUT +
                        CEPConstants.CEP_REGISTRY_BS + output.getTopic(), outputResource);

                ElementMapping elementMapping = output.getElementMapping();

                if (elementMapping != null) {
                    String elementMappingPathString = CEPConstants.CEP_REGISTRY_BS +
                            CEPConstants.CEP_REGISTRY_OUTPUT +
                            CEPConstants.CEP_REGISTRY_BS +
                            CEPConstants.CEP_REGISTRY_ELEMENT_MAPPING;
                    registry.put(queryPath + elementMappingPathString, registry.newCollection());
                    Resource elementMappingResource = registry.newResource();
                    elementMappingResource.addProperty(CEPConstants.CEP_REGISTRY_DOC_ELEMENT, elementMapping.getDocumentElement());
                    elementMappingResource.addProperty(CEPConstants.CEP_REGISTRY_NS, elementMapping.getNamespace());
                    registry.put(queryPath + elementMappingPathString +
                            CEPConstants.CEP_REGISTRY_BS + CEPConstants.CEP_REGISTRY_DETAILS, elementMappingResource);

                    registry.put(queryPath + elementMappingPathString +
                            CEPConstants.CEP_REGISTRY_BS + CEPConstants.CEP_REGISTRY_PROPERTIES, registry.newCollection());
                    for (Property property : elementMapping.getProperties()) {
                        Resource elementMappingProperties = registry.newResource();
                        elementMappingProperties.addProperty(CEPConstants.CEP_REGISTRY_NAME, property.getName());
                        elementMappingProperties.addProperty(CEPConstants.CEP_REGISTRY_XML_FIELD_NAME, property.getXmlFieldName());
                        elementMappingProperties.addProperty(CEPConstants.CEP_REGISTRY_XML_FIELD_TYPE, property.getXmlFieldType());
                        registry.put(queryPath + elementMappingPathString +
                                CEPConstants.CEP_REGISTRY_BS + CEPConstants.CEP_REGISTRY_PROPERTIES +
                                CEPConstants.CEP_REGISTRY_BS + property.getName(), elementMappingProperties);
                    }
                } else {
                    registry.put(queryPath +
                            CEPConstants.CEP_REGISTRY_BS +
                            CEPConstants.CEP_REGISTRY_OUTPUT +
                            CEPConstants.CEP_REGISTRY_BS +
                            CEPConstants.CEP_REGISTRY_XML_MAPPING, registry.newCollection());
                    Resource xmlMappingResource = registry.newResource();
                    xmlMappingResource.addProperty(CEPConstants.CEP_REGISTRY_TEXT, output.getXmlMapping().getMappingXMLText());
                    registry.put(queryPath +
                            CEPConstants.CEP_REGISTRY_BS +
                            CEPConstants.CEP_REGISTRY_OUTPUT +
                            CEPConstants.CEP_REGISTRY_BS +
                            CEPConstants.CEP_REGISTRY_XML_MAPPING +
View Full Code Here

    resource.setContent("Hello Out there!");*/

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

        Resource resource = registry.get(regPath);
        if (resource != null) {
            System.out.println("Resource Retrieved");
            return new String((byte[]) resource.getContent());
        }

        return "";
    }
View Full Code Here

                if (!scenarioId.equals(SecurityConstants.SCENARIO_DISABLE_SECURITY) &&
                        !scenarioId.equals(SecurityConstants.POLICY_FROM_REG_SCENARIO)) {
                    String resourceUri = SecurityConstants.SECURITY_POLICY + "/" + scenarioId;
                    if (!scenarioId.equals(SecurityConstants.SCENARIO_DISABLE_SECURITY) &&
                            !scenarioId.equals(SecurityConstants.POLICY_FROM_REG_SCENARIO)) {
                        Resource scenarioResource = tenantUserRegistry.newResource();
                        URL resource =
                                       IdentitySTSMgtServiceComponent.getBundleContext().
                                                                      getBundle().
                                                                      getResource(scenarioId +
                                                                                  "-policy.xml");
                        if (resource != null) {
                            scenarioResource.setContentStream(resource.openStream());
                            tenantUserRegistry.put(resourceUri, scenarioResource);
                        } else {
                            log.error("Could not load policy scenario " + scenarioId +
                                      " for tenant " + tenantId);
                        }
View Full Code Here

                SecurityScenarioDatabase.put(scenarioId, scenario);

                // Store the scenario in the Registry
                if (!scenarioId.equals(SecurityConstants.SCENARIO_DISABLE_SECURITY) &&
                        !scenarioId.equals(SecurityConstants.POLICY_FROM_REG_SCENARIO)) {
                    Resource scenarioResource = new ResourceImpl();
                    scenarioResource.setContentStream(
                            bundleContext.getBundle().getResource(scenarioId + "-policy.xml").openStream());
                    if (!registry.resourceExists(resourceUri)) {
                        registry.put(resourceUri, scenarioResource);
                    }
                }
View Full Code Here

                            </state>
                            <state name="Deprecated">
                            </state>
                        </lifecycle>
                 */
                Resource configurationResource = registry.get(configurationResourcePath);
                xmlContent = new String((byte[])configurationResource.getContent());
                configurationElement =  AXIOMUtil.stringToOM(xmlContent);
            }
            else {
                /* expected format in registry.xml
                *** opening aspect tag ***
 
View Full Code Here

        resource.setProperty(stateProperty, states.get(0));
        resource.setProperty(lifecycleProperty, aspectName);
    }

    public void invoke(RequestContext context, String action) throws RegistryException {
        Resource resource = context.getResource();
        String currentState = resource.getProperty(stateProperty);
        int stateIndex = states.indexOf(currentState);
        if (stateIndex == -1) {
            throw new RegistryException("State '" + currentState + "' is not valid!");
        }

        String newState;
        if (PROMOTE.equals(action)) {
            if (stateIndex == states.size() - 1) {
                throw new RegistryException("Can't promote beyond end of configured lifecycle!");
            }

            // Make sure all conditions are met
            List<Condition> conditions = transitions.get(currentState);
            if (conditions != null) {
                for (Condition condition : conditions) {
                    if (!condition.isTrue(resource)) {
                        throw new RegistryException(
                                "Condition failed - " + condition.getDescription());
                    }
                }
            }
            newState = states.get(stateIndex + 1);
        } else if (DEMOTE.equals(action)) {
            if (stateIndex == 0) {
                throw new RegistryException("Can't demote beyond start of configured lifecycle!");
            }
            newState = states.get(stateIndex - 1);
        }
        else {
          return;
        }
//        newState = states.get(stateIndex);
        resource.setProperty(stateProperty, newState);
        context.getRegistry().put(resource.getPath(), resource);
        Properties properties = resource.getProperties();
        String lifecycleScript = "";
        String lifecycleScriptCommand = "";
        for (Map.Entry<Object, Object> e : properties.entrySet()) {
            if (e.getKey() instanceof String) {
                String propName = (String) e.getKey();
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.