當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpStatus.SC_NOT_FOUND屬性代碼示例

本文整理匯總了Java中org.apache.commons.httpclient.HttpStatus.SC_NOT_FOUND屬性的典型用法代碼示例。如果您正苦於以下問題:Java HttpStatus.SC_NOT_FOUND屬性的具體用法?Java HttpStatus.SC_NOT_FOUND怎麽用?Java HttpStatus.SC_NOT_FOUND使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.apache.commons.httpclient.HttpStatus的用法示例。


在下文中一共展示了HttpStatus.SC_NOT_FOUND屬性的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: listObjects

@Override
public ListObjectsResult listObjects(String bucketName, String prefix) {
    ListObjectsResult result = new ListObjectsResult();
    ArrayList<S3Object> list = new ArrayList<>();
    Path path = Paths.get(this.baseDir, bucketName, prefix);
    try {
        if (Files.exists(path)) {
            if (Files.isDirectory(path)) {
                Files.list(path).forEach(file -> {
                    addFileAsObjectToList(file, list, bucketName);
                });
            } else {
                addFileAsObjectToList(path, list, bucketName);
            }
        }
    } catch (IOException e) {
        throw new S3Exception("NoSuchKey", HttpStatus.SC_NOT_FOUND, "NoSuchKey", "");
    }
    result.setObjects(list);
    return result;
}
 
開發者ID:pravega,項目名稱:pravega,代碼行數:21,代碼來源:S3FileSystemImpl.java

示例2: readObjectStream

@Override
public InputStream readObjectStream(String bucketName, String key, Range range) {
    byte[] bytes = new byte[Math.toIntExact(range.getLast() + 1 - range.getFirst())];
    Path path = Paths.get(this.baseDir, bucketName, key);
    FileInputStream returnStream;
    try {
        returnStream = new FileInputStream(path.toFile());
        if (range.getFirst() != 0) {
            long bytesSkipped = 0;
            do {
                bytesSkipped += returnStream.skip(range.getFirst());
            } while (bytesSkipped < range.getFirst());
        }
        StreamHelpers.readAll(returnStream, bytes, 0, bytes.length);
        return new ByteArrayInputStream(bytes);
    } catch (IOException e) {
        throw new S3Exception("NoSuchKey", HttpStatus.SC_NOT_FOUND, "NoSuchKey", "");
    }
}
 
開發者ID:pravega,項目名稱:pravega,代碼行數:19,代碼來源:S3FileSystemImpl.java

示例3: handleResponse

