Package org.wso2.carbon.registry.core

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


    private Boolean isAnonModeActive(String tDomain) {
        Boolean response = false;

        try {
            Registry registry = DashboardContext.getRegistry(MultitenantUtils.getTenantId(DashboardContext.getConfigContext()));

            Resource regAdminDataResource;
            if (registry.resourceExists(
                    DashboardConstants.REGISTRY_ADMIN_PROPERTIES_PATH)) {
                regAdminDataResource = registry.get(
                        DashboardConstants.REGISTRY_ADMIN_PROPERTIES_PATH);

                String storedValue = regAdminDataResource
                        .getProperty(
                                DashboardConstants.ANON_MODE_ACT);
View Full Code Here


     * A custom query to retrieve gadget data for unsigned users
     *
     * @return array of strings containing the gadget name and URLs
     */
    private String[] getGadgetUrlSetForUnSignedUser() {
        Registry registry;
        try {
            registry = getConfigSystemRegistry();
            Resource comQuery = registry.newResource();

            String sql = "SELECT R.REG_NAME, R.REG_PATH_ID FROM REG_RESOURCE R, REG_PROPERTY P, REG_RESOURCE_PROPERTY RP, REG_PATH PA WHERE "
                    + "R.REG_VERSION=RP.REG_VERSION AND "
                    + "P.REG_NAME='"
                    + DashboardConstants.UNSIGNED_USER_GADGET
                    + "' AND "
                    + "P.REG_VALUE='true' AND "
                    + "P.REG_ID=RP.REG_PROPERTY_ID AND "
                    + "PA.REG_PATH_ID=R.REG_PATH_ID";

            HashMap<String, String> map = new HashMap<String, String>();
            map.put("query", sql);
            Collection qResults = registry.executeQuery(null, map);

            String[] qPaths = (String[]) qResults.getContent();
            ArrayList gadgetUrlsList = new ArrayList();

            for (String qPath : qPaths) {
                if (registry.resourceExists(qPath)) {
                    Resource tempRes = registry.get(qPath);
                    String gadgetNameTmp = tempRes.getProperty(DashboardConstants.GADGET_NAME);
                    String gadgetUrlTmp = tempRes.getProperty(DashboardConstants.GADGET_URL);
                    if (isGadgetAutharized(CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME, gadgetUrlTmp)) {
                        gadgetUrlsList.add(gadgetNameTmp + "," + gadgetUrlTmp);
                    }
View Full Code Here

* The service pick gadget specs from the registry and returns them to the FE
*/
public class GadgetContentDownloadService extends AbstractAdmin {
    public Registry getRootRegistry() throws Exception {
        if (getHttpSession() != null) {
            Registry registry =
                    (Registry) getHttpSession().getAttribute(
                            RegistryConstants.ROOT_REGISTRY_INSTANCE);
            if (registry != null) {
                return registry;
            } else {
View Full Code Here

    }


    private static void addToRegistry(String rootPath, File file) {
        try {
            Registry registry = DashboardPopulatorContext.getRegistry();

            // This path is used to store the file resource under registry
            String fileRegistryPath =
                    SYSTEM_GADGETS_PATH + file.getAbsolutePath().substring(rootPath.length())
                            .replaceAll("[/\\\\]+", "/");

            // Adding the file to the Registry            
            Resource fileResource = registry.newResource();
            fileResource.setMediaType(new MimetypesFileTypeMap().getContentType(file));
            fileResource.setContentStream(new FileInputStream(file));
            registry.put(fileRegistryPath, fileResource);

        } catch (DashboardPopulatorException e) {
            log.error(e);
        } catch (RegistryException e) {
            log.error(e);
View Full Code Here

     *
     * @throws GovernanceException if the operation failed.
     */
    public void loadEndpointDetails() throws GovernanceException {
        checkRegistryResourceAssociation();
        Registry registry = getAssociatedRegistry();
        String path = getPath();
        String id = getId();
        Resource resource;
        try {
            resource = registry.get(path);
            Object contentObj = resource.getContent();
            if (contentObj instanceof String) {
                url = (String) contentObj;
            } else {
                byte[] content = (byte[]) contentObj;
View Full Code Here

        return admin.getStoreEntries(keyStoreName);
    }

    private void persistTrustedService(String groupName, String serviceName, String trustedService,
            String certAlias) throws SecurityConfigException {
        Registry registry;
        String resourcePath;
        Resource resource;
        try {
            resourcePath = RegistryResources.SERVICE_GROUPS + groupName
                    + RegistryResources.SERVICES + serviceName + "/trustedServices";
            registry = getConfigSystemRegistry(); //TODO: Multitenancy
            if (registry != null) {
                if (registry.resourceExists(resourcePath)) {
                    resource = registry.get(resourcePath);
                } else {
                    resource = registry.newResource();
                }
                if (resource.getProperty(trustedService) != null) {
                    resource.removeProperty(trustedService);
                }
                resource.addProperty(trustedService, certAlias);
                registry.put(resourcePath, resource);
            }
        } catch (Exception e) {
            log.error("Error occured while adding trusted service for STS", e);
            throw new SecurityConfigException("Error occured while adding trusted service for STS",
                    e);
View Full Code Here

        }
    }

    private void removeTrustedService(String groupName, String serviceName, String trustedService)
            throws SecurityConfigException {
        Registry registry;
        String resourcePath;
        Resource resource;
        try {
            resourcePath = RegistryResources.SERVICE_GROUPS + groupName
                    + RegistryResources.SERVICES + serviceName + "/trustedServices";
            registry = getConfigSystemRegistry(); //TODO: Multitenancy
            if (registry != null) {
                if (registry.resourceExists(resourcePath)) {
                    resource = registry.get(resourcePath);
                    if (resource.getProperty(trustedService) != null) {
                        resource.removeProperty(trustedService);
                    }
                    registry.put(resourcePath, resource);
                }
            }
        } catch (Exception e) {
            log.error("Error occured while removing trusted service for STS", e);
            throw new SecurityConfigException("Error occured while adding trusted service for STS",
View Full Code Here

     * @throws ServerRolesException - if operation fails
     */
    public String[] readServerRoles(String serverRoleType) throws ServerRolesException {
        log.debug("Reading " + serverRoleType + " Server-Roles from Registry.");

        Registry configReg = getConfigSystemRegistry();
        String regPath = this.getRegistryPath(serverRoleType);
        List<String> serverRolesList;
        Resource resource = this.getResourceFromRegistry(configReg, regPath);

        if (ServerRoleConstants.DEFAULT_ROLES_ID.equals(serverRoleType)) {
            String modified;
            List<String> productServerRolesList = ServerRoleUtils.readProductServerRoles();

            if (resource == null) {
                try {
                    resource = configReg.newResource();
                    resource.setProperty(serverRoleType, productServerRolesList);
                    resource.setProperty(ServerRoleConstants.MODIFIED_TAG,
                            ServerRoleConstants.MODIFIED_TAG_FALSE);
                    this.putResourceToRegistry(configReg, resource, regPath);
                } catch (RegistryException e) {
View Full Code Here

     */
    public boolean removeServerRoles(String[] serverRolesArray, String serverRoleType)
            throws ServerRolesException {
        log.debug("Removing " + serverRoleType + " Server-Roles from Registry.");
        boolean status = false;
        Registry configReg = getConfigSystemRegistry();
        String regPath = this.getRegistryPath(serverRoleType);

        List<String> serverRolesListToRemove = ServerRoleUtils.arrayToList(serverRolesArray);
        if ((serverRolesArray != null) && (serverRolesArray.length != 0)) {
            Resource resource = this.getResourceFromRegistry(configReg, regPath);
View Full Code Here

    public boolean addServerRoles(String[] serverRolesArray, String serverRoleType)
            throws ServerRolesException {
        log.debug("Adding " + serverRoleType + " Server-Roles to Registry.");

        boolean status = false;
        Registry configReg = getConfigSystemRegistry();
        String regPath = this.getRegistryPath(serverRoleType);

        if (serverRolesArray != null && serverRolesArray.length != 0) {
            List<String> serverRolesListToAdd = ServerRoleUtils.arrayToList(serverRolesArray);

            Resource resource = this.getResourceFromRegistry(configReg, regPath);
            if (resource == null) {
                try {
                    resource = configReg.newResource();
                    resource.setProperty(serverRoleType, serverRolesListToAdd);
                } catch (RegistryException e) {
                    this.handleException(e.getMessage(), e);
                }
            } else {
View Full Code Here

TOP

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

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.