001package co.codewizards.cloudstore.local.persistence; 002 003 004import java.util.ArrayList; 005import java.util.Collection; 006 007import javax.jdo.Query; 008 009import co.codewizards.cloudstore.core.util.AssertUtil; 010 011public class NormalFileDao extends Dao<NormalFile, NormalFileDao> { 012 /** 013 * Get those {@link RepoFile}s whose {@link RepoFile#getSha1() sha1} and {@link RepoFile#getLength() length} 014 * match the given parameters. 015 * @param sha1 the {@link RepoFile#getSha1() sha1} for which to query. Must not be <code>null</code>. 016 * @param length the {@link RepoFile#getLength() length} for which to query. 017 * @return those {@link RepoFile}s matching the given criteria. Never <code>null</code>; but maybe empty. 018 */ 019 public Collection<NormalFile> getNormalFilesForSha1(final String sha1, final long length) { 020 AssertUtil.assertNotNull(sha1, "sha1"); 021 final Query query = pm().newNamedQuery(getEntityClass(), "getNormalFiles_sha1_length"); 022 try { 023 @SuppressWarnings("unchecked") 024 final 025 Collection<NormalFile> repoFiles = (Collection<NormalFile>) query.execute(sha1, length); 026 return new ArrayList<NormalFile>(repoFiles); 027 } finally { 028 query.closeAll(); 029 } 030 } 031 032 @Override 033 public void deletePersistent(final NormalFile entity) { 034 throw new UnsupportedOperationException("Use RepoFileDao for this operation!"); 035 } 036 037 @Override 038 public <P extends NormalFile> P makePersistent(final P entity) { 039 throw new UnsupportedOperationException("Use RepoFileDao for this operation!"); 040 } 041}