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

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


        UserRegistry registry = (UserRegistry) configSystemRegistry;
        return registry.resourceExists(queryPath);
    }

    private void defineQueries(Registry configSystemRegistry, String queryPath, String queryContent) throws RegistryException {
        UserRegistry registry =
                (UserRegistry) configSystemRegistry;

        Resource q1 = registry.newResource();
        q1.setContent(queryContent);
        q1.setMediaType(RegistryConstants.SQL_QUERY_MEDIA_TYPE);
        q1.addProperty(RegistryConstants.RESULT_TYPE_PROPERTY_NAME,
                       RegistryConstants.RESOURCES_RESULT_TYPE);
        registry.put(queryPath, q1);

    }
View Full Code Here


            throws RegistryException {
        Registry registry = requestContext.getRegistry();
        RealmService realmService = registry.getRegistryContext().getRealmService();
        String systemUser = CarbonConstants.REGISTRY_SYSTEM_USERNAME;

        return new UserRegistry(systemUser, CurrentSession.getTenantId(), registry,
                realmService, null);
    }
View Full Code Here

    private static final Log log = LogFactory.getLog(TopicUtil.class);

    public static TopicBean getTopicBean(String path) throws Exception {

        try {
            UserRegistry registry = CommonUtil.getRegistry();

            Resource r = registry.get(path);
            if (!(r instanceof Collection)) {
                String msg = path + " is not a collection. Topics should be collections.";
                log.error(msg);
                throw new TopicException(msg);
            }
View Full Code Here

     * @return The properties bean.
     *
     * @throws RegistryException throws if there is an error.
     */
    public PropertiesBean getProperties(String path, String viewProps) throws RegistryException {
        UserRegistry registry = (UserRegistry)getRootRegistry();
        return PropertiesBeanPopulator.populate(registry, path, viewProps);
    }
View Full Code Here

     * @param value property value.
     *
     * @throws RegistryException throws if there is an error.
     */
    public void setProperty(String path, String name, String value) throws RegistryException {
        UserRegistry registry = (UserRegistry) getRootRegistry();
        if (RegistryUtils.isRegistryReadOnly(registry.getRegistryContext())) {
            return;
        }
        Resource resource = registry.get(path);
        resource.addProperty(name, value);
        registry.put(resource.getPath(), resource);
        resource.discard();
    }
View Full Code Here

     *
     * @throws RegistryException throws if there is an error.
     */
    public void updateProperty(String path, String name, String value, String oldName) throws
            RegistryException {
        UserRegistry registry = (UserRegistry) getRootRegistry();
        if (RegistryUtils.isRegistryReadOnly(registry.getRegistryContext())) {
            return;
        }
        Resource resource = registry.get(path);
        if (oldName.equals(name)) {
            resource.setProperty(name, value);
        } else {
            resource.setProperty(name, value);
            resource.removeProperty(oldName);
        }
        registry.put(resource.getPath(), resource);
        resource.discard();
    }
View Full Code Here

     * @param name property name.
     *
     * @throws RegistryException throws if there is an error.
     */
    public void removeProperty(String path, String name) throws RegistryException {
        UserRegistry registry = (UserRegistry) getRootRegistry();
        if (RegistryUtils.isRegistryReadOnly(registry.getRegistryContext())) {
            return;
        }
        Resource resource = registry.get(path);
        resource.removeProperty(name);
        registry.put(resource.getPath(), resource);
        resource.discard();
    }
View Full Code Here

     * @param bean RetentionBean which encapsulates retention properties
     * @return true if operation succeeds false otherwise
     * @throws RegistryException
     */
    public boolean setRetentionProperties(String path, RetentionBean bean) throws RegistryException {
        UserRegistry registry = (UserRegistry) getRootRegistry();
        if (RegistryUtils.isRegistryReadOnly(registry.getRegistryContext())) {
            return false;
        }
        Resource resource = registry.get(path);
        if (resource.getProperty(CommonConstants.RETENTION_USERNAME_PROP_NAME) != null &&
                !resource.getProperty(CommonConstants.RETENTION_USERNAME_PROP_NAME).equals(
                        registry.getUserName())) {
            throw new RegistryException("User is not authorized to change retention properties" +
                    " of this resource. Resource path = " + path);
        }

        if (bean == null) {
            resource.removeProperty(CommonConstants.RETENTION_USERNAME_PROP_NAME);
            resource.removeProperty(CommonConstants.RETENTION_FROM_DATE_PROP_NAME);
            resource.removeProperty(CommonConstants.RETENTION_TO_DATE_PROP_NAME);
            resource.removeProperty(CommonConstants.RETENTION_WRITE_LOCKED_PROP_NAME);
            resource.removeProperty(CommonConstants.RETENTION_DELETE_LOCKED_PROP_NAME);
        } else {
            resource.setProperty(CommonConstants.RETENTION_USERNAME_PROP_NAME, registry.getUserName());
            resource.setProperty(CommonConstants.RETENTION_FROM_DATE_PROP_NAME, bean.getFromDate());
            resource.setProperty(CommonConstants.RETENTION_TO_DATE_PROP_NAME, bean.getToDate());
            resource.setProperty(CommonConstants.RETENTION_WRITE_LOCKED_PROP_NAME,
                    String.valueOf(bean.getWriteLocked()));
            resource.setProperty(CommonConstants.RETENTION_DELETE_LOCKED_PROP_NAME,
                    String.valueOf(bean.getDeleteLocked()));
        }
        registry.put(resource.getPath(), resource);
        return true;
    }
View Full Code Here

     * @param path path of the resource
     * @return RetentionBean which encapsulates retention properties
     * @throws RegistryException
     */
    public RetentionBean getRetentionProperties(String path) throws RegistryException {
        UserRegistry registry = (UserRegistry) getRootRegistry();
        Resource resource = registry.get(path);

        RetentionBean bean = new RetentionBean();
        String userName = resource.getProperty(CommonConstants.RETENTION_USERNAME_PROP_NAME);
        if (userName == null) {
            /* Consistency is assumed. If this property is not set, that means no retention for that
            resource
             */
            return null;
        }
        bean.setUserName(userName);
        bean.setFromDate(resource.getProperty(CommonConstants.RETENTION_FROM_DATE_PROP_NAME));
        bean.setToDate(resource.getProperty(CommonConstants.RETENTION_TO_DATE_PROP_NAME));
        bean.setWriteLocked(Boolean.parseBoolean(resource.getProperty(
                CommonConstants.RETENTION_WRITE_LOCKED_PROP_NAME)));
        bean.setDeleteLocked(Boolean.parseBoolean(resource.getProperty(
                CommonConstants.RETENTION_DELETE_LOCKED_PROP_NAME)));
        bean.setReadOnly(!userName.equals(registry.getUserName()));
        return bean;
    }
View Full Code Here

        return getRegistry(request);
    }

    public static UserRegistry getRegistry(HttpServletRequest request) throws RegistryException {

        UserRegistry registry =
                (UserRegistry) request.getSession().getAttribute(RegistryConstants.USER_REGISTRY);

        if (registry == null) {
            String msg = "User's Registry instance is not found. " +
                    "Users have to login to retrieve a registry instance. ";
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.