Package org.apache.excalibur.source

Examples of org.apache.excalibur.source.ModifiableSource


            n.setMessage("Page Not Available.");
            n.setDescription("The requested resource couldn't be found.");
            n.addExtraDescription(Notifying.EXTRA_REQUESTURI, target.getSourceURI());
            n.addExtraDescription("missing-file", target.getSourceURI());

            ModifiableSource source = this.getSource(target);
            OutputStream stream = null;
            PrintStream out = null;
            try {
                stream = source.getOutputStream();
                out = new PrintStream(stream);
                Notifier.notify(n, out, "text/html");
            } finally {
                if (out != null) out.close();
                if (stream != null) stream.close();
View Full Code Here


    private void writeChecksumFile() throws Exception {
        Source checksumSource = this.sourceResolver.resolveURI(this.checksumsURI);
        if (!(checksumSource instanceof ModifiableSource)) {
            throw new ProcessingException("Checksum file is not Modifiable:" + checksumSource);
        }
        ModifiableSource source = (ModifiableSource) checksumSource;
        PrintWriter writer = new PrintWriter(new OutputStreamWriter(source.getOutputStream()));
        Iterator i = this.checksums.keySet().iterator();
        while (i.hasNext()){
            String key = (String) i.next();
            String checksum = (String) this.checksums.get(key);
            writer.println(key + "\t" + checksum);
View Full Code Here

                this.sendBrokenLinkWarning(target.getSourceURI(),
                    DefaultNotifyingBuilder.getRootCause(pe).getMessage());
            } finally {
                if (output != null && status != -1) {

                    ModifiableSource source = this.getSource(target);
                    try {
                        pageSize = output.size();

                        if (this.checksumsURI == null || !this.isSameContent(output, target)) {
                            OutputStream stream = source.getOutputStream();
                            output.setFileOutputStream(stream);
                            output.flush();
                            output.close();
                            this.pageGenerated(target.getSourceURI(),
                                          target.getAuthlessDestURI(),
View Full Code Here

            n.setMessage("Page Not Available.");
            n.setDescription("The requested resource couldn't be found.");
            n.addExtraDescription(Notifying.EXTRA_REQUESTURI, target.getSourceURI());
            n.addExtraDescription("missing-file", target.getSourceURI());

            ModifiableSource source = this.getSource(target);
            OutputStream stream = null;
            PrintStream out = null;
            try {
                stream = source.getOutputStream();
                out = new PrintStream(stream);
                Notifier.notify(n, out, "text/html");
            } finally {
                if (out != null) out.close();
                if (stream != null) stream.close();
View Full Code Here

    private void writeChecksumFile() throws Exception {
        Source checksumSource = this.sourceResolver.resolveURI(this.checksumsURI);
        if (!(checksumSource instanceof ModifiableSource)) {
            throw new ProcessingException("Checksum file is not Modifiable:" + checksumSource);
        }
        ModifiableSource source = (ModifiableSource) checksumSource;
        PrintWriter writer = new PrintWriter(new OutputStreamWriter(source.getOutputStream()));
        Iterator i = this.checksums.keySet().iterator();
        while (i.hasNext()){
            String key = (String) i.next();
            String checksum = (String) this.checksums.get(key);
            writer.println(key + "\t" + checksum);
View Full Code Here

    public void instantiate(Publication template, String newPublicationId, String name)
            throws Exception {

        SourceResolver resolver = null;
        Source publicationsSource = null;
        ModifiableSource metaSource = null;
        ModifiableSource configSource = null;
        try {
            resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
            publicationsSource = resolver.resolveURI("context://"
                    + PublicationImpl.PUBLICATION_PREFIX_URI);
            String publicationsUri = publicationsSource.getURI();

            for (int i = 0; i < sourcesToCopy.length; i++) {

                String source = sourcesToCopy[i];
                if (source.endsWith("/")) {
                    copyDirSource(template, newPublicationId, resolver, publicationsUri, source);
                } else {
                    copySource(template, newPublicationId, resolver, publicationsUri, source);
                }
            }

            metaSource = (ModifiableSource) resolver.resolveURI(publicationsUri + "/"
                    + newPublicationId + "/publication.xml");
            Document metaDoc = DocumentHelper.readDocument(metaSource.getInputStream());
            NamespaceHelper helper = new NamespaceHelper(
                    "http://apache.org/cocoon/lenya/publication/1.0", "lenya", metaDoc);
            Element nameElement = helper.getFirstChild(metaDoc.getDocumentElement(), "name");
            DocumentHelper.setSimpleElementText(nameElement, name);

            save(metaDoc, metaSource);

            configSource = (ModifiableSource) resolver.resolveURI(publicationsUri + "/"
                    + newPublicationId + "/config/publication.xconf");
            DefaultConfiguration config = (DefaultConfiguration) new DefaultConfigurationBuilder()
                    .build(configSource.getInputStream());
            DefaultConfiguration templatesConfig = new DefaultConfiguration("templates");
            DefaultConfiguration templateConfig = new DefaultConfiguration("template");
            templateConfig.setAttribute("id", template.getId());
            templatesConfig.addChild(templateConfig);
            config.addChild(templatesConfig);
            OutputStream oStream = configSource.getOutputStream();
            new DefaultConfigurationSerializer().serialize(oStream, config);
            if (oStream != null) {
                oStream.flush();
                try {
                    oStream.close();
View Full Code Here

            String publicationId,
            SourceResolver resolver,
            String publicationsUri,
            String source) throws MalformedURLException, IOException {
        Source templateSource = null;
        ModifiableSource targetSource = null;
        try {
            templateSource = resolver.resolveURI(publicationsUri + "/" + template.getId() + "/"
                    + source);
            targetSource = (ModifiableSource) resolver.resolveURI(publicationsUri + "/"
                    + publicationId + "/" + source);
View Full Code Here

     */
    public static void writeDOM(Document document, String sourceUri, ServiceManager manager)
            throws TransformerConfigurationException, TransformerException, ServiceException,
            MalformedURLException, IOException {
        SourceResolver resolver = null;
        ModifiableSource source = null;
        try {

            resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
            source = (ModifiableSource) resolver.resolveURI(sourceUri);

            OutputStream oStream = source.getOutputStream();
            Writer writer = new OutputStreamWriter(oStream);
            DocumentHelper.writeDocument(document, writer);
            if (oStream != null) {
                oStream.flush();
                try {
View Full Code Here

     * @throws IOException if an error occurs.
     */
    public static void delete(String sourceUri, ServiceManager manager) throws ServiceException,
            MalformedURLException, IOException {
        SourceResolver resolver = null;
        ModifiableSource source = null;
        try {

            resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
            source = (ModifiableSource) resolver.resolveURI(sourceUri);
            if (source.exists()) {
                source.delete();
            }
        } finally {
            if (resolver != null) {
                if (source != null) {
                    resolver.release(source);
View Full Code Here

    protected void saveResource(Resource resource, Part part) throws IOException {
        OutputStream out = null;
        InputStream in = null;

        SourceResolver resolver = null;
        ModifiableSource source = null;

        try {
            resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
            source = (ModifiableSource) resolver.resolveURI(resource.getSourceURI());

            byte[] buf = new byte[4096];
            out = source.getOutputStream();
            in = part.getInputStream();
            int read = in.read(buf);

            while (read > 0) {
                out.write(buf, 0, read);
View Full Code Here

TOP

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

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.