当前位置: 首页>>代码示例>>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: 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

示例5: 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

示例6: 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

示例7: 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

示例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;未经允许,请勿转载。