1 36 package org.ungoverned.oscar.installer.artifact; 37 38 import java.io.*; 39 import java.util.Map ; 40 41 import org.ungoverned.oscar.installer.Install; 42 import org.ungoverned.oscar.installer.Status; 43 import org.ungoverned.oscar.installer.StringProperty; 44 45 public abstract class AbstractFileArtifact extends AbstractArtifact 46 { 47 private StringProperty m_destName = null; 48 49 public AbstractFileArtifact(StringProperty sourceName) 50 { 51 this(sourceName, sourceName); 52 } 53 54 public AbstractFileArtifact(StringProperty sourceName, StringProperty destName) 55 { 56 this(sourceName, destName, null); 57 } 58 59 public AbstractFileArtifact( 60 StringProperty sourceName, StringProperty destName, StringProperty destDir) 61 { 62 this(sourceName, destName, destDir, false); 63 } 64 65 public AbstractFileArtifact( 66 StringProperty sourceName, StringProperty destName, 67 StringProperty destDir, boolean localize) 68 { 69 super(sourceName, destDir, localize); 70 m_destName = destName; 71 } 72 73 public StringProperty getDestinationName() 74 { 75 return m_destName; 76 } 77 78 public boolean process(Status status, Map propMap) 79 { 80 String installDir = 81 ((StringProperty) propMap.get(Install.INSTALL_DIR)).getStringValue(); 82 83 try 84 { 85 InputStream is = getInputStream(status); 86 87 if (is == null) 88 { 89 return true; 90 } 91 92 if (localize()) 93 { 94 status.setText("Copying and configuring " 95 + getSourceName().getStringValue()); 96 copyAndLocalize( 97 is, 98 installDir, 99 getDestinationName().getStringValue(), 100 getDestinationDirectory().getStringValue(), 101 propMap); 102 } 103 else 104 { 105 status.setText("Copying " + getSourceName().getStringValue()); 106 copy( 107 is, 108 installDir, 109 getDestinationName().getStringValue(), 110 getDestinationDirectory().getStringValue()); 111 } 112 113 is.close(); 114 115 } 116 catch (Exception ex) 117 { 118 System.err.println(ex); 119 return false; 120 } 121 122 return true; 123 } 124 } | Popular Tags |