Package org.wso2.carbon.registry.core

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


        try {
            if (states.size() == 0) {
                Registry registry = context.getRegistry();
                String xmlContent = "";
                if (isConfigurationFromResource) {
                    Resource configurationResource = registry.get(configurationResourcePath);
                    xmlContent = new String((byte[])configurationResource.getContent());
                    configurationElement =  AXIOMUtil.stringToOM(xmlContent);
                }

                Iterator stateElements = configurationElement.getChildElements();
                while (stateElements.hasNext()) {
                    OMElement stateEl = (OMElement)stateElements.next();
                    String name = stateEl.getAttributeValue(new QName("name"));
                    if (name == null) {
                        throw new IllegalArgumentException("Must have a name attribute for each state");
                    }

                    states.add(name);
                }
            }
        }
        catch (Exception e) {
            throw new RuntimeException("Resource does not contain valid XML configuration: " + e.toString());
        }

        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);
            resource.removeProperty(lifecycleProperty);
        }
    }
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("scenarios/" + scenarioId + "-policy.xml").openStream());
                    if (!registry.resourceExists(resourceUri)) {
                        registry.put(resourceUri, scenarioResource);
                    }
View Full Code Here

            }
            if (!registry.resourceExists(SecurityConstants.KEY_STORES)) {
                Collection kstores = registry.newCollection();
                registry.put(SecurityConstants.KEY_STORES, kstores);

                Resource primResource = registry.newResource();
                if (!registry.resourceExists(RegistryResources.SecurityManagement.PRIMARY_KEYSTORE_PHANTOM_RESOURCE)) {
                    registry.put(RegistryResources.SecurityManagement.PRIMARY_KEYSTORE_PHANTOM_RESOURCE,
                                 primResource);
                }
            }
