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: package de.schlund.pfixcore.util.basicapp.basics;
020:
021: import java.io.File;
022:
023: import de.schlund.pfixcore.util.basicapp.helper.AppValues;
024: import de.schlund.pfixcore.util.basicapp.objects.Project;
025:
026: /**
027: * Building the project with all informations collected by
028: * @see de.schlund.pfixcore.util.basicapp.basics.CreateProjectSettings
029: *
030: * @author <a href="mailto:rapude@schlund.de">Ralf Rapude</a>
031: * @version $Id: CreateProject.java 3302 2007-11-30 16:56:16Z jenstl $
032: */
033:
034: public class CreateProject {
035: /**
036: * The project settings initialized by
037: * @see de.schlund.pfixcore.util.basicapp.basics.CreateProjectSettings
038: */
039: private String docRoot = AppValues.BASICPATH;
040: private boolean success = false;
041: private String created = "Folder has been created successfully";
042: String projectFolder = null;
043:
044: public CreateProject(Project project) {
045: projectFolder = project.getProjectName();
046: }
047:
048: /** Building the Project starts with this method */
049: public void runCreateProject() {
050: // building the project folders
051: buildProjectFolder();
052: }
053:
054: /** Builds the main project folder */
055: private void buildProjectFolder() {
056: System.out.println("\nCreating project in \"" + docRoot
057: + "\" starts now");
058: System.out.println("\nCreating project folder: "
059: + projectFolder);
060: success = new File(docRoot + "/" + projectFolder).mkdir();
061:
062: if (success) {
063: System.out.println(created);
064: }
065:
066: buildSubPrjFolder();
067: }
068:
069: /** Method for building the appfolders */
070: private void buildSubPrjFolder() {
071: String projectpath = docRoot + "/" + projectFolder;
072: System.out.println("\nCreating subfolder starts now");
073:
074: for (int i = 0; i < AppValues.FOLDERNAMES.length; i++) {
075: StringBuffer buffy = new StringBuffer(projectpath);
076: buffy.append("/");
077:
078: if (AppValues.FOLDERNAMES[i].equals(AppValues.TXTFOLDER)) {
079: System.out.println("Creating folder "
080: + AppValues.FOLDERNAMES[i] + " & subfolders");
081: } else {
082: System.out.println("Creating folder "
083: + AppValues.FOLDERNAMES[i] + "...");
084: }
085:
086: buffy.append(AppValues.FOLDERNAMES[i]);
087:
088: if (AppValues.FOLDERNAMES[i].equals(AppValues.TXTFOLDER)) {
089: buffy.append(AppValues.TXTSUBFOLDER);
090: success = new File(buffy.toString()).mkdirs();
091: } else {
092: success = new File(buffy.toString()).mkdir();
093: }
094:
095: if (success) {
096: System.out.println(created);
097: }
098: }
099: }
100:
101: }
|