19 package org.sleuthkit.autopsy.datamodel;
 
   21 import java.io.FileOutputStream;
 
   22 import java.io.IOException;
 
   23 import java.io.InputStream;
 
   24 import java.text.SimpleDateFormat;
 
   25 import java.util.TimeZone;
 
   26 import java.util.logging.Level;
 
   27 import java.util.prefs.PreferenceChangeEvent;
 
   28 import java.util.prefs.PreferenceChangeListener;
 
   29 import org.openide.util.NbBundle;
 
   31 import javax.swing.SwingWorker;
 
   32 import org.netbeans.api.progress.ProgressHandle;
 
   54     private static final SimpleDateFormat 
dateFormatter = 
new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss z");
 
   55     private static final SimpleDateFormat 
dateFormatterISO8601 = 
new SimpleDateFormat(
"yyyy-MM-dd'T'HH:mm:ss'Z'");
 
   60             public void preferenceChange(PreferenceChangeEvent evt) {
 
   70         throw new AssertionError();
 
   81         String time = 
"0000-00-00 00:00:00";
 
   82         if (epochSeconds != 0) {
 
   84                 dateFormatter.setTimeZone(tzone);
 
   85                 time = dateFormatter.format(
new java.util.Date(epochSeconds * 1000));
 
   92         String time = 
"0000-00-00T00:00:00Z"; 
 
   93         if (epochSeconds != 0) {
 
   95                 dateFormatterISO8601.setTimeZone(tzone);
 
   96                 time = dateFormatterISO8601.format(
new java.util.Date(epochSeconds * 1000));
 
  130                 return TimeZone.getTimeZone(
"GMT");
 
  134                 if ((dataSource != null) && (dataSource instanceof 
Image)) {
 
  135                     Image image = (Image)dataSource;
 
  139                     return TimeZone.getDefault();
 
  143             return TimeZone.getDefault();
 
  149         return content.
accept(systemName);
 
  159             return cntnt.
getName() + 
":" + Long.toString(cntnt.
getId());
 
  180             ProgressHandle progress, SwingWorker<T,V> worker, 
boolean source) 
throws IOException {
 
  184         boolean append = 
false;
 
  185         FileOutputStream out = 
new FileOutputStream(outputFile, append);
 
  188         int unit = (int) (content.getSize() / 100);
 
  193             int len = in.read(buffer);
 
  196                 if (worker != null && worker.isCancelled()) {
 
  199                 out.write(buffer, 0, len);
 
  200                 len = in.read(buffer);
 
  204                 if (progress != null && source && totalRead >= TO_FILE_BUFFER_SIZE) {
 
  205                     int totalProgress = (int) (totalRead / unit);
 
  206                     progress.progress(content.getName(), totalProgress);
 
  208                 } 
else if (progress != null && !source) {
 
  209                     progress.progress(content.getName());
 
  219         writeToFile(content, outputFile, null, null, 
false);
 
  227         return name.equals(
".") || name.equals(
"..");
 
  238         ProgressHandle progress;
 
  239         SwingWorker<T,V> worker;
 
  240         boolean source = 
false;
 
  254                 ProgressHandle progress, SwingWorker<T,V> worker, 
boolean source) {
 
  256             this.progress = progress;
 
  257             this.worker = worker;
 
  258             this.source = source;
 
  269         public static <T,V> 
void extract(
Content cntnt, java.io.File dest, ProgressHandle progress, SwingWorker<T,V> worker) {
 
  277             } 
catch (IOException ex) {
 
  278                 logger.log(Level.SEVERE,
 
  279                         "Trouble extracting file to " + dest.getAbsolutePath(), 
 
  289             } 
catch (IOException ex) {
 
  290                 logger.log(Level.SEVERE,
 
  291                         "Trouble extracting unallocated content file to " + dest.getAbsolutePath(), 
 
  301             } 
catch (IOException ex) {
 
  302                 logger.log(Level.SEVERE,
 
  303                         "Error extracting derived file to " + dest.getAbsolutePath(), 
 
  313             } 
catch (IOException ex) {
 
  314                 logger.log(Level.SEVERE,
 
  315                         "Error extracting local file to " + dest.getAbsolutePath(), 
 
  332             String path = dest.getAbsolutePath() + java.io.
File.separator
 
  334             return new java.io.File(path);
 
  349                 int numProcessed = 0;
 
  358                     if (worker != null && worker.isCancelled()) {
 
  361                     if (progress != null && source) {
 
  362                         progress.progress(child.getName(), numProcessed);
 
  364                     child.accept(childVisitor);
 
  368                 logger.log(Level.SEVERE,
 
  369                         "Trouble fetching children to extract.", ex); 
 
  377             throw new UnsupportedOperationException(NbBundle.getMessage(
this.getClass(),
 
  378                                                                         "ContentUtils.exception.msg",
 
  379                                                                         cntnt.getClass().getSimpleName()));
 
static String getStringTime(long epochSeconds, TimeZone tzone)
static< T, V > long writeToFile(Content content, java.io.File outputFile, ProgressHandle progress, SwingWorker< T, V > worker, boolean source)
File(SleuthkitCase db, long objId, long fsObjId, TSK_FS_ATTR_TYPE_ENUM attrType, short attrId, String name, long metaAddr, int metaSeq, TSK_FS_NAME_TYPE_ENUM dirType, TSK_FS_META_TYPE_ENUM metaType, TSK_FS_NAME_FLAG_ENUM dirFlag, short metaFlags, long size, long ctime, long crtime, long atime, long mtime, short modes, int uid, int gid, String md5Hash, FileKnown knownState, String parentPath)
static final SimpleDateFormat dateFormatter
String defaultVisit(Content cntnt)
static boolean shouldDisplayTimesInLocalTime()
static final Logger logger
static final int TO_FILE_BUFFER_SIZE
static String getSystemName(Content content)
List< Content > getChildren()
static String getStringTimeISO8601(long epochSeconds, TimeZone tzone)
static final SimpleDateFormat dateFormatterISO8601
static final String DISPLAY_TIMES_IN_LOCAL_TIME
static final SystemNameVisitor systemName
static String getStringTime(long epochSeconds, Content c)
static String getStringTimeISO8601(long epochSeconds, Content c)
public< T > T accept(ContentVisitor< T > v)
static void addChangeListener(PreferenceChangeListener listener)
static boolean displayTimesInLocalTime
static TimeZone getTimeZone(Content c)
static void writeToFile(Content content, java.io.File outputFile)
static boolean displayTimesInLocalTime()
static boolean isDotDirectory(AbstractFile dir)
static Logger getLogger(String name)