@Override
public T handleResponse(HttpResponse response) throws IOException {
  int statusCode = response.getStatusLine().getStatusCode();
  if (!isSuccessful(statusCode)) {
    if (statusCode == HttpStatus.SC_NOT_FOUND && myIgnoreNotFound) {
      return null;
    }
    throw RequestFailedException.forStatusCode(statusCode);
  }
  try {
    if (LOG.isDebugEnabled()) {
      String content = getResponseContentAsString(response);
      TaskUtil.prettyFormatJsonToLog(LOG, content);
      return myGson.fromJson(content, myClass);
    }
    else {
      return myGson.fromJson(getResponseContentAsReader(response), myClass);
    }
  }
  catch (JsonSyntaxException e) {
    LOG.warn("Malformed server response", e);
    return null;
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:24,代碼來源:TaskResponseUtil.java

示例4: copyPart

@Override
public CopyPartResult copyPart(CopyPartRequest request) {
    Map<Integer, CopyPartRequest> partMap = multipartUploads.get(request.getKey());
    if (partMap == null) {
        throw new S3Exception("NoSuchKey", HttpStatus.SC_NOT_FOUND, "NoSuchKey", "");
    }
    partMap.put(request.getPartNumber(), request);
    CopyPartResult result = new CopyPartResult();
    result.setPartNumber(request.getPartNumber());
    result.setETag(request.getUploadId());
    return result;
}
 
開發者ID:pravega,項目名稱:pravega,代碼行數:12,代碼來源:S3FileSystemImpl.java

示例5: executeMethod

@Override
public int executeMethod(HttpMethod httpMethod) {
    numberOfCallsToExecuteMethod++;
    if (failAlternateResponses && (numberOfCallsToExecuteMethod % 2 == 0)) {
        return HttpStatus.SC_NOT_FOUND;
    } else {
        return httpStatus;
    }
}
 
開發者ID:FluffyFairyGames,項目名稱:jenkins-telegram-plugin,代碼行數:9,代碼來源:HttpClientStub.java

示例6: setObjectAcl

@Synchronized
@Override
public void setObjectAcl(String bucketName, String key, AccessControlList acl) {
    AclSize retVal = aclMap.get(key);
    if (retVal == null) {
        throw new S3Exception("NoObject", HttpStatus.SC_NOT_FOUND, "NoSuchKey", key);
    }
    aclMap.put(key, retVal.withAcl(acl));
}
 
開發者ID:pravega,項目名稱:pravega,代碼行數:9,代碼來源:S3FileSystemImpl.java

示例7: getObjectAcl

@Override
public AccessControlList getObjectAcl(String bucketName, String key) {
    AclSize retVal = aclMap.get(key);
    if (retVal == null) {
        throw new S3Exception("NoObject", HttpStatus.SC_NOT_FOUND, "NoSuchKey", key);
    }
    return retVal.getAcl();
}
 
開發者ID:pravega,項目名稱:pravega,代碼行數:8,代碼來源:S3FileSystemImpl.java

示例8: getObjectMetadata

@Override
public S3ObjectMetadata getObjectMetadata(String bucketName, String key) {
    S3ObjectMetadata metadata = new S3ObjectMetadata();
    AclSize data = aclMap.get(key);
    if (data == null) {
        throw new S3Exception("NoSuchKey", HttpStatus.SC_NOT_FOUND, "NoSuchKey", "");
    }
    metadata.setContentLength(data.getSize());
    Path path = Paths.get(this.baseDir, bucketName, key);
    metadata.setLastModified(new Date(path.toFile().lastModified()));
    return metadata;
}
 
開發者ID:pravega,項目名稱:pravega,代碼行數:12,代碼來源:S3FileSystemImpl.java

示例9: completeMultipartUpload

@Synchronized
@Override
public CompleteMultipartUploadResult completeMultipartUpload(CompleteMultipartUploadRequest request) {
    Map<Integer, CopyPartRequest> partMap = multipartUploads.get(request.getKey());
    if (partMap == null) {
        throw new S3Exception("NoSuchKey", HttpStatus.SC_NOT_FOUND, "NoSuchKey", "");
    }
    try {
        partMap.forEach((index, copyPart) -> {
            if (copyPart.getKey() != copyPart.getSourceKey()) {
                Path sourcePath = Paths.get(this.baseDir, copyPart.getBucketName(), copyPart.getSourceKey());
                Path targetPath = Paths.get(this.baseDir, copyPart.getBucketName(), copyPart.getKey());
                try (FileChannel sourceChannel = FileChannel.open(sourcePath, StandardOpenOption.READ);
                     FileChannel targetChannel = FileChannel.open(targetPath, StandardOpenOption.WRITE)) {
                    targetChannel.transferFrom(sourceChannel, Files.size(targetPath),
                            copyPart.getSourceRange().getLast() + 1 - copyPart.getSourceRange().getFirst());
                    targetChannel.close();
                    AclSize aclMap = this.aclMap.get(copyPart.getKey());
                    this.aclMap.put(copyPart.getKey(), aclMap.withSize(Files.size(targetPath)));
                } catch (IOException e) {
                    throw new S3Exception("NoSuchKey", 404, "NoSuchKey", "");
                }
            }
        });
    } finally {
        multipartUploads.remove(request.getKey());
    }

    return new CompleteMultipartUploadResult();
}
 
開發者ID:pravega,項目名稱:pravega,代碼行數:30,代碼來源:S3FileSystemImpl.java

示例10: copyPart

@Override
public CopyPartResult copyPart(CopyPartRequest request) {
    if (aclMap.get(request.getKey()) == null) {
        throw new S3Exception("NoObject", HttpStatus.SC_NOT_FOUND, "NoSuchKey", request.getKey());
    }
    return client.copyPart(request);
}
 
開發者ID:pravega,項目名稱:pravega,代碼行數:7,代碼來源:S3ProxyImpl.java


注:本文中的org.apache.commons.httpclient.HttpStatus.SC_NOT_FOUND屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。