1 10 11 package org.mmbase.model; 12 13 import org.mmbase.util.*; 14 import org.mmbase.util.logging.*; 15 import java.util.*; 16 import java.io.*; 17 18 public class CloudModel { 19 20 private static Logger log = Logging.getLoggerInstance(CloudModel.class); 21 private String name; 22 private String path; 23 private HashMap builders = new HashMap(); 24 25 public CloudModel(String name) { 26 this.name = name; 27 } 28 29 public CloudModelBuilder addBuilder(String buildername,String path) { 30 CloudModelBuilder cmb = new CloudModelBuilder(buildername); 31 cmb.setPath(path); 32 builders.put(buildername,cmb); 33 return cmb; 34 } 35 36 public void setPath(String path) { 37 this.path = path; 38 } 39 40 public CloudModelBuilder getModelBuilder(String name) { 41 return (CloudModelBuilder)builders.get(name); 42 } 43 44 45 public boolean writeToFile(String filepath) { 46 InputStream in = ResourceLoader.getConfigurationRoot().getResourceAsStream(path); 47 if (in!=null) { 48 try { 49 FileOutputStream out = new FileOutputStream(filepath); 50 byte[] buf = new byte[1024]; 51 int len; 52 while ((len = in.read(buf)) > 0) { 53 out.write(buf, 0, len); 54 } 55 in.close(); 56 out.flush(); 57 out.close(); 58 } catch(Exception e) { 59 e.printStackTrace(); 60 return false; 61 } 62 } else { 63 log.info("Resource not found : "+path); 64 } 65 return true; 66 } 67 68 } 69 | Popular Tags |