1 11 package org.eclipse.update.internal.core; 12 import java.io.*; 13 14 import org.eclipse.core.runtime.*; 15 import org.eclipse.osgi.util.NLS; 16 import org.eclipse.update.core.*; 17 18 21 public class SiteFileNonPluginContentConsumer extends ContentConsumer { 22 23 private String path; 24 private boolean closed = false; 25 26 29 public SiteFileNonPluginContentConsumer(String featurePath) { 30 this.path = featurePath; 31 } 32 33 36 public void store(ContentReference contentReference, IProgressMonitor monitor) throws CoreException { 37 38 if (closed) { 39 UpdateCore.warn("Attempt to store in a closed SiteFileNonPluginContentConsumer", new Exception ()); return; 41 } 42 43 InputStream inStream = null; 44 String featurePath = path; 45 String contentKey = contentReference.getIdentifier(); 46 featurePath += contentKey; 47 try { 48 inStream = contentReference.getInputStream(); 49 UpdateManagerUtils.copyToLocal(inStream, featurePath, null); 50 UpdateManagerUtils.checkPermissions(contentReference, featurePath); } catch (IOException e) { 52 throw Utilities.newCoreException(NLS.bind(Messages.GlobalConsumer_ErrorCreatingFile, (new String [] { featurePath })), e); 53 } finally { 54 if (inStream != null) { 55 try { 56 inStream.close(); 58 } catch (IOException e) { 59 } 60 } 61 } 62 63 } 64 65 68 public void close() { 69 if (closed) { 70 UpdateCore.warn("Attempt to close a closed SiteFileNonPluginContentConsumer", new Exception ()); return; 72 } 73 closed = true; 74 } 75 76 } 77 | Popular Tags |