Package org.wso2.carbon.registry.core.session

Examples of org.wso2.carbon.registry.core.session.UserRegistry


            String dashboardConfigFile = dashboardDiskRoot + File.separator + "dashboard.xml";
            String gadgetsDiskLocation = dashboardDiskRoot + File.separator + "gadgets";

            // Check whether the system dashboard is already available if not populate
            UserRegistry registry = DashboardPopulatorContext.getRegistry(tenantId);

            // Set permission for annonymous read. We do it here because it should happen always in order
            // to support mounting a remote registry.
            AuthorizationManager accessControlAdmin =
                    registry.getUserRealm().getAuthorizationManager();

            if (!accessControlAdmin.isRoleAuthorized(CarbonConstants.REGISTRY_ANONNYMOUS_ROLE_NAME, RegistryConstants.CONFIG_REGISTRY_BASE_PATH +
                    GadgetPopulator.SYSTEM_GADGETS_PATH, ActionConstants.GET)) {
                accessControlAdmin.authorizeRole(CarbonConstants.REGISTRY_ANONNYMOUS_ROLE_NAME, RegistryConstants.CONFIG_REGISTRY_BASE_PATH +
                        GadgetPopulator.SYSTEM_GADGETS_PATH, ActionConstants.GET);
            }

            String serverName = CarbonUtils.getServerConfiguration().getFirstProperty("Name");

/*            String serverPrefix = serverName.indexOf("Business Activity Monitor") > -1 ? "bam" : "";

            if (serverName.length() > 0) {
                gadgetsPath = SYSTEM_GADGETS_PATH + "/" + serverPrefix;
            }*/

            if (!registry.resourceExists(REGISTRY_SYSTEM_DASHBOARDS_ROOT + "/" + serverName)) {
                // Creating an OMElement from file
                File dashboardConfigXml = new File(dashboardConfigFile);

                if (dashboardConfigXml.exists()) {
                    FileReader dashboardConfigXmlReader = new FileReader(dashboardConfigXml);

                    // Restoring from file
                    registry.restore(REGISTRY_SYSTEM_DASHBOARDS_ROOT, dashboardConfigXmlReader);

                    log.info("Successfully populated the default Dashboards.");

                } else {
                    log.info("Couldn't find a Dashboard at '" + dashboardConfigFile +
                            "'. Giving up.");
                }

                // Store gadgets
                File gadgetsDir = new File(gadgetsDiskLocation);
                if (gadgetsDir.exists()) {
                    GadgetPopulator.beginFileTansfer(gadgetsDir, tenantId);

                    log.info("Successfully populated the default Gadgets.");
                } else {
                    log.info("Couldn't find contents at '" + gadgetsDiskLocation +
                            "'. Giving up.");
                }
                registry.put(REGISTRY_SYSTEM_DASHBOARDS_ROOT + "/" + serverName, registry.newResource());
            }

        } catch (Exception e) {
            log.debug("Failed to activate Dashboard Populator for Governance bundle ");
        }
View Full Code Here


        try {

            // Storing the root path for future reference
            String rootPath = rootDirectory.getAbsolutePath();

            UserRegistry registry = DashboardPopulatorContext.getRegistry(tenantId);

            // Creating the default gadget collection resource
            Collection defaultGadgetCollection = registry.newCollection();
            try {
                registry.beginTransaction();
                registry.put(gadgetsPath, defaultGadgetCollection);

                transferDirectoryContentToRegistry(rootDirectory, registry, rootPath, tenantId);
                registry.commitTransaction();
            } catch (Exception e) {
                registry.rollbackTransaction();
                log.error(e.getMessage(), e);
            }


        } catch (DashboardPopulatorException e) {
View Full Code Here

            gadgetUrl = gadgetUrl.split("path=")[1];
        } else {
            //GS is not hosting this gadget
            return true;
        }
        UserRegistry registry = (UserRegistry) getConfigUserRegistry();
        return registry.getUserRealm().getAuthorizationManager().isUserAuthorized(user, gadgetUrl, ActionConstants.GET);
    }
View Full Code Here

import org.wso2.carbon.registry.core.session.UserRegistry;

public class CustomUIService extends RegistryAbstractAdmin implements ICustomUIService {

