当前位置: 首页>>代码示例>>Java>>正文


Java InternalServerErrorException类代码示例

本文整理汇总了Java中javax.ws.rs.InternalServerErrorException的典型用法代码示例。如果您正苦于以下问题:Java InternalServerErrorException类的具体用法?Java InternalServerErrorException怎么用?Java InternalServerErrorException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


InternalServerErrorException类属于javax.ws.rs包,在下文中一共展示了InternalServerErrorException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sign

import javax.ws.rs.InternalServerErrorException; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public String sign(final JwtClaims claims) {

    try {
        final RsaJsonWebKey aSigningKey = cachedDataProvider.getASigningKey();
        final JsonWebSignature jws = new JsonWebSignature();
        jws.setPayload(claims.toJson());
        jws.setKeyIdHeaderValue(aSigningKey.getKeyId());
        jws.setKey(aSigningKey.getPrivateKey());
        jws.setAlgorithmHeaderValue(aSigningKey.getAlgorithm());
        jws.sign();
        return jws.getCompactSerialization();
    } catch (final JoseException e) {
        throw new InternalServerErrorException(e);
    }
}
 
开发者ID:trajano,项目名称:app-ms,代码行数:20,代码来源:JcaCryptoOps.java

示例2: toClaimsSet

import javax.ws.rs.InternalServerErrorException; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public JwtClaims toClaimsSet(final String jwt,
    final String audience,
    final HttpsJwks httpsJwks) {

    final JwtConsumerBuilder builder = new JwtConsumerBuilder()
        .setVerificationKeyResolver(new HttpsJwksVerificationKeyResolver(httpsJwks));
    if (audience == null) {
        builder.setSkipDefaultAudienceValidation();
    } else {
        builder.setExpectedAudience(audience);
    }

    final JwtConsumer jwtConsumer = builder
        .build();

    try {
        return jwtConsumer.processToClaims(jwt);
    } catch (final InvalidJwtException e) {
        throw new InternalServerErrorException(e);
    }
}
 
开发者ID:trajano,项目名称:app-ms,代码行数:26,代码来源:JcaCryptoOps.java

示例3: issue

import javax.ws.rs.InternalServerErrorException; //导入依赖的package包/类
@GET
@Path("/issue")
@Produces(MediaType.TEXT_PLAIN)
public Response issue(@Context SecurityContext securityContext) {

	// get Authentication
	Authentication authc = (Authentication) securityContext.getUserPrincipal();

	// configuration
	JwtConfiguration configuration = ResourceUtils.lookupResource(getClass(), JwtConfiguration.class, providers)
			.orElseThrow(() -> new InternalServerErrorException("JWT configuration not available"));

	// build JWT
	String jwt = JwtTokenBuilder.buildJwtToken(configuration, authc, UUID.randomUUID().toString());
	// ok
	return Response.ok(jwt, MediaType.TEXT_PLAIN).build();

}
 
开发者ID:holon-platform,项目名称:holon-examples,代码行数:19,代码来源:JwtIssuerEndpoint.java

示例4: list

import javax.ws.rs.InternalServerErrorException; //导入依赖的package包/类
/** Returns all lectures, in proper order, that given {@link Unit} is part of.*/
public List<Lecture> list(Unit unit){
	
	List<Lecture> lectures = new ArrayList<Lecture>();
	String query = "SELECT * FROM lectures JOIN lecture_units ON (lectures.lecture_id = lecture_units.lecture_id) WHERE lecture_units.unit_id = ? ORDER BY lecture_units.unit_ordinal ASC";
	try (PreparedStatement statement = connProvider.get().prepareStatement(query)){
		statement.setObject(1, unit.getId());
		try(ResultSet resultSet = statement.executeQuery()){
			while(resultSet.next())
				lectures.add(lectureFromResultSet(resultSet));			
		}
	}
	catch(SQLException e){
		throw new InternalServerErrorException("Unable to list lectures for unit " + unit.toString(), e);
	}
	Log.debug("User {} listed lectures that unit {} is part of", userProvider.get().me(), unit.toString());
	return lectures;
}
 
开发者ID:vsite-hr,项目名称:mentor,代码行数:19,代码来源:LectureManager.java

示例5: update

import javax.ws.rs.InternalServerErrorException; //导入依赖的package包/类
/**
 * Updates existing <code>Course</code> in database. Returns <code>Course</code>
 * if successful.
 */
