001: /*
002: * This file is part of PFIXCORE.
003: *
004: * PFIXCORE is free software; you can redistribute it and/or modify
005: * it under the terms of the GNU Lesser General Public License as published by
006: * the Free Software Foundation; either version 2 of the License, or
007: * (at your option) any later version.
008: *
009: * PFIXCORE is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012: * GNU Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public License
015: * along with PFIXCORE; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017: *
018: */
019:
020: package de.schlund.pfixcore.util.basicapp.projectdom;
021:
022: import org.w3c.dom.Document;
023:
024: import de.schlund.pfixcore.util.basicapp.helper.AppValues;
025: import de.schlund.pfixcore.util.basicapp.helper.XmlUtils;
026: import de.schlund.pfixcore.util.basicapp.objects.Project;
027: import de.schlund.pfixcore.util.basicapp.objects.ServletObject;
028:
029: /**
030: * Represents the dom of config.prop.in
031: *
032: * @author <a href="mailto:rapude@schlund.de">Ralf Rapude</a>
033: * @version $Id: ConfigXmlDom.java 3302 2007-11-30 16:56:16Z jenstl $
034: */
035: public final class ConfigXmlDom {
036: /** The current dom */
037: private Document domDoc = null;
038: /** A String Buffer to get e.g. correctPaths */
039: private StringBuffer buffy = new StringBuffer();
040: /** The current Project */
041: private Project project = null;
042: private String projectName = null;
043: /** defines the current pagename and is a suffix for home*/
044: private int homeCounter;
045:
046: /**
047: * Constructor initializes the Project Object
048: * and the dom for the current document
049: * @param project The current project
050: * @param domDoc the current Dom given by HandleXmlFiles
051: */
052: public ConfigXmlDom(Project project, Document domDoc, int counter) {
053: this .domDoc = domDoc;
054: projectName = project.getProjectName();
055: homeCounter = counter;
056: this .project = project;
057: prepareConfigProp();
058: }
059:
060: /**
061: * Preparing the project.xml whicht means, that the content of some
062: * of the doms attributes and tags will be changed
063: * @param buffy A StringBuffer for the new values
064: * @param domDoc The dom
065: * @return The new dom
066: */
067: private void prepareConfigProp() {
068: String curPageName = AppValues.PAGEDEFAULT + homeCounter;
069: // setting the current path
070: buffy.append(projectName);
071: buffy.append(AppValues.CONFFOLDER);
072: buffy.append(AppValues.DEPENDXML);
073:
074: // change attribute depend -> tag=servletinfo
075: domDoc = XmlUtils.changeAttributes(domDoc,
076: AppValues.CONFIGTAG_SERVLETINFO,
077: AppValues.CONFIGATT_DEPEND, buffy.toString(), false);
078: buffy.setLength(0);
079:
080: // change attribute name
081: buffy.append(AppValues.CONFIGATT_NAMEPREFIX);
082: buffy.append(projectName);
083: buffy.append(AppValues.CONFIGATT_NAMEPOSTFIX);
084: buffy.append(((ServletObject) project.getServletList().get(
085: homeCounter - 1)).getServletName());
086: domDoc = XmlUtils.changeAttributes(domDoc,
087: AppValues.CONFIGTAG_SERVLETINFO,
088: AppValues.CONFIGATT_NAME, buffy.toString(), false);
089: buffy.setLength(0);
090:
091: // change attribute name -> tag is flowstep
092: domDoc = XmlUtils.changeAttributes(domDoc,
093: AppValues.CONFIGTAG_FLOWSTEP, AppValues.CONFIGATT_NAME,
094: curPageName, false);
095:
096: // change attribute name -> tag is pagerequest
097: domDoc = XmlUtils.changeAttributes(domDoc,
098: AppValues.CONFIGTAG_PAGEREQUEST,
099: AppValues.CONFIGATT_NAME, curPageName, false);
100: }
101:
102: /**
103: * Gives the current dom back to
104: * HandleXmlFiles
105: * @return Document The current dom
106: */
107: public Document getDom() {
108: return domDoc;
109: }
110: }
|