    public String getTextContent(String path) throws Exception {
        UserRegistry registry = (UserRegistry)getRootRegistry();
        return GetTextContentUtil.getTextContent(path, registry);
    }
View Full Code Here

        UserRegistry registry = (UserRegistry)getRootRegistry();
        return GetTextContentUtil.getTextContent(path, registry);
    }

    public boolean updateTextContent(String path, String content) throws Exception {
        UserRegistry registry = (UserRegistry)getRootRegistry();
        UpdateTextContentUtil.updateTextContent(path, content, registry);
        return true;
    }
View Full Code Here

    }

    public boolean addTextContent(
            String parentPath, String resourceName, String mediaType, String description, String content)
            throws Exception {
        UserRegistry registry = (UserRegistry)getRootRegistry();
        AddTextResourceUtil.addTextResource(parentPath, resourceName, mediaType, description, content, registry);
        return true;
    }
View Full Code Here

    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        try {
            UserRegistry registry = (UserRegistry) request.getSession().getAttribute(
                            RegistryConstants.ROOT_REGISTRY_INSTANCE);
            String path = request.getParameter("path");
            if (path == null) {
                String msg = "Could not get the resource content. Path is not specified.";
                log.error(msg);
                response.setStatus(400);
                return;
            }

            Resource resource = null;
            try {
                resource = registry.get(path);
            } catch (RegistryException e) {
                String msg = "Error retrieving the resource " + path + ". " + e.getMessage();
                log.error(msg, e);
                throw e;
            }
View Full Code Here

            // Storing the root path for future reference
            String rootPath = rootDirectory.getAbsolutePath();

            Registry registry = GadgetRepoPopulatorContext.getRegistry(tenantId);

            UserRegistry uReg = (UserRegistry) registry;

            // Creating the default gadget collection resource
            Collection defaultGadgetCollection = registry.newCollection();
            // Set permission for annonymous read
            AuthorizationManager authorizationManager = uReg.getUserRealm().getAuthorizationManager();
            authorizationManager.authorizeRole(CarbonConstants.REGISTRY_ANONNYMOUS_ROLE_NAME, RegistryConstants.CONFIG_REGISTRY_BASE_PATH +
                    SYSTEM_GS_GADGETS_PATH, ActionConstants.GET);

            /*authorizationManager.authorizeRole(RegistryConstants.GUESTS_ROLE,
                                             SYSTEM_GS_GADGETS_PATH, ActionConstants.GET);*/
 
View Full Code Here

    }

    public void addResource(String path, String mediaType, String description, DataHandler content,
                            String symlinkLocation)
            throws Exception {
        UserRegistry registry = (UserRegistry) getConfigUserRegistry();
        if (RegistryUtils.isRegistryReadOnly(registry.getRegistryContext())) {
            return;
        }
        addResourceToRegistry(path, mediaType, description, content, symlinkLocation, registry);
    }
View Full Code Here

    public void deploy(DeploymentFileData deploymentFileData) throws DeploymentException {
        try {
            // todo:Temporarily using tenant 0 till we sort out the multi-tenant deployment.
            int tenantId = 0;

            UserRegistry registry = getRegistry(tenantId);

            // Extracting archive
            String extractedArchiveDir = extractGarArchive(deploymentFileData.getAbsolutePath());

            // Set permission for anonymous read. We do it here because it should happen always in order
            // to support mounting a remote registry.

            if (registry != null) {
                AuthorizationManager accessControlAdmin =
                        registry.getUserRealm().getAuthorizationManager();

                if (!accessControlAdmin.isRoleAuthorized(CarbonConstants.REGISTRY_ANONNYMOUS_ROLE_NAME, RegistryConstants.CONFIG_REGISTRY_BASE_PATH +
                        REGISTRY_GADGET_STORAGE_PATH, ActionConstants.GET)) {
                    accessControlAdmin.authorizeRole(CarbonConstants.REGISTRY_ANONNYMOUS_ROLE_NAME, RegistryConstants.CONFIG_REGISTRY_BASE_PATH +
                            REGISTRY_GADGET_STORAGE_PATH, ActionConstants.GET);
View Full Code Here

TOP

Related Classes of org.wso2.carbon.registry.core.session.UserRegistry

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.