Examples of NameFactory


Examples of org.apache.jackrabbit.spi.NameFactory

            // a future attempt to put the node under version control again
            // (see JCR-3115)
           
            log.info("trying to rename version history of node " + node.getId());

            NameFactory nf = NameFactoryImpl.getInstance();
           
            // Name of VHR in parent folder is ID of versionable node
            Name vhrname = nf.create(Name.NS_DEFAULT_URI, node.getId().toString());

            try {
                NodeState vhrState = versionManager.getPersistenceManager().load(vhid);
                NodeState vhrParentState = versionManager.getPersistenceManager().load(vhrState.getParentId());
               
                if (vhrParentState.hasChildNodeEntry(vhrname)) {
                    NodeState modifiedParent = (NodeState) vworkspaceChanges.get(vhrState.getParentId());
                    if (modifiedParent == null) {
                        modifiedParent = new NodeState(vhrParentState, NodeState.STATUS_EXISTING_MODIFIED, true);
                    }
                   
                    Calendar now = Calendar.getInstance();
                    String appendme = " (disconnected by RepositoryChecker on "
                            + ISO8601.format(now) + ")";
                    modifiedParent.renameChildNodeEntry(vhid,
                            nf.create(vhrname.getNamespaceURI(), vhrname.getLocalName() + appendme));

                    vworkspaceChanges.modified(modifiedParent);
                }
                else {
                    log.info("child node entry " + vhrname + " for version history not found inside parent folder.");
View Full Code Here

Examples of org.apache.jackrabbit.spi.NameFactory

        return repository;
    }

    protected RepositoryService createService(String uri) throws RepositoryException {
        IdFactory idFactory = IdFactoryImpl.getInstance();
        NameFactory nFactory = NameFactoryImpl.getInstance();
        PathFactory pFactory = PathFactoryImpl.getInstance();
        QValueFactory vFactory = QValueFactoryImpl.getInstance();
        return new RepositoryServiceImpl(uri, idFactory, nFactory, pFactory, vFactory);
    }
View Full Code Here

Examples of org.apache.jackrabbit.spi.NameFactory

                // REFERENCE value constraints
                if (propertyDefs[i].getRequiredType() == PropertyType.REFERENCE) {
                    String[] ca = propertyDefs[i].getValueConstraints();
                    if (ca != null) {
                        for (int j = 0; j < ca.length; j++) {
                            NameFactory factory = NameFactoryImpl.getInstance();
                            Name ntName = factory.create(ca[j]);
                            if (!name.equals(ntName)) {
                                deps.add(ntName);
                            }
                        }
                    }
View Full Code Here

Examples of org.jboss.dna.graph.properties.NameFactory

    protected synchronized FederatedRepositoryConfig getRepositoryConfiguration( ExecutionContext context,
                                                                                 RepositoryConnectionFactory connectionFactory ) {
        Problems problems = new SimpleProblems();
        ValueFactories valueFactories = context.getValueFactories();
        PathFactory pathFactory = valueFactories.getPathFactory();
        NameFactory nameFactory = valueFactories.getNameFactory();
        ValueFactory<Long> longFactory = valueFactories.getLongFactory();

        // Create the configuration projection ...
        ProjectionParser projectionParser = ProjectionParser.getInstance();
        String ruleStr = "/dna:system => " + this.getConfigurationSourcePath();
        Projection.Rule[] rules = projectionParser.rulesFromStrings(context, ruleStr);
        Projection configurationProjection = new Projection(this.getConfigurationSourceName(), rules);

        // Create a federating command executor to execute the commands and merge the results into a single set of
        // commands.
        final String configurationSourceName = configurationProjection.getSourceName();
        List<Projection> projections = Collections.singletonList(configurationProjection);
        CommandExecutor executor = null;
        if (configurationProjection.getRules().size() == 0) {
            // There is no projection for the configuration repository, so just use a no-op executor
            executor = new NoOpCommandExecutor(context, configurationSourceName);
        } else if (configurationProjection.isSimple()) {
            // There is just a single projection for the configuration repository, so just use an executor that
            // translates the paths using the projection
            executor = new SingleProjectionCommandExecutor(context, configurationSourceName, configurationProjection,
                                                           connectionFactory);
        } else {
            // The configuration repository has more than one projection, so we need to merge the results
            executor = new FederatingCommandExecutor(context, configurationSourceName, projections, connectionFactory);
        }
        // Wrap the executor with a logging executor ...
        executor = new LoggingCommandExecutor(executor, context.getLogger(getClass()), Logger.Level.DEBUG);

        // The configuration projection (via "executor") will convert this path into a path that exists in the configuration
        // repository
        Path configNode = pathFactory.create(PATH_TO_CONFIGURATION_INFORMATION);

        try {
            // Get the repository node ...
            BasicGetNodeCommand getRepository = new BasicGetNodeCommand(configNode);
            executor.execute(getRepository);
            if (getRepository.hasError()) {
                throw new FederationException(FederationI18n.federatedRepositoryCannotBeFound.text(repositoryName));
            }

            // Get the first child node of the "dna:cache" node, since this represents the source used as the cache ...
            Path cacheNode = pathFactory.create(configNode, nameFactory.create(DNA_CACHE_SEGMENT));
            BasicGetChildrenCommand getCacheSource = new BasicGetChildrenCommand(cacheNode);

            executor.execute(getCacheSource);
            if (getCacheSource.hasError() || getCacheSource.getChildren().size() < 1) {
                I18n msg = FederationI18n.requiredNodeDoesNotExistRelativeToNode;
                throw new FederationException(msg.text(DNA_CACHE_SEGMENT, configNode));
            }

            // Add a command to get the projection defining the cache ...
            Path pathToCacheRegion = pathFactory.create(cacheNode, getCacheSource.getChildren().get(0));
            BasicGetNodeCommand getCacheRegion = new BasicGetNodeCommand(pathToCacheRegion);
            executor.execute(getCacheRegion);
            Projection cacheProjection = createProjection(context,
                                                          projectionParser,
                                                          getCacheRegion.getPath(),
                                                          getCacheRegion.getPropertiesByName(),
                                                          problems);

            if (getCacheRegion.hasError()) {
                I18n msg = FederationI18n.requiredNodeDoesNotExistRelativeToNode;
                throw new FederationException(msg.text(DNA_CACHE_SEGMENT, configNode));
            }

            // Get the source projections for the repository ...
            Path projectionsNode = pathFactory.create(configNode, nameFactory.create(DNA_PROJECTIONS_SEGMENT));
            BasicGetChildrenCommand getProjections = new BasicGetChildrenCommand(projectionsNode);

            executor.execute(getProjections);
            if (getProjections.hasError()) {
                I18n msg = FederationI18n.requiredNodeDoesNotExistRelativeToNode;
                throw new FederationException(msg.text(DNA_PROJECTIONS_SEGMENT, configNode));
            }

            // Build the commands to get each of the projections (children of the "dna:projections" node) ...
            List<Projection> sourceProjections = new LinkedList<Projection>();
            if (getProjections.hasNoError() && !getProjections.getChildren().isEmpty()) {
                BasicCompositeCommand commands = new BasicCompositeCommand();
                for (Path.Segment child : getProjections.getChildren()) {
                    final Path pathToSource = pathFactory.create(projectionsNode, child);
                    commands.add(new BasicGetNodeCommand(pathToSource));
                }
                // Now execute these commands ...
                executor.execute(commands);

                // Iterate over each region node obtained ...
                for (GraphCommand command : commands) {
                    BasicGetNodeCommand getProjectionCommand = (BasicGetNodeCommand)command;
                    if (getProjectionCommand.hasNoError()) {
                        Projection projection = createProjection(context,
                                                                 projectionParser,
                                                                 getProjectionCommand.getPath(),
                                                                 getProjectionCommand.getPropertiesByName(),
                                                                 problems);
                        if (projection != null) {
                            Logger logger = context.getLogger(getClass());
                            if (logger.isTraceEnabled()) {
                                logger.trace("Adding projection to federated repository {0}: {1}",
                                             getRepositoryName(),
                                             projection);
                            }
                            sourceProjections.add(projection);
                        }
                    }
                }
            }

            // Look for the default cache policy ...
            BasicCachePolicy cachePolicy = new BasicCachePolicy();
            Property timeToLiveProperty = getRepository.getPropertiesByName().get(nameFactory.create(CACHE_POLICY_TIME_TO_LIVE_CONFIG_PROPERTY_NAME));
            if (timeToLiveProperty != null && !timeToLiveProperty.isEmpty()) {
                cachePolicy.setTimeToLive(longFactory.create(timeToLiveProperty.getValues().next()), TimeUnit.MILLISECONDS);
            }
            CachePolicy defaultCachePolicy = cachePolicy.isEmpty() ? null : cachePolicy.getUnmodifiable();
            return new FederatedRepositoryConfig(repositoryName, cacheProjection, sourceProjections, defaultCachePolicy);
View Full Code Here

Examples of org.jboss.dna.graph.properties.NameFactory

                                           ProjectionParser projectionParser,
                                           Path path,
                                           Map<Name, Property> properties,
                                           Problems problems ) {
        ValueFactories valueFactories = context.getValueFactories();
        NameFactory nameFactory = valueFactories.getNameFactory();
        ValueFactory<String> stringFactory = valueFactories.getStringFactory();

        String sourceName = path.getLastSegment().getName().getLocalName();

        // Get the rules ...
        Projection.Rule[] projectionRules = null;
        Property projectionRulesProperty = properties.get(nameFactory.create(PROJECTION_RULES_CONFIG_PROPERTY_NAME));
        if (projectionRulesProperty != null && !projectionRulesProperty.isEmpty()) {
            String[] projectionRuleStrs = stringFactory.create(projectionRulesProperty.getValuesAsArray());
            if (projectionRuleStrs != null && projectionRuleStrs.length != 0) {
                projectionRules = projectionParser.rulesFromStrings(context, projectionRuleStrs);
            }
View Full Code Here

Examples of org.jboss.dna.graph.property.NameFactory

     *         being unregistered.
     * @throws RepositoryException if any other error occurs
     */
    public void unregisterNodeType( Collection<String> nodeTypeNames )
        throws NoSuchNodeTypeException, InvalidNodeTypeDefinitionException, RepositoryException {
        NameFactory nameFactory = context().getValueFactories().getNameFactory();

        try {
            session.checkPermission((Path)null, JcrSession.DNA_REGISTER_TYPE_PERMISSION);
        } catch (AccessControlException ace) {
            throw new AccessDeniedException(ace);
        }

        Collection<Name> names = new ArrayList<Name>(nodeTypeNames.size());
        for (String name : nodeTypeNames) {
            names.add(nameFactory.create(name));
        }
        repositoryTypeManager.unregisterNodeType(names);
    }
View Full Code Here

Examples of org.jboss.dna.graph.property.NameFactory

        }

        Map<Name, Property> nodeProperties = nodeTypeNode.getPropertiesByName();

        ValueFactories valueFactories = context.getValueFactories();
        NameFactory nameFactory = valueFactories.getNameFactory();
        ValueFactory<Boolean> booleanFactory = valueFactories.getBooleanFactory();

        Name name = nameFactory.create(getFirstPropertyValue(nodeProperties.get(JcrLexicon.NODE_TYPE_NAME)));
        Name primaryItemName = nameFactory.create(getFirstPropertyValue(nodeProperties.get(JcrLexicon.PRIMARY_ITEM_NAME)));
        boolean mixin = booleanFactory.create(getFirstPropertyValue(nodeProperties.get(JcrLexicon.IS_MIXIN)));
        boolean orderableChildNodes = booleanFactory.create(getFirstPropertyValue(nodeProperties.get(JcrLexicon.HAS_ORDERABLE_CHILD_NODES)));

        return new JcrNodeType(this.context, this, name, supertypes, primaryItemName, childNodes, properties, mixin,
                               orderableChildNodes);
View Full Code Here

Examples of org.jboss.dna.graph.property.NameFactory

                                                          Location propertyLocation ) {
        Node propertyDefinitionNode = nodeTypeGraph.getNode(propertyLocation);
        Map<Name, Property> properties = propertyDefinitionNode.getPropertiesByName();

        ValueFactories valueFactories = context.getValueFactories();
        NameFactory nameFactory = valueFactories.getNameFactory();
        ValueFactory<Boolean> booleanFactory = valueFactories.getBooleanFactory();

        Name propertyName = nameFactory.create(getFirstPropertyValue(properties.get(JcrLexicon.NAME)));
        int onParentVersionBehavior = OnParentVersionAction.valueFromName((String)getFirstPropertyValue(properties.get(JcrLexicon.ON_PARENT_VERSION)));
        int requiredType = PROPERTY_TYPE_VALUES_FROM_NAME.get(getFirstPropertyValue(properties.get(JcrLexicon.REQUIRED_TYPE)));

        boolean mandatory = booleanFactory.create(getFirstPropertyValue(properties.get(JcrLexicon.MANDATORY)));
        boolean multiple = booleanFactory.create(getFirstPropertyValue(properties.get(JcrLexicon.MULTIPLE)));
View Full Code Here

Examples of org.jboss.dna.graph.property.NameFactory

                                                       Location childNodeLocation ) {
        Node childNodeDefinitionNode = nodeTypeGraph.getNode(childNodeLocation);
        Map<Name, Property> properties = childNodeDefinitionNode.getPropertiesByName();

        ValueFactories valueFactories = context.getValueFactories();
        NameFactory nameFactory = valueFactories.getNameFactory();
        ValueFactory<Boolean> booleanFactory = valueFactories.getBooleanFactory();

        Name childNodeName = nameFactory.create(getFirstPropertyValue(properties.get(JcrLexicon.NAME)));
        Name defaultPrimaryTypeName = nameFactory.create(getFirstPropertyValue(properties.get(JcrLexicon.DEFAULT_PRIMARY_TYPE)));
        int onParentVersion = OnParentVersionAction.valueFromName((String)getFirstPropertyValue(properties.get(JcrLexicon.ON_PARENT_VERSION)));

        boolean mandatory = booleanFactory.create(getFirstPropertyValue(properties.get(JcrLexicon.MANDATORY)));
        boolean allowsSns = booleanFactory.create(getFirstPropertyValue(properties.get(JcrLexicon.SAME_NAME_SIBLINGS)));
        boolean autoCreated = booleanFactory.create(getFirstPropertyValue(properties.get(JcrLexicon.AUTO_CREATED)));
        boolean isProtected = booleanFactory.create(getFirstPropertyValue(properties.get(JcrLexicon.PROTECTED)));

        Name[] requiredTypes;
        Property requiredTypeNamesProperty = properties.get(JcrLexicon.REQUIRED_PRIMARY_TYPES);
        if (requiredTypeNamesProperty != null) {
            List<Name> names = new ArrayList<Name>(requiredTypeNamesProperty.size());
            for (Object value : requiredTypeNamesProperty) {
                names.add(nameFactory.create(value));
            }

            requiredTypes = names.toArray(new Name[names.size()]);
        } else {
            requiredTypes = new Name[0];
View Full Code Here

Examples of org.jboss.dna.graph.property.NameFactory

        protected ReferenceConstraintChecker( String[] valueConstraints,
                                              ExecutionContext context ) {
            // this.context = context;

            NameFactory factory = context.getValueFactories().getNameFactory();

            constraints = new Name[valueConstraints.length];

            for (int i = 0; i < valueConstraints.length; i++) {
                constraints[i] = factory.create(valueConstraints[i]);
            }
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.