Package com.kolich.havalo.exceptions.objects

Examples of com.kolich.havalo.exceptions.objects.ObjectNotFoundException


            // Add the object to repository.
            repo.addObject(key, hfo);
          } else if(hfo == null && failIfNotFound) {
            // The object with the given key did not exist in
            // this repository.
            throw new ObjectNotFoundException("Object not found " +
              "(id=" + repo.getRepoId() + ", key=" + key + ")");
          }
          return hfo;
        }
      }.read(false); // Shared reader lock on repo, no wait
View Full Code Here


          // Get the object we're going to delete.
          final HashedFileObject hfo = repo.getObject(key);
          // Make sure the object exists -- if there was no object
          // with the given key in the repo then it does not exist.
          if(hfo == null) {
            throw new ObjectNotFoundException("Object " +
              "not found (id=" + repo.getRepoId() + ", key=" +
                  key + ")");
          }
          // Now attempt to grab an exclusive write lock on the
          // file object do delete.  And, attempt to follow through
          // on the physical delete from the platters.
          return new ReentrantReadWriteEntityLock<HashedFileObject>(hfo) {
            @Override
            public HashedFileObject transaction() throws Exception {
              final String eTag = hfo.getFirstHeader(ETAG);
              // If we have an incoming If-Match, we need to
              // compare that against the current HFO before we
              // attempt to delete.  If the If-Match ETag does not
              // match, fail.
              if(ifMatch != null && eTag != null) {
                // OK, we have an incoming If-Match ETag, use it.
                if(!ifMatch.equals(eTag)) {
                  throw new ObjectConflictException("Failed " +
                    "to delete HFO; incoming If-Match " +
                    "ETag does not match (hfo=" +
                    hfo.getName() + ", etag=" +
                    eTag + ", if-match=" + ifMatch + ")");
                }
              }
              // OK, we either didn't have an incoming If-Match
              // to check, or we did and it passed -- grab a
              // pointer to the actual File on disk.
              final File hfoFile = getCanonicalObject(repo.getFile(),
                getSHA256Hash(key), false).getFile();
              // Validate that the file exists before we attempt
              // to physically remove it from disk.
              if(hfoFile.exists()) {
                if(deleteQuietly(hfoFile)) {
                  repo.deleteObject(key);
                } else {
                  throw new ObjectDeletionException("Failed " +
                    "to delete object from disk (file=" +
                      hfoFile.getAbsolutePath() +
                        ", id=" + repo.getRepoId() + ")");
                }
              } else {
                // So the object was in the index in memory, but
                // was not found on disk. Hm, probably a bigger
                // issue.
                throw new ObjectNotFoundException("Object " +
                  "file on disk not found (file=" +
                    hfoFile.getAbsolutePath() + ", id=" +
                      repo.getRepoId() + ", key=" +
                        key + ")");
              }
View Full Code Here

                    public HashedFileObject transaction() throws Exception {
                        final DiskObject object = getCanonicalObject(repo, hfo);
                        // Validate that the object file exists on disk
                        // before we attempt to load it.
                        if(!object.getFile().exists()) {
                            throw new ObjectNotFoundException("Failed " +
                                "to find canonical object on disk " +
                                "(key=" + key + ", file=" +
                                object.getFile().getAbsolutePath() +
                                ")");
                        }
View Full Code Here

                                            final HashedFileObject hfo,
                                            final HttpServletResponse response) {
        checkNotNull(hfo, "Hashed file object cannot be null.");
        // Validate that the File object still exists.
        if(!object.getFile().exists()) {
            throw new ObjectNotFoundException("Object not " +
                "found (file=" + object.getFile().getAbsolutePath() +
                ", key=" + hfo.getName() + ")");
        }
        // Extract any response headers from this objects' meta data.
        final Map<String,List<String>> headers = hfo.getHeaders();
View Full Code Here

TOP

Related Classes of com.kolich.havalo.exceptions.objects.ObjectNotFoundException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.