當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。