Package org.wso2.carbon.registry.core

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


                String regIdentifier = policyPath.substring(0, policyPath.lastIndexOf(':'));
                if (SecurityConstants.GOVERNANCE_REGISTRY_IDENTIFIER.equals(regIdentifier)) {
                    registryToLoad = govRegistry;
                }
            }
            Resource resource = registryToLoad.get(resourceUri);
            InputStream in = resource.getContentStream();

            XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(in);
            StAXOMBuilder builder = new StAXOMBuilder(parser);

            OMElement policyElement = builder.getDocumentElement();
View Full Code Here


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

        Resource resource = registry.get(servicePath);
        Association[] pvtStores = registry.getAssociations(servicePath,
                SecurityConstants.ASSOCIATION_PRIVATE_KEYSTORE);
        Association[] tstedStores = registry.getAssociations(servicePath,
                SecurityConstants.ASSOCIATION_TRUSTED_KEYSTORE);

        if (pvtStores != null && pvtStores.length > 0) {
            String keyAlias = null;
            ServerConfiguration serverConfig = ServerConfiguration.getInstance();
            keyAlias = serverConfig.getFirstProperty("Security.KeyStore.KeyAlias");
            cryptoProps.setProperty(ServerCrypto.PROP_ID_PRIVATE_STORE, privateKeyStore);
            cryptoProps.setProperty(ServerCrypto.PROP_ID_DEFAULT_ALIAS, keyAlias);
        }
        StringBuffer trustStores = new StringBuffer();

        for (Association assoc : tstedStores) {
            String tstedStore = assoc.getDestinationPath();
            String name = tstedStore.substring(tstedStore.lastIndexOf("/"));
            trustStores.append(name).append(",");
        }

        cryptoProps.setProperty(ServerCrypto.PROP_ID_TRUST_STORES, trustStores.toString());

        try {
            setServiceParameterElement(serviceName, RahasUtil.getSCTIssuerConfigParameter(
                    ServerCrypto.class.getName(), cryptoProps, -1, null, true, true));
            setServiceParameterElement(serviceName, RahasUtil.getTokenCancelerConfigParameter());
            resource.setProperty(SecurityConstants.PROP_RAHAS_SCT_ISSUER, "true");
            registry.put(servicePath, resource);

        } catch (Exception e) {
            throw new AxisFault("Could not configure Rahas parameters", e);
        }
View Full Code Here

                    && parameter.getValue() instanceof String) {
                parameter = ParameterUtil.createParameter(paramName.trim(),
                        (String) parameter.getValue(), parameter.isLocked());
            }
            if (parameter.getParameterElement() != null) {
                Resource paramResource = registry.newResource();
                paramResource.setContent(parameter.getParameterElement().toString());
                paramResource.addProperty(RegistryResources.NAME, parameter.getName());
                registry.put(servicePath + RegistryResources.PARAMETERS
                        + parameter.getName(), paramResource);
                paramResource.discard();
            }
        }
        if (!transactionStarted) {
            registry.commitTransaction();
        }
