19 package org.sleuthkit.autopsy.datamodel;
21 import java.beans.PropertyChangeEvent;
22 import java.beans.PropertyChangeListener;
23 import java.util.ArrayList;
24 import java.util.EnumSet;
25 import java.util.List;
28 import java.util.logging.Level;
29 import java.util.stream.Collectors;
30 import org.apache.commons.lang3.StringUtils;
31 import org.openide.nodes.Children;
32 import org.openide.nodes.Sheet;
33 import org.openide.util.NbBundle;
34 import org.openide.util.WeakListeners;
57 @NbBundle.Messages(
"AbstractAbstractFileNode.addFileProperty.desc=no description")
58 private static final String
NO_DESCR = AbstractAbstractFileNode_addFileProperty_desc();
68 String ext = abstractFile.getNameExtension();
69 if (StringUtils.isNotBlank(ext)) {
102 private final PropertyChangeListener
pcl = (PropertyChangeEvent evt) -> {
103 String eventType = evt.getPropertyName();
111 if ((moduleContentEvent.getSource() instanceof Content) ==
false) {
114 Content newContent = (Content) moduleContentEvent.getSource();
117 if (
getContent().getId() == newContent.getId()) {
120 Children parentsChildren = getParentNode().getChildren();
125 if (parentsChildren instanceof ContentChildren) {
126 ((ContentChildren) parentsChildren).refreshChildren();
127 parentsChildren.getNodesCount();
129 }
catch (NullPointerException ex) {
134 if (evt.getNewValue() == null) {
140 if (event.getAddedTag().getContent().equals(content)) {
145 if (event.getDeletedTagInfo().getContentID() == content.getId()) {
159 private final PropertyChangeListener
weakPcl = WeakListeners.propertyChange(pcl, null);
162 this.setSheet(createSheet());
165 @NbBundle.Messages({
"AbstractAbstractFileNode.nameColLbl=Name",
166 "AbstractAbstractFileNode.locationColLbl=Location",
167 "AbstractAbstractFileNode.modifiedTimeColLbl=Modified Time",
168 "AbstractAbstractFileNode.changeTimeColLbl=Change Time",
169 "AbstractAbstractFileNode.accessTimeColLbl=Access Time",
170 "AbstractAbstractFileNode.createdTimeColLbl=Created Time",
171 "AbstractAbstractFileNode.sizeColLbl=Size",
172 "AbstractAbstractFileNode.flagsDirColLbl=Flags(Dir)",
173 "AbstractAbstractFileNode.flagsMetaColLbl=Flags(Meta)",
174 "AbstractAbstractFileNode.modeColLbl=Mode",
175 "AbstractAbstractFileNode.useridColLbl=UserID",
176 "AbstractAbstractFileNode.groupidColLbl=GroupID",
177 "AbstractAbstractFileNode.metaAddrColLbl=Meta Addr.",
178 "AbstractAbstractFileNode.attrAddrColLbl=Attr. Addr.",
179 "AbstractAbstractFileNode.typeDirColLbl=Type(Dir)",
180 "AbstractAbstractFileNode.typeMetaColLbl=Type(Meta)",
181 "AbstractAbstractFileNode.knownColLbl=Known",
182 "AbstractAbstractFileNode.inHashsetsColLbl=In Hashsets",
183 "AbstractAbstractFileNode.md5HashColLbl=MD5 Hash",
184 "AbstractAbstractFileNode.objectId=Object ID",
185 "AbstractAbstractFileNode.mimeType=MIME Type",
186 "AbstractAbstractFileNode.extensionColLbl=Extension"})
189 NAME(AbstractAbstractFileNode_nameColLbl()),
190 LOCATION(AbstractAbstractFileNode_locationColLbl()),
191 MOD_TIME(AbstractAbstractFileNode_modifiedTimeColLbl()),
195 SIZE(AbstractAbstractFileNode_sizeColLbl()),
198 MODE(AbstractAbstractFileNode_modeColLbl()),
199 USER_ID(AbstractAbstractFileNode_useridColLbl()),
200 GROUP_ID(AbstractAbstractFileNode_groupidColLbl()),
203 TYPE_DIR(AbstractAbstractFileNode_typeDirColLbl()),
205 KNOWN(AbstractAbstractFileNode_knownColLbl()),
206 HASHSETS(AbstractAbstractFileNode_inHashsetsColLbl()),
207 MD5HASH(AbstractAbstractFileNode_md5HashColLbl()),
215 this.displayString = displayString;
220 return displayString;
232 map.put(NAME.toString(), getContentDisplayName(content));
238 map.put(SIZE.toString(), content.getSize());
239 map.put(FLAGS_DIR.toString(), content.getDirFlagAsString());
240 map.put(FLAGS_META.toString(), content.getMetaFlagsAsString());
241 map.put(MODE.toString(), content.getModesAsString());
242 map.put(USER_ID.toString(), content.getUid());
243 map.put(GROUP_ID.toString(), content.getGid());
244 map.put(META_ADDR.toString(), content.getMetaAddr());
245 map.put(ATTR_ADDR.toString(), content.getAttrType().getValue() +
"-" + content.getAttributeId());
246 map.put(TYPE_DIR.toString(), content.getDirType().getLabel());
247 map.put(TYPE_META.toString(), content.getMetaType().toString());
248 map.put(KNOWN.toString(), content.getKnown().getName());
250 map.put(MD5HASH.toString(), StringUtils.defaultString(content.getMd5Hash()));
251 map.put(ObjectID.toString(), content.getId());
252 map.put(MIMETYPE.toString(), StringUtils.defaultString(content.getMIMEType()));
253 map.put(EXTENSION.toString(), content.getNameExtension());
263 @NbBundle.Messages(
"AbstractAbstractFileNode.tagsProperty.displayName=Tags")
265 List<ContentTag> tags =
new ArrayList<>();
269 logger.log(Level.SEVERE,
"Failed to get tags for content " + content.getName(), ex);
271 sheetSet.put(
new NodeProperty<>(
"Tags", AbstractAbstractFileNode_tagsProperty_displayName(),
272 NO_DESCR, tags.stream().map(t -> t.getName().getDisplayName())
274 .collect(Collectors.joining(
", "))));
279 return file.getUniquePath();
280 }
catch (TskCoreException ex) {
281 logger.log(Level.SEVERE,
"Except while calling Content.getUniquePath() on " + file, ex);
286 static String getContentDisplayName(AbstractFile file) {
287 String name = file.getName();
301 return StringUtils.join(file.getHashSetNames(),
", ");
302 }
catch (TskCoreException tskCoreException) {
303 logger.log(Level.WARNING,
"Error getting hashset hits: ", tskCoreException);
static final Logger logger
void removeIngestModuleEventListener(final PropertyChangeListener listener)
static final String DOTDIR
static String getHashSetHitsForFile(AbstractFile file)
static String getStringTime(long epochSeconds, TimeZone tzone)
static List< String > getArchiveExtensions()
final String displayString
static synchronized IngestManager getInstance()
static String getContentPath(AbstractFile file)
static final String DOTDOTDIR
static Case getOpenCase()
static void fillPropertyMap(Map< String, Object > map, AbstractFile content)
TagsManager getTagsManager()
static final Set< Case.Events > CASE_EVENTS_OF_INTEREST
static final String NO_DESCR
AbstractFilePropertyType(String displayString)
void addIngestModuleEventListener(final PropertyChangeListener listener)
synchronized static Logger getLogger(String name)
static void addEventTypeSubscriber(Set< Events > eventTypes, PropertyChangeListener subscriber)
final PropertyChangeListener pcl
static void removeEventTypeSubscriber(Set< Events > eventTypes, PropertyChangeListener subscriber)
void addTagProperty(Sheet.Set sheetSet)
final PropertyChangeListener weakPcl