package net.sourceforge.fenixedu.domain; import java.util.Collection; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Set; import net.sourceforge.fenixedu.util.ByteArray; import pt.utl.ist.fenix.tools.file.FileSetMetaData; import pt.utl.ist.fenix.tools.file.VirtualPath; public class FileLocalContent extends FileLocalContent_Base { public FileLocalContent(File file, VirtualPath path, Collection metadata, byte[] content) { super(); setFile(file); setPath(path); if (metadata != null) { for (FileSetMetaData entry : metadata) { new FileLocalContentMetadata(this, entry); } } setContent(new ByteArray(content)); setRootDomainObject(RootDomainObject.getInstance()); } public Collection createMetadata() { Set metadata = new HashSet(); for (FileLocalContentMetadata entry : super.getMetadata()) { metadata.add(entry.getEntry()); } return metadata; } /** * @use {@link #createMetadata()}) */ @Override public List getMetadata() { throw new UnsupportedOperationException(); } /** * @use {@link #createMetadata()}) */ @Override public Set getMetadataSet() { throw new UnsupportedOperationException(); } /** * @use {@link #createMetadata()}) */ @Override public Iterator getMetadataIterator() { throw new UnsupportedOperationException(); } public void delete() { removeFile(); for (FileLocalContentMetadata metadata : super.getMetadataSet()) { metadata.delete(); } removeRootDomainObject(); deleteDomainObject(); } }