public Course update(Course newValues) {
	
	if (newValues.getTitle() == null || newValues.getDescription() == null || newValues.getAuthor() == null) {
		throw new BadRequestException("Missing Parameter(s) on updating course by user " + userProvider.get().me());
	}
	if(findById(newValues.getId()) == null) {
		throw new NotFoundException("Course " + newValues.toString() + " not found while updating by user " + userProvider.get().me());
	}
	
	String query = "UPDATE courses SET course_title=?, course_description=?, author_id=?, course_keywords=? WHERE course_id=?";
	try (PreparedStatement statement = connProvider.get().prepareStatement(query)) {
		int index = 0;
		statement.setString(++index, newValues.getTitle());
		statement.setString(++index, newValues.getDescription());
		statement.setObject(++index, newValues.getAuthor().getId());
		statement.setArray(++index, connProvider.get().createArrayOf("text", newValues.getKeywords().toArray()));
		statement.setObject(++index, newValues.getId());
		if(statement.executeUpdate() == 1) {
			Log.info("User {} updated course {}", userProvider.get().me(), newValues.toString());
		}
	} catch (SQLException e) {
		throw new InternalServerErrorException("Unable to update course by user " + userProvider.get().me(), e);
	}
	return newValues;
}
 
开发者ID:vsite-hr,项目名称:mentor,代码行数:30,代码来源:CourseManager.java

示例6: delete

import javax.ws.rs.InternalServerErrorException; //导入依赖的package包/类
/**
 * Deletes a <code>Course</code> from database.
 */
public Course delete(Course course) {
	
	if(findById(course.getId()) == null) {
		throw new NotFoundException("Course " + course.toString() + " not found while deleting by user " + userProvider.get().me());
	}
	String query = "BEGIN; DELETE FROM course_lectures WHERE course_id=?; DELETE FROM courses WHERE course_id=?; COMMIT;";
	try (PreparedStatement statement = connProvider.get().prepareStatement(query)) {
		int index = 0;
		statement.setObject(++index, course.getId());
		statement.setObject(++index, course.getId());
		statement.executeUpdate();
		Log.info("User: {} Deleted Course: {}", userProvider.get().me(), course.toString());
		return course;
	} catch (SQLException e) {
		throw new InternalServerErrorException("Unable To Delete Course " + course.toString() + " By User " + userProvider.get().me(), e);
	}
}
 
开发者ID:vsite-hr,项目名称:mentor,代码行数:21,代码来源:CourseManager.java

示例7: fromResultSet

import javax.ws.rs.InternalServerErrorException; //导入依赖的package包/类
/**
 * Parses given ResultSet and extract {@link Course} from it. If ResultSet
 * had <code>NULL</code> in <code>course_id</code> column, <code>null</code>
 * is returned.
 */
public Course fromResultSet(ResultSet resultSet) {

	Course course = new Course();

	try {
		course.setId(UUID.class.cast(resultSet.getObject("course_id")));
		if (resultSet.wasNull())
			return null;
		course.setTitle(resultSet.getString("course_title"));
		course.setDescription(resultSet.getString("course_description"));
		course.setAuthor(userProvider.get().findById(UUID.class.cast(resultSet.getObject("author_id"))));
		course.setKeywords(JdbcUtils.array2List(resultSet.getArray("course_keywords"), String[].class));
	} catch (SQLException e) {
		throw new InternalServerErrorException("Unable to resolve course from result set", e);
	}
	return course;
}
 
开发者ID:vsite-hr,项目名称:mentor,代码行数:23,代码来源:CourseManager.java

示例8: getHeadUnit

import javax.ws.rs.InternalServerErrorException; //导入依赖的package包/类
/** Returns head {@link Unit} for given {@link Course}.*/
public Unit getHeadUnit(Course course) {
	
	Unit headUnit = null;
	String query = "SELECT * FROM units JOIN courses ON (unit_id=course_head_unit_id) AND course_id=?";
	try(PreparedStatement statement = connProvider.get().prepareStatement(query)){
		statement.setObject(1, course.getId());			
		try(ResultSet resultSet = statement.executeQuery()){
			if(resultSet.next())
				headUnit = unitProvider.get().fromResultSet(resultSet);			
		}
	}
	catch(SQLException e){
		throw new InternalServerErrorException("Unable to resolve head unit in course " + course.toString() + " for user " + userProvider.get().me(), e);
	}
	Log.debug("Returned head unit in course {} for user {}", course.toString(), userProvider.get().me());
	return headUnit;
}
 
