001: /*
002: * ChainBuilder ESB
003: * Visual Enterprise Integration
004: *
005: * Copyright (C) 2006 Bostech Corporation
006: *
007: * This program is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU General Public License as published by the
009: * Free Software Foundation; either version 2 of the License, or (at your option)
010: * any later version.
011: *
012: * This program is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
014: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
015: * for more details.
016: *
017: * You should have received a copy of the GNU General Public License along with
018: * this program; if not, write to the Free Software Foundation, Inc.,
019: * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020: *
021: *
022: * $Id$
023: */
024: package com.bostechcorp.cbesb.common.util.project;
025:
026: import java.io.IOException;
027: import java.io.OutputStream;
028:
029: import org.apache.commons.logging.Log;
030: import org.apache.commons.logging.LogFactory;
031:
032: public class ProjectInfoDocument {
033:
034: /**
035: * The projectName
036: */
037: private ProjectBean project;
038:
039: protected static transient Log logger = LogFactory
040: .getLog(ProjectInfoDocument.class);
041:
042: public ProjectBean getProject() {
043: return project;
044: }
045:
046: public void setProject(ProjectBean project) {
047: this .project = project;
048: }
049:
050: public ProjectInfoDocument() {
051: }
052:
053: /* (non-Javadoc)
054: * @see com.bostechcorp.cbesb.common.mdl.IMDLDocument#serialize(java.io.OutputStream)
055: */
056: public void serialize(OutputStream outputStream) {
057: try {
058: outputStream.write("<?xml version=\"1.0\"?>\n".getBytes());
059: outputStream
060: .write(("<project name=\""
061: + this .getProject().getName()
062: + "\" type=\""
063: + this .getProject().getType() + "\">\n")
064: .getBytes());
065: SubProjectBean[] subProjects = this .getProject()
066: .getAllSubProjects();
067: for (int i = 0; i < subProjects.length; i++) {
068: SubProjectBean subProject = subProjects[i];
069: String subName = "";
070: if (this .getProject().getType().equals("ESB")) {
071: subName = "subproject";
072: } else if (this .getProject().getType().equals("JBI")) {
073: subName = "superproject";
074: }
075: outputStream.write(("\t<" + subName + " name=\""
076: + subProject.getName() + "\" type=\""
077: + subProject.getType() + "\"/>\n").getBytes());
078: }
079:
080: //
081: outputStream.write("</project>\n".getBytes());
082: } catch (IOException e) {
083: logger.error("Exception in serialize(): " + e.getMessage());
084: if (logger.isDebugEnabled()) {
085: logger.debug("Exception in serialize():", e);
086: }
087: }
088: }
089:
090: /* (non-Javadoc)
091: * @see com.bostechcorp.cbesb.legacydata.mdl.MDLDocument#toSchema(java.io.OutputStream)
092: */
093: public void toSchema(OutputStream outputStream) {
094:
095: }
096:
097: public void addNewProject(String name, String type) {
098: project = new ProjectBean(name, type);
099: }
100: }
|