View Full Code Here

        String servicePath = RegistryResources.SERVICE_GROUPS
                + axisService.getAxisServiceGroup().getServiceGroupName()
                + RegistryResources.SERVICES + serviceName;
        try {
            if (registry.resourceExists(servicePath)) {
                Resource resource = registry.get(servicePath);
                if (resource.getProperty(SecurityConstants.PROP_RAHAS_SCT_ISSUER) != null) {
                    resource.removeProperty(SecurityConstants.PROP_RAHAS_SCT_ISSUER);
                    registry.put(servicePath, resource);
                }
            }
        } catch (Exception e) {
            throw new AxisFault("Could not configure Rahas parameters", e);
View Full Code Here

public class WSDLToolService extends AbstractAdmin {

    public void addMEXService(String path, ServiceInfoBean serviceInfo) throws Exception {
        Registry registry = getGovernanceRegistry();
        Resource resource = registry.newResource();
        //String parentPath = RegistryUtils.getParentPath(path);
        //String wsdlURL = serviceInfo.getWsdlURL();

        OMFactory fac = OMAbstractFactory.getOMFactory();
        OMElement serviceInfoElement = fac.createOMElement("wsdltool", null);

        if (serviceInfo.getOwnerName() != null) {
            OMElement childElement = fac.createOMElement("wsdlurl", null);
            childElement.setText(serviceInfo.getWsdlURL());
            serviceInfoElement.addChild(childElement);
        }

        if (serviceInfo.getOwnerName() != null) {
            OMElement childElement = fac.createOMElement("ownername", null);
            childElement.setText(serviceInfo.getOwnerName());
            serviceInfoElement.addChild(childElement);
        }

        if (serviceInfo.getOwnerAddress() != null) {
            OMElement childElement = fac.createOMElement("owneraddress", null);
            childElement.setText(serviceInfo.getOwnerAddress());
            serviceInfoElement.addChild(childElement);
        }

        if (serviceInfo.getOwnerTelephone() != null) {
            OMElement childElement = fac.createOMElement("ownertelephone", null);
            childElement.setText(serviceInfo.getOwnerTelephone());
            serviceInfoElement.addChild(childElement);
        }

        if (serviceInfo.getOwnerEmail() != null) {
            OMElement childElement = fac.createOMElement("owneremail", null);
            childElement.setText(serviceInfo.getOwnerEmail());
            serviceInfoElement.addChild(childElement);
        }

        if (serviceInfo.getDescription() != null) {
            OMElement childElement = fac.createOMElement("description", null);
            childElement.setText(serviceInfo.getDescription());
            serviceInfoElement.addChild(childElement);
        }

        String content = serviceInfoElement.toString();
        resource.setContent(content.getBytes());
        resource.setMediaType(RegistryConstants.MEX_MEDIA_TYPE);
        registry.put(path, resource);
    }
View Full Code Here

                sysRegistry.put(DashboardConstants.GS_REGISTRY_ROOT +
                                DashboardConstants.GADGET_PATH + gadgetName
                                + RegistryConstants.PATH_SEPARATOR + entryName, col);
            } else {
                //if a file, creating a resource
                Resource res = sysRegistry.newResource();
                try {
                    while ((i = zis.read(buff, 0, buff.length)) > 0) {
                        byteOut.write(buff, 0, i);
                    }
                } catch (IOException ioe) {
                    sysRegistry.rollbackTransaction();
                    log.error(ioe);
                }

                res.setContent(byteOut.toByteArray());

                // If entry is gadget xml then set its media type.
                if (entryName.contains(".xml")) {
                    res.setMediaType("application/vnd.wso2-gadget+xml");
                }

                sysRegistry.put(DashboardConstants.GS_REGISTRY_ROOT +
                                DashboardConstants.GADGET_PATH + gadgetName +
                                RegistryConstants.PATH_SEPARATOR + entryName, res);
View Full Code Here

            String parentCollectionPath = CEPConstants.CEP_CONF_ELE_CEP_BUCKETS + CEPConstants.CEP_REGISTRY_BS + bucket.getName();
            if (registry.resourceExists(parentCollectionPath)) {
                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());
//               registry.put(parentCollectionPath + CEPConstants.CEP_REGISTRY_BS + CEPConstants.CEP_REGISTRY_PROPERTIES, bucketProperties);

                String inputsCollectionPath = parentCollectionPath + CEPConstants.CEP_REGISTRY_BS + CEPConstants.CEP_REGISTRY_INPUTS;
                if (!registry.resourceExists(inputsCollectionPath)) {
                    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;
                if (registry.resourceExists(queriesCollectionPath)) {
                    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

                        }
                    } else {
                        String name = fullname.substring(fullname.lastIndexOf("/") + 1);
                        KeyStore store = keyMan.getKeyStore(name);
                        if (store.containsAlias(username)) {
                            Resource resource = (Resource) govRegistry.get(ks[i]);
                            CryptoUtil cryptoUtil = CryptoUtil.getDefaultCryptoUtil();
                            String encryptedPassword = resource
                                    .getProperty(SecurityConstants.PROP_PRIVATE_KEY_PASS);
                            password = new String(cryptoUtil
                                    .base64DecodeAndDecrypt(encryptedPassword));
                            break;
                        }
View Full Code Here

    }

    @SuppressWarnings("unchecked")
    public void invokeAspect(RequestContext requestContext) throws RegistryException {
        Map<String, String> parameters = new HashMap<String, String>();
        Resource resource = requestContext.getOldResource();
        String oldPath = resource.getPath();
        String stateKey = null;
        Properties props = resource.getProperties();
        String lcName = resource.getProperty("registry.LC.name");
        for (Object key : props.keySet()) {
            String propKey = (String)key;
            if (propKey.matches("registry\\p{Punct}lifecycle\\p{Punct}.*\\p{Punct}state")) {
                stateKey = propKey;
                break;
            }
        }
        if (stateKey == null) {
            return;
        }
        String relativeOldPath = RegistryUtils.getRelativePath(requestContext.getRegistryContext(),
                oldPath);
        String oldState = resource.getProperty(stateKey);
        if ((requestContext.getAspect() == null) || (requestContext.getAction() == null)) {
            return;
        }
        if (!requestContext.isProcessingComplete()) {
            Object parameterNames = requestContext.getProperty("parameterNames");
            if (parameterNames != null) {
                for (String key : (Set<String>)parameterNames) {
                    parameters.put(key, (String)requestContext.getProperty(key));
                }
                requestContext.getAspect().invoke(requestContext, requestContext.getAction(),
                        parameters);
            } else {
                requestContext.getAspect().invoke(requestContext, requestContext.getAction());
            }
            requestContext.setProcessingComplete(true);
        }
        String path = requestContext.getResourcePath().getPath();
        String relativePath = RegistryUtils.getRelativePath(requestContext.getRegistryContext(),
                path);
        resource = requestContext.getRepository().get(path);
        if (resource == null) {
            return;
        }
        String newState = resource.getProperty(stateKey);
        if (oldState != null && oldState.equalsIgnoreCase(newState)) {
            return;
        }
        String extendedMessage = "";
        if (!oldPath.equals(path)) {
View Full Code Here

                            + dashboardName
                            + DashboardConstants.GADGET_PATH
                            + indGadgetId;
                }

                Resource currentGadget;
                try {
                    currentGadget = registry.get(gadgetPath);

                    String gadgetUrlTmp = currentGadget
                            .getProperty(DashboardConstants.GADGET_URL);

                    if (isGadgetAutharized(userId, gadgetUrlTmp)) {
                        gadgetUrlsList.add(gadgetUrlTmp);
                    }
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.