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.Arrays;
25 import java.util.EnumSet;
26 import java.util.List;
29 import java.util.logging.Level;
30 import java.util.stream.Collectors;
31 import javax.swing.Action;
32 import org.apache.commons.lang3.StringUtils;
33 import org.openide.nodes.Children;
34 import org.openide.nodes.Sheet;
35 import org.openide.util.NbBundle;
36 import org.openide.util.WeakListeners;
62 @NbBundle.Messages(
"AbstractAbstractFileNode.addFileProperty.desc=no description")
63 private static final String
NO_DESCR = AbstractAbstractFileNode_addFileProperty_desc();
73 String ext = abstractFile.getNameExtension();
74 if (StringUtils.isNotBlank(ext)) {
107 private final PropertyChangeListener
pcl = (PropertyChangeEvent evt) -> {
108 String eventType = evt.getPropertyName();
116 if ((moduleContentEvent.getSource() instanceof Content) ==
false) {
119 Content newContent = (Content) moduleContentEvent.getSource();
122 if (
getContent().getId() == newContent.getId()) {
125 Children parentsChildren = getParentNode().getChildren();
130 if (parentsChildren instanceof ContentChildren) {
131 ((ContentChildren) parentsChildren).refreshChildren();
132 parentsChildren.getNodesCount();
134 }
catch (NullPointerException ex) {
139 if (evt.getNewValue() == null) {
145 if (event.getAddedTag().getContent().equals(content)) {
150 if (event.getDeletedTagInfo().getContentID() == content.getId()) {
164 private final PropertyChangeListener
weakPcl = WeakListeners.propertyChange(pcl, null);
167 this.setSheet(createSheet());
170 @NbBundle.Messages({
"AbstractAbstractFileNode.nameColLbl=Name",
171 "AbstractAbstractFileNode.locationColLbl=Location",
172 "AbstractAbstractFileNode.modifiedTimeColLbl=Modified Time",
173 "AbstractAbstractFileNode.changeTimeColLbl=Change Time",
174 "AbstractAbstractFileNode.accessTimeColLbl=Access Time",
175 "AbstractAbstractFileNode.createdTimeColLbl=Created Time",
176 "AbstractAbstractFileNode.sizeColLbl=Size",
177 "AbstractAbstractFileNode.flagsDirColLbl=Flags(Dir)",
178 "AbstractAbstractFileNode.flagsMetaColLbl=Flags(Meta)",
179 "AbstractAbstractFileNode.modeColLbl=Mode",
180 "AbstractAbstractFileNode.useridColLbl=UserID",
181 "AbstractAbstractFileNode.groupidColLbl=GroupID",
182 "AbstractAbstractFileNode.metaAddrColLbl=Meta Addr.",
183 "AbstractAbstractFileNode.attrAddrColLbl=Attr. Addr.",
184 "AbstractAbstractFileNode.typeDirColLbl=Type(Dir)",
185 "AbstractAbstractFileNode.typeMetaColLbl=Type(Meta)",
186 "AbstractAbstractFileNode.knownColLbl=Known",
187 "AbstractAbstractFileNode.inHashsetsColLbl=In Hashsets",
188 "AbstractAbstractFileNode.md5HashColLbl=MD5 Hash",
189 "AbstractAbstractFileNode.objectId=Object ID",
190 "AbstractAbstractFileNode.mimeType=MIME Type",
191 "AbstractAbstractFileNode.extensionColLbl=Extension"})
194 NAME(AbstractAbstractFileNode_nameColLbl()),
195 LOCATION(AbstractAbstractFileNode_locationColLbl()),
196 MOD_TIME(AbstractAbstractFileNode_modifiedTimeColLbl()),
200 SIZE(AbstractAbstractFileNode_sizeColLbl()),
203 MODE(AbstractAbstractFileNode_modeColLbl()),
204 USER_ID(AbstractAbstractFileNode_useridColLbl()),
205 GROUP_ID(AbstractAbstractFileNode_groupidColLbl()),
208 TYPE_DIR(AbstractAbstractFileNode_typeDirColLbl()),
210 KNOWN(AbstractAbstractFileNode_knownColLbl()),
211 HASHSETS(AbstractAbstractFileNode_inHashsetsColLbl()),
212 MD5HASH(AbstractAbstractFileNode_md5HashColLbl()),
220 this.displayString = displayString;
225 return displayString;
237 map.put(NAME.toString(), getContentDisplayName(content));
243 map.put(SIZE.toString(), content.getSize());
244 map.put(FLAGS_DIR.toString(), content.getDirFlagAsString());
245 map.put(FLAGS_META.toString(), content.getMetaFlagsAsString());
246 map.put(MODE.toString(), content.getModesAsString());
247 map.put(USER_ID.toString(), content.getUid());
248 map.put(GROUP_ID.toString(), content.getGid());
249 map.put(META_ADDR.toString(), content.getMetaAddr());
250 map.put(ATTR_ADDR.toString(), content.getAttrType().getValue() +
"-" + content.getAttributeId());
251 map.put(TYPE_DIR.toString(), content.getDirType().getLabel());
252 map.put(TYPE_META.toString(), content.getMetaType().toString());
253 map.put(KNOWN.toString(), content.getKnown().getName());
255 map.put(MD5HASH.toString(), StringUtils.defaultString(content.getMd5Hash()));
256 map.put(ObjectID.toString(), content.getId());
257 map.put(MIMETYPE.toString(), StringUtils.defaultString(content.getMIMEType()));
258 map.put(EXTENSION.toString(), content.getNameExtension());
263 List<Action> actionsList =
new ArrayList<>();
265 actionsList.addAll(Arrays.asList(super.getActions(
true)));
268 AbstractFile file = content;
273 return actionsList.toArray(
new Action[actionsList.size()]);
283 @NbBundle.Messages(
"AbstractAbstractFileNode.tagsProperty.displayName=Tags")
285 List<ContentTag> tags =
new ArrayList<>();
289 logger.log(Level.SEVERE,
"Failed to get tags for content " + content.getName(), ex);
291 sheetSet.put(
new NodeProperty<>(
"Tags", AbstractAbstractFileNode_tagsProperty_displayName(),
292 NO_DESCR, tags.stream().map(t -> t.getName().getDisplayName())
294 .collect(Collectors.joining(
", "))));
299 return file.getUniquePath();
300 }
catch (TskCoreException ex) {
301 logger.log(Level.SEVERE,
"Except while calling Content.getUniquePath() on " + file, ex);
306 static String getContentDisplayName(AbstractFile file) {
307 String name = file.getName();
321 return StringUtils.join(file.getHashSetNames(),
", ");
322 }
catch (TskCoreException tskCoreException) {
323 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 boolean useCentralRepo()
static boolean isSupportedAbstractFileType(AbstractFile file)
static void fillPropertyMap(Map< String, Object > map, AbstractFile content)
TagsManager getTagsManager()
static final Set< Case.Events > CASE_EVENTS_OF_INTEREST
Action[] getActions(boolean context)
static final String NO_DESCR
AbstractFilePropertyType(String displayString)
void addIngestModuleEventListener(final PropertyChangeListener listener)
synchronized static Logger getLogger(String name)
static Case getCurrentCaseThrows()
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