Examples of NamespaceHelper


Examples of org.apache.lenya.xml.NamespaceHelper

     * @return An XML document.
     * @exception SchedulerException if an error occurs
     */
    public Document getSnapshot(Publication publication, JobWrapper[] jobs)
        throws SchedulerException {
        NamespaceHelper helper = SchedulerStore.getNamespaceHelper();
        Document document = helper.getDocument();
        Element root = document.getDocumentElement();

        log.debug("Creating job snapshot for publication [" + publication.getId() + "]");
        root.appendChild(createSnapshot(helper, publication, jobs));

View Full Code Here

Examples of org.apache.lenya.xml.NamespaceHelper

     * Returns a scheduler namespace helper for a document.
     * @param document The XML document.
     * @return a namespace helper.
     */
    public static NamespaceHelper getNamespaceHelper(Document document) {
        return new NamespaceHelper(NAMESPACE, "sch", document);
    }
View Full Code Here

Examples of org.apache.lenya.xml.NamespaceHelper

     * a <sch:scheduler> element.
     * @return a namespace helper.
     */
    public static NamespaceHelper getNamespaceHelper() {
        try {
            return new NamespaceHelper(NAMESPACE, "sch", "scheduler");
        } catch (Exception e) {
            log.error("Could not create namespace helper: ", e);

            return null;
        }
View Full Code Here

Examples of org.apache.lenya.xml.NamespaceHelper

            try {
                document = DocumentHelper.readDocument(jobsFile);
            } catch (Exception e) {
                throw new SchedulerException(e);
            }
            NamespaceHelper helper = SchedulerStore.getNamespaceHelper(document);

            for (int i = 0; i < jobElements.length; i++) {
                wrappers.add(restoreJob(helper, jobElements[i], publication));
            }
        }
View Full Code Here

Examples of org.apache.lenya.xml.NamespaceHelper

        try {
            File jobsFile = getJobsFile(publication);
            if (jobsFile.exists()) {
                Document document = DocumentHelper.readDocument(jobsFile);
                Element schedulerElement = document.getDocumentElement();
                NamespaceHelper helper = SchedulerStore.getNamespaceHelper(document);

                Element jobGroupElement =
                    helper.getFirstChild(schedulerElement, SchedulerStore.ELEMENT_JOB_GROUP);
                if (jobGroupElement == null) {
                    throw new SchedulerException("No <job-group> element found!");
                }

                String jobGroupAttribute = jobGroupElement.getAttribute("name");

                if (!jobGroupAttribute.equals(publication.getId())) {
                    throw new SchedulerException(
                        "The jobs.xml file contains a wrong job group: ["
                            + jobGroupAttribute
                            + "]");
                } else {
                    jobElements = helper.getChildren(jobGroupElement, SchedulerStore.ELEMENT_JOB);

                }
            } else {
                throw new SchedulerException(
                    "The jobs file [" + jobsFile.getAbsolutePath() + "] does not exist!");
View Full Code Here

Examples of org.apache.lenya.xml.NamespaceHelper

            throws TransformerConfigurationException, TransformerException, IOException,
            ParserConfigurationException {

        assert (metaDataFile.getParentFile().exists());

        NamespaceHelper helper = new NamespaceHelper("http://purl.org/dc/elements/1.1/", "dc",
                "metadata");

        Element root = helper.getDocument().getDocumentElement();

        Iterator iter = dublinCoreParams.entrySet().iterator();
        while (iter.hasNext()) {
            Map.Entry entry = (Map.Entry)iter.next();
            root.appendChild(helper.createElement((String)entry.getKey(), (String)entry.getValue()));
        }

        String mimeType = dublinCoreParams.get("format").toString();
        if (canReadMimeType(mimeType)) {
            NamespaceHelper lenyaHelper = new NamespaceHelper("http://apache.org/cocoon/lenya/page-envelope/1.0", "lenya", helper.getDocument());
            Element metaElement = lenyaHelper.createElement("meta");

            Iterator iterlenya = lenyaMetaParams.entrySet().iterator();
            while (iterlenya.hasNext()) {
                Map.Entry entry = (Map.Entry)iterlenya.next();
                metaElement.appendChild(lenyaHelper.createElement((String)entry.getKey(), (String)entry.getValue()));
            }
            root.appendChild(metaElement);
        }
        DocumentHelper.writeDocument(helper.getDocument(), metaDataFile);
    }
View Full Code Here

Examples of org.apache.lenya.xml.NamespaceHelper

     * @return A job details object.
     */
    public JobDetail load(Element jobElement, String jobGroup, String servletContextPath) throws SchedulerException {
        JobDetail jobDetail = super.load(jobElement, jobGroup, servletContextPath);
       
        NamespaceHelper helper = SchedulerStore.getNamespaceHelper();
        DefaultTaskWrapper wrapper = new DefaultTaskWrapper(helper, jobElement);
        wrapper.getTaskParameters().setServletContextPath(servletContextPath);
       
        JobDataMap map = new JobDataMap(wrapper.getParameters());
        jobDetail.setJobDataMap(map);
View Full Code Here

Examples of org.apache.lenya.xml.NamespaceHelper

        if (type != co && type != ci) {
            throw new IllegalArgumentException(
                "ERROR: " + this.getClass().getName() + ".checkOutIn(): No such type");
        }

        NamespaceHelper helper = new NamespaceHelper(null, "", document);

        Element identityElement = helper.createElement("Identity", identity);
        Element timeElement = helper.createElement("Time", "" + time);

        String elementName = (String) ELEMENTS.get(new Short(type));
        Element checkOutElement = helper.createElement(elementName);

        checkOutElement.appendChild(identityElement);
        checkOutElement.appendChild(timeElement);

        if (backup) {
            Element backupElement = helper.createElement(ELEMENT_BACKUP);
            checkOutElement.appendChild(backupElement);
        }

        Element root = document.getDocumentElement();
        root.insertBefore(checkOutElement, root.getFirstChild());
View Full Code Here

Examples of org.apache.lenya.xml.NamespaceHelper

                    uri = absoluteUri;
                }
                Document document = DocumentHelper.readDocument(new URL(uri));
                Element root = document.getDocumentElement();

                NamespaceHelper helper = new NamespaceHelper(NAMESPACE_URI, "mail", document);

                String[] keys = {
                    ELEMENT_SERVER, ELEMENT_FROM, ELEMENT_TO, ELEMENT_CC, ELEMENT_BCC,
                    ELEMENT_SUBJECT, ELEMENT_BODY
                };

                Element[] elements = helper.getChildren(root);

                for (int i = 0; i < elements.length; i++) {
                    if (elements[i].getChildNodes().getLength() > 0) {
                        Node firstChild = elements[i].getChildNodes().item(0);
View Full Code Here

Examples of org.apache.lenya.xml.NamespaceHelper

     */
    public void addLabel(Label label) {
        if (getLabel(label.getLanguage()) == null) {
            // only add the label if there is no label with the same language yet.

            NamespaceHelper helper = getNamespaceHelper();
            Element labelElem = helper.createElement(SiteTreeNodeImpl.LABEL_NAME, label.getLabel());

            labelElem.setAttribute(SiteTreeNodeImpl.LANGUAGE_ATTRIBUTE_NAME, label.getLanguage());
            if (label.getHref() != null) {
                labelElem.setAttribute(SiteTreeNodeImpl.HREF_ATTRIBUTE_NAME, label.getHref());
            }
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.