开发者ID:vsite-hr,项目名称:mentor,代码行数:19,代码来源:CourseManager.java

示例9: testAuthenticationFilterNegative

import javax.ws.rs.InternalServerErrorException; //导入依赖的package包/类
/**
 * Verifies: on 500 server error, broker invalidates session and client receives 500 correctly.
 * 
 * @throws Exception
 */
@Test
public void testAuthenticationFilterNegative() throws Exception {
    log.info("-- Starting {} test --", methodName);

    Map<String, String> authParams = new HashMap<>();
    authParams.put("tlsCertFile", TLS_CLIENT_CERT_FILE_PATH);
    authParams.put("tlsKeyFile", TLS_CLIENT_KEY_FILE_PATH);
    Authentication authTls = new AuthenticationTls();
    authTls.configure(authParams);
    internalSetup(authTls);

    final String cluster = "use";
    final ClusterData clusterData = new ClusterData(brokerUrl.toString(), brokerUrlTls.toString(),
            "pulsar://localhost:" + BROKER_PORT, "pulsar+ssl://localhost:" + BROKER_PORT_TLS);
    // this will cause NPE and it should throw 500
    doReturn(null).when(pulsar).getGlobalZkCache();
    try {
        admin.clusters().createCluster(cluster, clusterData);
    } catch (PulsarAdminException e) {
        Assert.assertTrue(e.getCause() instanceof InternalServerErrorException);
    }

    log.info("-- Exiting {} test --", methodName);
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:30,代码来源:AuthenticatedProducerConsumerTest.java

示例10: endActiveConversations

import javax.ws.rs.InternalServerErrorException; //导入依赖的package包/类
@Override
public Response endActiveConversations(List<ConversationStatus> conversationStatuses) {
    try {
        for (ConversationStatus conversationStatus : conversationStatuses) {
            String conversationId = conversationStatus.getConversationId();
            conversationMemoryStore.setConversationState(
                    conversationId,
                    ConversationState.ENDED);

            ConversationDescriptor conversationDescriptor = conversationDescriptorStore.
                    readDescriptor(conversationId, 0);
            conversationDescriptor.setConversationState(ConversationState.ENDED);
            conversationDescriptorStore.setDescriptor(conversationId, 0, conversationDescriptor);

            log.info(String.format("conversation (%s) has been set to ENDED", conversationId));
        }

        return Response.ok().build();
    } catch (IResourceStore.ResourceStoreException | IResourceStore.ResourceNotFoundException e) {
        log.error(e.getLocalizedMessage(), e);
        throw new InternalServerErrorException();
    }
}
 
开发者ID:labsai,项目名称:EDDI,代码行数:24,代码来源:RestConversationStore.java

示例11: webHook

import javax.ws.rs.InternalServerErrorException; //导入依赖的package包/类
@Override
public Response webHook(final String botId, final String callbackPayload, final String sha1PayloadSignature) {
    SystemRuntime.getRuntime().submitCallable((Callable<Void>) () -> {
        try {
            log.info("webhook called");
            getMessageClient(botId).getReceiveClient().
                    processCallbackPayload(callbackPayload, sha1PayloadSignature);
        } catch (MessengerVerificationException e) {
            log.error(e.getLocalizedMessage(), e);
            throw new InternalServerErrorException("Error when processing callback payload");
        }
        return null;
    }, null);

    return Response.ok().build();
}
 
开发者ID:labsai,项目名称:EDDI,代码行数:17,代码来源:FacebookEndpoint.java

示例12: deployBot

import javax.ws.rs.InternalServerErrorException; //导入依赖的package包/类
@Override
public Response deployBot(final Deployment.Environment environment,
                          final String botId, final Integer version, final Boolean autoDeploy) {
    RuntimeUtilities.checkNotNull(environment, "environment");
    RuntimeUtilities.checkNotNull(botId, "botId");
    RuntimeUtilities.checkNotNull(version, "version");
    RuntimeUtilities.checkNotNull(autoDeploy, "autoDeploy");

    try {
        deploy(environment, botId, version, autoDeploy);
        return Response.accepted().build();
    } catch (Exception e) {
        log.error(e.getLocalizedMessage(), e);
        throw new InternalServerErrorException(e.getLocalizedMessage(), e);
    }
}
 
开发者ID:labsai,项目名称:EDDI,代码行数:17,代码来源:RestBotAdministration.java

示例13: undeployBot

import javax.ws.rs.InternalServerErrorException; //导入依赖的package包/类
@Override
public Response undeployBot(Deployment.Environment environment, String botId, Integer version) {
    RuntimeUtilities.checkNotNull(environment, "environment");
    RuntimeUtilities.checkNotNull(botId, "botId");
    RuntimeUtilities.checkNotNull(version, "version");

    try {
        Long activeConversationCount = conversationMemoryStore.getActiveConversationCount(botId, version);
        if (activeConversationCount > 0) {
            String message = "%s active (thus not ENDED) conversation(s) going on with this bot!";
            message = String.format(message, activeConversationCount);
            return Response.status(Response.Status.CONFLICT).entity(message).type(MediaType.TEXT_PLAIN).build();
        }

        undeploy(environment, botId, version);
        return Response.accepted().build();
    } catch (Exception e) {
        log.error(e.getLocalizedMessage(), e);
        throw new InternalServerErrorException(e.getLocalizedMessage(), e);
    }
}
 
开发者ID:labsai,项目名称:EDDI,代码行数:22,代码来源:RestBotAdministration.java

示例14: startConversation

import javax.ws.rs.InternalServerErrorException; //导入依赖的package包/类
@Override
public Response startConversation(Deployment.Environment environment, String botId) {
    RuntimeUtilities.checkNotNull(environment, "environment");
    RuntimeUtilities.checkNotNull(botId, "botId");

    try {
        IBot latestBot = botFactory.getLatestBot(environment, botId);
        if (latestBot == null) {
            String message = "No instance of bot (botId=%s) deployed in environment (environment=%s)!";
            message = String.format(message, botId, environment);
            return Response.status(Response.Status.NOT_FOUND).type(MediaType.TEXT_PLAIN).entity(message).build();
        }

        IConversation conversation = latestBot.startConversation(null);
        String conversationId = storeConversationMemory(conversation.getConversationMemory(), environment);
        URI createdUri = RestUtilities.createURI(resourceURI, conversationId);
        return Response.created(createdUri).build();
    } catch (ServiceException |
            IResourceStore.ResourceStoreException |
            InstantiationException |
            LifecycleException |
            IllegalAccessException e) {
        log.error(e.getLocalizedMessage(), e);
        throw new InternalServerErrorException(e.getLocalizedMessage(), e);
    }
}
 
开发者ID:labsai,项目名称:EDDI,代码行数:27,代码来源:RestBotEngine.java

示例15: testCreateException

import javax.ws.rs.InternalServerErrorException; //导入依赖的package包/类
@Test
public void testCreateException() {
    assertExceptionType(Response.Status.INTERNAL_SERVER_ERROR, InternalServerErrorException.class);
    assertExceptionType(Response.Status.NOT_FOUND, NotFoundException.class);
    assertExceptionType(Response.Status.FORBIDDEN, ForbiddenException.class);
    assertExceptionType(Response.Status.BAD_REQUEST, BadRequestException.class);
    assertExceptionType(Response.Status.METHOD_NOT_ALLOWED, NotAllowedException.class);
    assertExceptionType(Response.Status.UNAUTHORIZED, NotAuthorizedException.class);
    assertExceptionType(Response.Status.NOT_ACCEPTABLE, NotAcceptableException.class);
    assertExceptionType(Response.Status.UNSUPPORTED_MEDIA_TYPE, NotSupportedException.class);
    assertExceptionType(Response.Status.SERVICE_UNAVAILABLE, ServiceUnavailableException.class);
    assertExceptionType(Response.Status.TEMPORARY_REDIRECT, RedirectionException.class);
    assertExceptionType(Response.Status.LENGTH_REQUIRED, ClientErrorException.class);
    assertExceptionType(Response.Status.BAD_GATEWAY, ServerErrorException.class);
    assertExceptionType(Response.Status.NO_CONTENT, WebApplicationException.class);
}
 
开发者ID:Microbule,项目名称:microbule,代码行数:17,代码来源:AbstractErrorResponseStrategyTest.java


注:本文中的javax.ws.rs.InternalServerErrorException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。