本文整理汇总了Java中javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR属性的典型用法代码示例。如果您正苦于以下问题:Java Status.INTERNAL_SERVER_ERROR属性的具体用法?Java Status.INTERNAL_SERVER_ERROR怎么用?Java Status.INTERNAL_SERVER_ERROR使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.ws.rs.core.Response.Status
的用法示例。
在下文中一共展示了Status.INTERNAL_SERVER_ERROR属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getExtraData
private String getExtraData() {
try {
Microservice microservice = RegistryUtils.getMicroservice();
MicroserviceInstance instance = RegistryUtils.getMicroserviceInstance();
return JsonUtils.writeValueAsString(new DefaultHealthCheckExtraData(
instance.getInstanceId(),
instance.getHostName(),
microservice.getAppId(),
microservice.getServiceName(),
microservice.getVersion(),
String.join(",", instance.getEndpoints())));
} catch (Exception e) {
String error = "unable load microservice info from RegistryUtils";
logger.error(error, e);
throw new InvocationException(Status.INTERNAL_SERVER_ERROR, error);
}
}
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:17,代码来源:DefaultMicroserviceHealthChecker.java
示例2: readFrom
@Override
public PropertyBox readFrom(Class<PropertyBox> type, Type genericType, Annotation[] annotations,
MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream)
throws IOException, WebApplicationException {
try (final Reader reader = new InputStreamReader(entityStream, CHARSET)) {
// check property set
PropertySet<?> propertySet = null;
if (!com.holonplatform.core.Context.get().resource(PropertySet.CONTEXT_KEY, PropertySet.class)
.isPresent()) {
PropertySetRef propertySetRef = PropertySetRefIntrospector.getPropertySetRef(annotations).orElse(null);
if (propertySetRef != null) {
try {
propertySet = getPropertySetRefIntrospector().getPropertySet(propertySetRef);
} catch (PropertySetIntrospectionException e) {
throw new WebApplicationException(e.getMessage(), e, Status.INTERNAL_SERVER_ERROR);
}
}
}
if (propertySet != null) {
return propertySet.execute(() -> readPropertyBox(reader));
} else {
return readPropertyBox(reader);
}
}
}
示例3: toResponse
@Override
public Response toResponse(Throwable t) {
if (t instanceof WebApplicationException) {
return ((WebApplicationException) t).getResponse();
}
Status status = Status.INTERNAL_SERVER_ERROR;
String message = Messages.ERROR_EXECUTING_REST_API_CALL;
if (t instanceof ContentException) {
status = Status.BAD_REQUEST;
} else if (t instanceof NotFoundException) {
status = Status.NOT_FOUND;
} else if (t instanceof ConflictException) {
status = Status.CONFLICT;
}
if (t instanceof SLException || t instanceof VirusScannerException) {
message = t.getMessage();
}
LOGGER.error(Messages.ERROR_EXECUTING_REST_API_CALL, t);
return Response.status(status).entity(message).type(MediaType.TEXT_PLAIN_TYPE).build();
}
示例4: startMultipart
@Override
public MultipartBean startMultipart(String uuid, String filepath, Boolean uploads)
{
if( uploads == null )
{
throw new BadRequestException("Must use PUT for uploading files");
}
StagingFile stagingFile = getStagingFile(uuid);
String uploadId = UUID.randomUUID().toString();
String folderPath = "multipart/" + uploadId;
ensureMultipartDir(stagingFile);
try
{
fileSystemService.mkdir(stagingFile, folderPath);
return new MultipartBean(uploadId);
}
catch( Exception e )
{
throw new WebApplicationException(Status.INTERNAL_SERVER_ERROR);
}
}
示例5: logout
@GET
@Path("/logout")
@Produces("text/plain")
@ApiResponses(value = { @ApiResponse(code = 500, message = "CustomerService Internal Server Error") })
public String logout(@QueryParam("login") String login, @CookieParam("sessionid") String sessionid) {
try {
customerService.invalidateSession(sessionid);
// The following call will trigger query against all partitions, disable for now
// customerService.invalidateAllUserSessions(login);
// TODO: Want to do this with setMaxAge to zero, but to do that I need to have the same path/domain as cookie
// created in login. Unfortunately, until we have a elastic ip and domain name its hard to do that for "localhost".
// doing this will set the cookie to the empty string, but the browser will still send the cookie to future requests
// and the server will need to detect the value is invalid vs actually forcing the browser to time out the cookie and
// not send it to begin with
// NewCookie sessCookie = new NewCookie(SESSIONID_COOKIE_NAME, "");
return "logged out";
}
catch (Exception e) {
throw new InvocationException(Status.INTERNAL_SERVER_ERROR, "Internal Server Error");
}
}
示例6: readFrom
@Override
public Object readFrom(Class<Object> type, Type genericType, Annotation[] annotations, MediaType mediaType,
MultivaluedMap<String, String> httpHeaders, InputStream entityStream)
throws IOException, WebApplicationException {
final Type jsonType = type.equals(genericType) ? type : genericType;
try (final Reader reader = new InputStreamReader(entityStream, CHARSET)) {
// check property set
PropertySet<?> propertySet = null;
if (isPropertyBoxType(jsonType) && !com.holonplatform.core.Context.get()
.resource(PropertySet.CONTEXT_KEY, PropertySet.class).isPresent()) {
PropertySetRef propertySetRef = PropertySetRefIntrospector.getPropertySetRef(annotations).orElse(null);
if (propertySetRef != null) {
try {
propertySet = getPropertySetRefIntrospector().getPropertySet(propertySetRef);
} catch (PropertySetIntrospectionException e) {
throw new WebApplicationException(e.getMessage(), e, Status.INTERNAL_SERVER_ERROR);
}
}
}
if (propertySet != null) {
return propertySet.execute(() -> readPropertyBox(reader, jsonType));
} else {
return readPropertyBox(reader, jsonType);
}
}
}
示例7: initServiceProviders
/**
* Retrieve a list of products from Bugzilla and construct a service provider for each.
*
* Each product ID is added to the parameter map which will be used during service provider
* creation to create unique URI paths for each Bugzilla product. See @Path definition at
* the top of BugzillaChangeRequestService.
*
* @param httpServletRequest
*/
protected static void initServiceProviders (HttpServletRequest httpServletRequest)
{
try {
// Start of user code initServiceProviders
// End of user code
String basePath = OSLC4JUtils.getServletURI();
ServiceProviderInfo [] serviceProviderInfos = PlannerReasonerManager.getServiceProviderInfos(httpServletRequest);
//Register each service provider
for (ServiceProviderInfo serviceProviderInfo : serviceProviderInfos) {
String identifier = serviceProviderIdentifier(serviceProviderInfo.serviceProviderId);
if (!serviceProviders.containsKey(identifier)) {
String serviceProviderName = serviceProviderInfo.name;
String title = String.format("Service Provider '%s'", serviceProviderName);
String description = String.format("%s (id: %s; kind: %s)",
"Robot planner provider",
identifier,
"robot");
Publisher publisher = null;
Map<String, Object> parameterMap = new HashMap<String, Object>();
parameterMap.put("serviceProviderId", serviceProviderInfo.serviceProviderId);
final ServiceProvider aServiceProvider = ServiceProvidersFactory.createServiceProvider(basePath, title, description, publisher, parameterMap);
registerServiceProvider(aServiceProvider, serviceProviderInfo.serviceProviderId);
}
}
} catch (Exception e) {
e.printStackTrace();
throw new WebApplicationException(e,Status.INTERNAL_SERVER_ERROR);
}
}
示例8: readFrom
@Override
public PropertyBox readFrom(Class<PropertyBox> type, Type genericType, Annotation[] annotations,
MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream)
throws IOException, WebApplicationException {
try (InputStreamReader isr = new InputStreamReader(entityStream, CHARSET);
BufferedReader reader = new BufferedReader(isr)) {
// read into String
StringBuffer content = new StringBuffer();
String line = null;
while ((line = reader.readLine()) != null) {
content.append(line);
}
// check property set
PropertySet<?> propertySet = null;
if (!com.holonplatform.core.Context.get().resource(PropertySet.CONTEXT_KEY, PropertySet.class)
.isPresent()) {
PropertySetRef propertySetRef = PropertySetRefIntrospector.getPropertySetRef(annotations).orElse(null);
if (propertySetRef != null) {
try {
propertySet = getPropertySetRefIntrospector().getPropertySet(propertySetRef);
} catch (PropertySetIntrospectionException e) {
throw new WebApplicationException(e.getMessage(), e, Status.INTERNAL_SERVER_ERROR);
}
}
}
if (propertySet != null) {
return propertySet.execute(() -> readPropertyBox(content.toString()));
} else {
return readPropertyBox(content.toString());
}
}
}
示例9: deleteFile
@Override
public Response deleteFile(String stagingUuid, String filepath)
{
final StagingFile stagingFile = getStagingFile(stagingUuid);
ensureFileExists(stagingFile, filepath);
boolean removed = fileSystemService.removeFile(stagingFile, filepath);
if( !removed )
{
throw new WebApplicationException(Status.INTERNAL_SERVER_ERROR);
}
return Response.status(Status.NO_CONTENT).build();
}
示例10: listFiles
@Override
public FileListBean listFiles(UriInfo uriInfo, String uuid, int version)
{
ItemId itemId = new ItemId(uuid, version);
checkViewItem(itemId);
ItemFile itemFile = itemFileService.getItemFile(itemId, null);
FileEntry base;
try
{
base = fileSystemService.enumerateTree(itemFile, "", null);
}
catch( IOException e )
{
throw new WebApplicationException(Status.INTERNAL_SERVER_ERROR);
}
List<BlobBean> blobs = Lists.newArrayList();
for( FileEntry fileEntry : base.getFiles() )
{
buildBlobBeans(itemFile, uuid, version, blobs, fileEntry, "");
}
Collections.sort(blobs, new Comparator<BlobBean>()
{
@Override
public int compare(BlobBean o1, BlobBean o2)
{
return o1.getName().compareToIgnoreCase(o2.getName());
}
});
final FileListBean fileList = new FileListBean();
fileList.setFiles(blobs);
return fileList;
}
示例11: deleteFile
@Override
public Response deleteFile(String stagingUuid, String filepath, String uploadId) throws IOException
{
final StagingFile stagingFile = getStagingFile(stagingUuid);
ensureFileExists(stagingFile, filepath);
boolean removed = fileSystemService.removeFile(stagingFile, filepath);
if( !removed )
{
throw new WebApplicationException(Status.INTERNAL_SERVER_ERROR);
}
return Response.status(Status.NO_CONTENT).build();
}
示例12: ensureMultipartDir
private void ensureMultipartDir(StagingFile handle)
{
try
{
if( !fileSystemService.fileExists(handle, "multipart") )
{
fileSystemService.mkdir(handle, "multipart");
}
}
catch( Exception e )
{
throw new WebApplicationException(Status.INTERNAL_SERVER_ERROR);
}
}
示例13: initServiceProviders
/**
* Retrieve a list of products from Bugzilla and construct a service provider for each.
*
* Each product ID is added to the parameter map which will be used during service provider
* creation to create unique URI paths for each Bugzilla product. See @Path definition at
* the top of BugzillaChangeRequestService.
*
* @param httpServletRequest
*/
protected static void initServiceProviders (HttpServletRequest httpServletRequest)
{
try {
// Start of user code initServiceProviders
// End of user code
String basePath = OSLC4JUtils.getServletURI();
ServiceProviderInfo [] serviceProviderInfos = WarehouseControllerManager.getServiceProviderInfos(httpServletRequest);
//Register each service provider
for (ServiceProviderInfo serviceProviderInfo : serviceProviderInfos) {
String identifier = serviceProviderIdentifier(serviceProviderInfo.serviceProviderId);
if (!serviceProviders.containsKey(identifier)) {
String serviceProviderName = serviceProviderInfo.name;
String title = String.format("Service Provider '%s'", serviceProviderName);
String description = String.format("%s (id: %s; kind: %s)",
"Service Provider",
identifier,
"Service Provider");
Publisher publisher = null;
Map<String, Object> parameterMap = new HashMap<String, Object>();
parameterMap.put("serviceProviderId", serviceProviderInfo.serviceProviderId);
final ServiceProvider aServiceProvider = ServiceProvidersFactory.createServiceProvider(basePath, title, description, publisher, parameterMap);
registerServiceProvider(aServiceProvider, serviceProviderInfo.serviceProviderId);
}
}
} catch (Exception e) {
e.printStackTrace();
throw new WebApplicationException(e,Status.INTERNAL_SERVER_ERROR);
}
}
示例14: ApiException
public ApiException(Throwable cause){
super(cause);
status = Status.INTERNAL_SERVER_ERROR;
}
示例15: RollbackExceptionMapper
public RollbackExceptionMapper() {
super(Status.INTERNAL_SERVER_ERROR);
}