Package org.apache.excalibur.source

Examples of org.apache.excalibur.source.SourceResolver


    /* (non-Javadoc)
     * @see org.apache.avalon.framework.activity.Initializable#initialize()
     */
    public void initialize() throws Exception {
        SourceResolver resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
        Source source = null;
        try {
      Entry entry;
      String name;
      String mappingSource;
      Mapping mapping;
      Iterator iterator = this.mappingSources.entrySet().iterator();
          while (iterator.hasNext()) {
            entry = (Map.Entry)iterator.next();
            name = (String)entry.getKey();
            mappingSource = (String)entry.getValue();
           
        source = resolver.resolveURI(mappingSource);
        mapping = new Mapping();
        mapping.loadMapping(SourceUtil.getInputSource(source));
        this.mappings.put(name, mapping);
          }
        } finally {
            if (source != null) {
                resolver.release(source);
            }
            manager.release(resolver);
        }
    }
View Full Code Here


            }
        }
    }

    public void save() throws MetaDataException {
        SourceResolver resolver = null;
        JCRNodeSource source = null;
        try {
            resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
            source = (JCRNodeSource) resolver.resolveURI(this.sourceUri);

            if (!source.exists()) {
                OutputStream stream = source.getOutputStream();
                stream.flush();
                stream.close();
            }

            Node node = source.getNode();
            String prefix = node.getSession()
                    .getWorkspace()
                    .getNamespaceRegistry()
                    .getPrefix(this.namespace);
            if (!prefix.equals("")) {
                prefix = prefix + ":";
            }

            String possibleKeys[] = getPossibleKeys();
            for (int i = 0; i < possibleKeys.length; i++) {
                String[] stringValues = (String[]) getKey2Values().get(possibleKeys[i]);
                String key = prefix + possibleKeys[i];
                node.setProperty(key, stringValues);
            }

        } catch (Exception e) {
            throw new RuntimeException(e);
        } finally {
            if (resolver != null) {
                if (source != null) {
                    resolver.release(source);
                }
                this.manager.release(resolver);
            }
        }
    }
View Full Code Here

    }

    public long getLastModified() throws MetaDataException {
        long lastModified = 0;
        try {
            SourceResolver resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
            JCRNodeSource source = (JCRNodeSource) resolver.resolveURI(this.sourceUri);
            lastModified = source.getLastModified();
        } catch (Exception e) {
            throw new MetaDataException("Error resolving meta data source", e);
        }
        return lastModified;
View Full Code Here

    /**
     * @see org.apache.avalon.framework.activity.Initializable#initialize()
     */
    public void initialize() throws Exception {
        SourceResolver resolver = null;
        Source contextSource = null;
        File contextDir;
        try {
            resolver = (SourceResolver) getManager().lookup(SourceResolver.ROLE);
            contextSource = resolver.resolveURI("context:///");
            contextDir = SourceUtil.getFile(contextSource);

            if (contextDir == null || !contextDir.isDirectory()) {
                throw new AccessControlException("The servlet context is not a directory!");
            }

        } finally {
            if (resolver != null) {
                if (contextSource != null) {
                    resolver.release(contextSource);
                }
                getManager().release(resolver);
            }
        }
        this.context = contextDir;
View Full Code Here

        super.doExecute();
        String pubId = getParameterAsString(PUBLICATION);
        DocumentFactory factory = getDocumentFactory();
        ServiceSelector selector = null;
        SiteManager siteManager = null;
        SourceResolver resolver = null;
        try {
            resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
            Publication pub = factory.getPublication(pubId);
            selector = (ServiceSelector) this.manager.lookup(SiteManager.ROLE + "Selector");
            siteManager = (SiteManager) selector.select(pub.getSiteManagerHint());
View Full Code Here

    }

    protected void load() {

        this.key2values = new HashMap();
        SourceResolver resolver = null;
        JCRNodeSource source = null;
        try {
            resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
            source = (JCRNodeSource) resolver.resolveURI(this.sourceUri);

            Node node = source.getNode();
            String prefix = node.getSession()
                    .getWorkspace()
                    .getNamespaceRegistry()
                    .getPrefix(this.namespace);
            if (!prefix.equals("")) {
                prefix = prefix + ":";
            }

            String possibleKeys[] = getPossibleKeys();
            for (int i = 0; i < possibleKeys.length; i++) {
                String key = prefix + possibleKeys[i];
                if (node.hasProperty(key)) {
                    Property property = node.getProperty(key);
                    Value[] values = property.getValues();
                    String[] stringValues = new String[values.length];
                    for (int v = 0; v < values.length; v++) {
                        stringValues[v] = values[v].getString();
                    }
                    this.key2values.put(possibleKeys[i], stringValues);
                }
            }

        } catch (Exception e) {
            throw new RuntimeException(e);
        } finally {
            if (resolver != null) {
                if (source != null) {
                    resolver.release(source);
                }
                this.manager.release(resolver);
            }
        }
    }
View Full Code Here

    /**
     * @see org.apache.lenya.cms.usecase.AbstractUsecase#doExecute()
     */
    protected void doExecute() throws Exception {
        SourceResolver resolver = null;

        try {
            resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);

            Document doc = getSourceDocument();
View Full Code Here

    /**
     *
     */
    public Collection getChildren() throws RepositoryException {
        SourceResolver resolver = null;
        TraversableSource source = null;
        try {
            resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
            source = (TraversableSource) resolver.resolveURI(this.contentSource.getRealSourceUri());
            Collection children = source.getChildren();
            java.util.Iterator iterator = children.iterator();
            java.util.Vector newChildren = new java.util.Vector();
            while (iterator.hasNext()) {
                TraversableSource child = (TraversableSource) iterator.next();
View Full Code Here

    /**
     *
     */
    public boolean isCollection() throws RepositoryException {
        SourceResolver resolver = null;
        TraversableSource source = null;
        try {
            resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
            source = (TraversableSource) resolver.resolveURI(this.contentSource.getRealSourceUri());
            return source.isCollection();
        } catch (Exception e) {
            throw new RepositoryException(e);
        }
    }
View Full Code Here

     * @exception SAXException if an error occurs while parsing the file
     */
    protected void load(String sourceURL)
    throws IOException, ProcessingException, SAXException {
        Source source = null;
        SourceResolver resolver = null;
        try {
            int valid = this.validity == null? SourceValidity.INVALID: this.validity.isValid();
            if (valid != SourceValidity.VALID) {
                // Saved validity is not valid, get new source and validity
                resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
                source = resolver.resolveURI(sourceURL);
                SourceValidity sourceValidity = source.getValidity();
                if (valid == SourceValidity.INVALID || this.validity.isValid(sourceValidity) != SourceValidity.VALID) {
                    HashMap values = new HashMap();
                    SourceUtil.toSAX(source, new SAXContentHandler(values));
                    this.validity = sourceValidity;
                    this.values = values;
                    if (getLogger().isDebugEnabled()) {
                        getLogger().debug("Loaded XML bundle: " + this.name + ", locale: " + this.locale);
                    }
                }
            }
        } catch (ServiceException e) {
            throw new ProcessingException("Can't lookup source resolver", e);
        } catch (MalformedURLException e) {
            throw new SourceNotFoundException("Invalid resource URL: " + sourceURL, e);
        } finally {
            if (source != null) {
                resolver.release(source);
            }
            this.manager.release(resolver);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.excalibur.source.SourceResolver

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.