Rev 18 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
/****/package in.shop2020.metamodel.util;import in.shop2020.metamodel.definitions.Catalog;import in.shop2020.metamodel.definitions.Category;import in.shop2020.metamodel.definitions.DefinitionsContainer;import org.apache.commons.lang.ArrayUtils;import org.apache.commons.lang.StringUtils;/*** CN - Content Tool* Imports and exports content. Validates against content model** @author naveen**/public class CN {public static final String CONTENT_SRC_TXT_PATH ="/home/naveen/workspace/eclipse/webapp/src/content/txt/";public static final String CONTENT_SRC_HTML_PATH ="/home/naveen/workspace/eclipse/webapp/src/content/html/";public static final String CONTENT_SRC_XML_PATH ="/home/naveen/workspace/eclipse/webapp/src/content/xml/";public static final String CONTENT_DB_PATH ="/home/naveen/workspace/eclipse/webapp/db/entities/";// Known patternspublic static final String PATTERN_LEVEL_1 = "* ";public static final String PATTERN_LEVEL_2 = " * ";public static final String PATTERN_LEVEL_3 = " * ";public static final String PATTERN_LEVEL_4 = " * ";private long categoryID;private String srcFile;private String dbFile;/*** @param args*/public static void main(String[] args) throws Exception {String[] commands = new String[] {"show", "import"};String usage = "Usage: CN ["+ StringUtils.join(commands, "|") +"] {Category ID} {Content file name}\n" +"Note:Only text files for now";if(args.length < 3) {System.out.println(usage);System.exit(-1);}System.out.println("CN "+ args[0] + " " + args[1]+ " " + args[2]);String inputCommand = args[0];String inputCategoryID = args[1];String inputFilename = args[2];if(!ArrayUtils.contains(commands, inputCommand)) {System.out.println(usage);System.exit(-1);}long categoryID = new Long(inputCategoryID).longValue();CN cn = new CN(categoryID, inputFilename);if(inputCommand.equals("import")) {cn.importEntity();}else if(inputCommand.equals("show")) {cn.showEntity();}}/**** @param categoryID* @param fileName*/public CN(long categoryID, String fileName) {this.categoryID = categoryID;this.srcFile = CONTENT_SRC_TXT_PATH + fileName + ".txt";this.dbFile = CONTENT_DB_PATH + "entities" + ".ser";}/**** @throws Exception*/public void importEntity() throws Exception {System.out.println("importEntity()");DefinitionsContainer allDefs =Catalog.getInstance().getDefinitionsContainer();Category category = allDefs.getCategory(this.categoryID);System.out.println(category);}/**** @throws Exception*/public void showEntity() throws Exception {System.out.println("showEntity()");}}