View Full Code Here

                param2.setName("disableREST"); // TODO Find the constant
                param2.setValue(Boolean.TRUE.toString());
                service.addParameter(param2);
            }

            Resource serviceResource = configRegistry.get(servicePath);
            if (serviceResource.getProperty(SecurityConstants.PROP_RAHAS_SCT_ISSUER) != null) {

                Association[] pvtStores = rootRegistry.getAssociations(RegistryConstants.CONFIG_REGISTRY_BASE_PATH +
                                                                       servicePath,
                                                                       SecurityConstants.ASSOCIATION_PRIVATE_KEYSTORE);
View Full Code Here

           
            Registry registry = SecurityServiceHolder.getRegistryService().getConfigSystemRegistry(tenantID);
            String servicePath = RegistryResources.SERVICE_GROUPS
                    + service.getAxisServiceGroup().getServiceGroupName()
                    + RegistryResources.SERVICES + service.getName();
            Resource serviceResource = null;
            if (registry.resourceExists(servicePath)) {
                serviceResource = registry.get(servicePath);
            } else {
                return InvocationResponse.CONTINUE;
            }

            if (serviceResource != null) {
                if (serviceResource.getProperty(RegistryResources.ServiceProperties.IS_UT_ENABLED) == null) {
                    //TODO: We specifically have to check for UT auth
                    return InvocationResponse.CONTINUE;
                }
            } else {
                return InvocationResponse.CONTINUE;
View Full Code Here

        }
    }

    public void put(RequestContext requestContext) throws RegistryException {
        String path = requestContext.getResourcePath().getPath();
        Resource resource = requestContext.getResource();
        if (resource == null || resource.getProperties() == null) {
            return;
        }
        boolean allItemsAreChecked = true;
        String currentState = null;
        String lastState = resource.getProperty("registry.dlcm.last.state");
        String aspectName = resource.getProperty("registry.LC.name");
        Properties props = resource.getProperties();
        Iterator iKeys = props.keySet().iterator();
        while (iKeys.hasNext()) {
            String propKey = (String) iKeys.next();
            if (propKey.matches("registry\\p{Punct}lifecycle\\p{Punct}.*\\p{Punct}state")) {
                currentState = resource.getProperty(propKey);
                if (lastState != null) {
                    break;
                }
            }
        }
        if (currentState == null || (lastState != null && lastState.equals(currentState))) {
            return;
        }
        iKeys = props.keySet().iterator();
        while (iKeys.hasNext()) {
            String propKey = (String) iKeys.next();
            if (propKey.matches("registry\\p{Punct}.*\\p{Punct}checklist\\p{Punct}.*")) {
                List<String> propValues = (List<String>) props.get(propKey);
                if (propValues == null)
                    continue;
                if (propValues.size() > 2) {
                    String value = null;
                    String lifeCycleState = null;
                    for (String param : propValues) {
                        if (param.startsWith("status:")) {
                            lifeCycleState = param.substring(7);
                        } else if (param.startsWith("value:")) {
                            value = param.substring(6);
                        }
                    }
                    if ((lifeCycleState != null) && (value != null)) {
                        if (lifeCycleState.equalsIgnoreCase(currentState)) {
                            if (value.equalsIgnoreCase("false")) {
                                allItemsAreChecked = false;
                                break;
                            }
                        }
                    }
                }
            }
        }
        if (!allItemsAreChecked) {
            return;
        }
        String[] actions = null;
        try {
            Resource oldResource = requestContext.getRepository().get(path);
            requestContext.getRepository().put(path, resource);
            actions = requestContext.getRegistry().getAspectActions(path, aspectName);
            requestContext.getRepository().put(path, oldResource);
            if (actions == null) {
                return;
View Full Code Here

                try {
                    boolean transactionStarted = Transaction.isStarted();
                    if (!transactionStarted) {
                        registry.beginTransaction();
                    }
                    Resource resource = registry.get(servicePath);
                    resource.removeProperty(RegistryResources.ServiceProperties.IS_UT_ENABLED);
                    List<String> transports = getAllTransports();
                    setServiceTransports(serviceName, transports);

                    // Fire the transport binding added event
                    AxisEvent event = new AxisEvent(CarbonConstants.AxisEvent.TRANSPORT_BINDING_ADDED,
                            service);
                    axisConfig.notifyObservers(event, service);

                    resource.setProperty(
                            RegistryResources.ServiceProperties.EXPOSED_ON_ALL_TANSPORTS,
                            Boolean.TRUE.toString());

                    for (String trans : transports) {
                        if (trans.endsWith("https")) {
                            continue;
                        }
                        String transPath = RegistryResources.TRANSPORTS + trans;
                        if (registry.resourceExists(transPath)) {
                            registry.addAssociation(servicePath, transPath,
                                    RegistryResources.Associations.EXPOSED_TRANSPORTS);
                        } else {
                            String msg = "Transport path " + transPath + " does not exist in the registry";
                            log.error(msg);
                            throw new AxisFault(msg);
                        }
                    }

                    registry.put(resource.getPath(), resource);
                    if (!transactionStarted) {
                        registry.commitTransaction();
                    }

                } catch (RegistryException e) {
View Full Code Here

                    boolean transactionStarted = Transaction.isStarted();
                    if (!transactionStarted) {
                        registry.beginTransaction();
                    }
                   
                    Resource resource = registry.get(servicePath);
                    resource.setProperty(
                            RegistryResources.ServiceProperties.EXPOSED_ON_ALL_TANSPORTS,
                            Boolean.FALSE.toString());
                    resource.setProperty(RegistryResources.ServiceProperties.IS_UT_ENABLED,
                            Boolean.TRUE.toString());

                    Association[] exposedTransports =
                            registry.getAssociations(servicePath,
                                                     RegistryResources.Associations.EXPOSED_TRANSPORTS);
                    boolean isExists = false;
                    // TODO : Handle generally as axis2 parameters
                    for (Association assoc : exposedTransports) {
                        String transport = assoc.getDestinationPath();
                        if (transport.endsWith("https")) {
                            isExists = true;
                            continue;
                        }
                        if (registry.resourceExists(transport)) {
                            registry.removeAssociation(servicePath, transport,
                                    RegistryResources.Associations.EXPOSED_TRANSPORTS);
                        } else {
                            String msg = "Transport resource " + transport + " not available in Registry";
                            log.error(msg);
                            throw new AxisFault(msg);
                        }
                    }

                    if (!isExists) {
                        String transportResourcePath = RegistryResources.TRANSPORTS + "https" + "/listener";
                        if (registry.resourceExists(transportResourcePath)) {
                            registry.addAssociation(servicePath, transportResourcePath,
                                    RegistryResources.Associations.EXPOSED_TRANSPORTS);
                        } else {
                            String msg = "Transport resource " + transportResourcePath + " not available in Registry";
                            log.error(msg);
                            throw new AxisFault(msg);
                        }
                    }

                    registry.put(resource.getPath(), resource);
                    if (!transactionStarted) {
                        registry.commitTransaction();
                    }
                } catch (RegistryException e) {
                    registry.rollbackTransaction();
View Full Code Here

        if (url == null) {
            ServiceHolder serviceHodler = ServiceHolder.getInstance();
            RegistryService regService = serviceHodler.getRegistryService();
            Registry systemRegistry = regService.getConfigSystemRegistry();
            Resource resource = systemRegistry.get("/carbon/connection/props");
            String servicePath = resource.getProperty("service-path");
            String contextRoot = resource.getProperty("context-root");

            String host = resource.getProperty("host-name");
            contextRoot = contextRoot.equals("/") ? "" : contextRoot;

            host = (host == null) ? "localhost" : host;
            String port = System.getProperty("carbon.https.port");
            url = "https://" + host + ":" + port + "/" + contextRoot + servicePath + "/";
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.