• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java InvalidParameterException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: testActions

import com.amazonaws.services.sns.model.InvalidParameterException; //导入依赖的package包/类
@Test
@Ignore
public void testActions() {

    // setAttributes
    try {
        subscription.setAttributes("RawMessageDelivery", "false");
        refreshSubscription();
        Assert.assertEquals("false", subscription.getAttributes().get("RawMessageDelivery"));

    } catch (InvalidParameterException ipe) {
        Assert.assertTrue(ipe.getMessage().contains(
                "delivery protocol [application] does not support raw message delivery."));
    }

}
 
开发者ID:awslabs,项目名称:aws-sdk-java-resources,代码行数:17,代码来源:SubscriptionIntegrationTest.java


示例2: subscribe

import com.amazonaws.services.sns.model.InvalidParameterException; //导入依赖的package包/类
@Override
public SubscribeResult subscribe(SubscribeRequest subscribeRequest) throws AmazonClientException {
    final String protocol = subscribeRequest.getProtocol().toLowerCase();
    if (!protocol.equals("sqs")) {
        throw new InvalidParameterException("endpoint protocol " + protocol + " not supported");
    }
    final String topicArn = subscribeRequest.getTopicArn();
    if (!_subscriptionsForTopic.containsKey(topicArn)) {
        throw new InvalidParameterException("no such topic " + topicArn);
    }
    String subscriptionArn = topicArn + ":" + RandomStringUtils.randomNumeric(7);
    if (!_subscriptionsByArn.containsKey(subscriptionArn)) {
        _subscriptionsByArn.put(subscriptionArn, new Subscription().
                withTopicArn(topicArn).
                withProtocol(protocol).
                withSubscriptionArn(subscriptionArn).
                withEndpoint(subscribeRequest.getEndpoint()));
        _subscriptionsForTopic.get(topicArn).add(subscriptionArn);
    }

    return new SubscribeResult().withSubscriptionArn(subscriptionArn);
}
 
开发者ID:bazaarvoice,项目名称:awslocal,代码行数:23,代码来源:InMemorySNS.java


示例3: testAddPermission_withInvalidParameterMock_shouldThrowException

import com.amazonaws.services.sns.model.InvalidParameterException; //导入依赖的package包/类
@Test(expected = AmazonSNSException.class)
public void testAddPermission_withInvalidParameterMock_shouldThrowException() {
  mockSns(new MockParameters(InvalidParameterException.class));

  AddPermissionRequest addPermissionRequest = new AddPermissionRequest()
      .withActionNames(ImmutableList.of("READ", "WRITE"))
      .withAWSAccountIds(ImmutableList.of("1", "2")).withLabel("unsecure-topic").withTopicArn(
          "arn:aws:sns:us-east-1:123456789012:my_corporate_topic:02034b43-fefa-4e07-a5eb-3be56f8c54ce");
  
  sns.addPermission(addPermissionRequest);
}
 
开发者ID:daflockinger,项目名称:unitstack,代码行数:12,代码来源:MockSnsTest.java


示例4: createTopicWithInvalidName

import com.amazonaws.services.sns.model.InvalidParameterException; //导入依赖的package包/类
@Test
public void createTopicWithInvalidName() {
    assertSNSThrownBy(() -> sns.createTopic("test topic"))
            .isInstanceOf(InvalidParameterException.class)
            .hasErrorCode("InvalidParameter")
            .hasErrorMessage("Invalid parameter: test topic")
            .hasStatusCode(400);
}
 
开发者ID:OpenG,项目名称:aws-java-sdk,代码行数:9,代码来源:AmazonSNSFakeCreateTopicTest.java


示例5: verifyPlatformApplication

import com.amazonaws.services.sns.model.InvalidParameterException; //导入依赖的package包/类
public void verifyPlatformApplication(AmazonSNS client) {
    try {
        if (!BatchCreatePlatformEndpointSample.listOfRegions
                .contains(this.region = this.applicationArn.split(":")[3])) {
            System.err.println("[ERROR] The region " + region
                    + " is invalid");
            System.exit(BatchCreatePlatformEndpointSample.MALFORMED_PROPERTIES_ERROR_CODE);
        }
    } catch (ArrayIndexOutOfBoundsException aioobe) {
        System.err.println("[ERROR] The ARN " + this.applicationArn
                + " is malformed");
        System.exit(BatchCreatePlatformEndpointSample.MALFORMED_PROPERTIES_ERROR_CODE);
    }
    client.setEndpoint("https://sns." + this.region + ".amazonaws.com/");
    try {
        GetPlatformApplicationAttributesRequest applicationAttributesRequest = new GetPlatformApplicationAttributesRequest();
        applicationAttributesRequest
                .setPlatformApplicationArn(this.applicationArn);
        @SuppressWarnings("unused")
        GetPlatformApplicationAttributesResult getAttributesResult = client
                .getPlatformApplicationAttributes(applicationAttributesRequest);
    } catch (NotFoundException nfe) {
        System.err
                .println("[ERROR: APP NOT FOUND] The application ARN provided: "
                        + this.applicationArn
                        + " does not correspond to any existing platform applications. "
                        + nfe.getMessage());
        System.exit(BatchCreatePlatformEndpointSample.NOT_FOUND_ERROR_CODE);
    } catch (InvalidParameterException ipe) {
        System.err
                .println("[ERROR: APP ARN INVALID] The application ARN provided: "
                        + this.applicationArn
                        + " is malformed"
                        + ipe.getMessage());
        System.exit(BatchCreatePlatformEndpointSample.NOT_FOUND_ERROR_CODE);
    }
}
 
开发者ID:tonchidot,项目名称:aws-java-sns-mobile-push-sample,代码行数:38,代码来源:CreateEndpointJob.java


示例6: publishNotification

import com.amazonaws.services.sns.model.InvalidParameterException; //导入依赖的package包/类
private void publishNotification(
    final String arn,
    final SNSMessage<?> message,
    final QualifiedName name,
    final String errorMessage,
    final String counterKey,
    final boolean retryOnLongMessage
) {
    this.notificationMetric.recordTime(message, Metrics.TimerNotificationsBeforePublishDelay.getMetricName());
    try {
        final AsyncHandler<PublishRequest, PublishResult> handler =
            new AsyncHandler<PublishRequest, PublishResult>() {
                @Override
                public void onError(final Exception exception) {
                    if (retryOnLongMessage && (exception instanceof InvalidParameterException
                        || exception instanceof InvalidParameterValueException)) {
                        log.error("SNS Publish message exceeded the size threshold", exception);
                        notificationMetric.counterIncrement(
                            Metrics.CounterSNSNotificationPublishMessageSizeExceeded.getMetricName());
                        final SNSMessage<Void> voidMessage = new SNSMessage<>(message.getId(),
                            message.getTimestamp(), message.getRequestId(), message.getType(), message.getName(),
                            null);
                        publishNotification(arn, voidMessage, name, errorMessage, counterKey, false);
                    } else {
                        notificationMetric.handleException(name, errorMessage, counterKey, message, exception);
                    }
                }

                @Override
                public void onSuccess(final PublishRequest request, final PublishResult publishResult) {
                    log.info("Successfully published message to topic {} with id {}",
                        arn, publishResult.getMessageId());
                    log.debug("Successfully published message {} to topic {} with id {}",
                        message, arn, publishResult.getMessageId());
                    notificationMetric.counterIncrement(counterKey);
                    notificationMetric.recordTime(message,
                        Metrics.TimerNotificationsPublishDelay.getMetricName());
                }
            };
        client.publishAsync(arn, mapper.writeValueAsString(message), handler);
    } catch (final Exception e) {
        notificationMetric.handleException(name, errorMessage, counterKey, message, e);
    }
}
 
开发者ID:Netflix,项目名称:metacat,代码行数:45,代码来源:SNSNotificationServiceImpl.java


示例7: newInvalidParameterException

import com.amazonaws.services.sns.model.InvalidParameterException; //导入依赖的package包/类
static SNSExceptionBuilder newInvalidParameterException(String reason) {
    return new SNSExceptionBuilder(
            new InvalidParameterException("Invalid parameter: " + reason),
            "InvalidParameter",
            400);
}
 
开发者ID:OpenG,项目名称:aws-java-sdk,代码行数:7,代码来源:SNSExceptionBuilder.java


示例8: assertSNSParamThrownBy

import com.amazonaws.services.sns.model.InvalidParameterException; //导入依赖的package包/类
private static AWSThrowableAssert assertSNSParamThrownBy(ThrowableAssert.ThrowingCallable shouldRaiseThrowable) {
    return assertSNSThrownBy(shouldRaiseThrowable)
            .isInstanceOf(InvalidParameterException.class)
            .hasErrorCode("InvalidParameter")
            .hasStatusCode(400);
}
 
开发者ID:OpenG,项目名称:aws-java-sdk,代码行数:7,代码来源:AmazonSNSFakePublishTest.java


示例9: createApplicationEndpoint

import com.amazonaws.services.sns.model.InvalidParameterException; //导入依赖的package包/类
String createApplicationEndpoint(String backendId, String appId, PushService service, String token) {

		Optional<PlatformApplication> application = getApplication(appId, service);

		if (!application.isPresent())
			throw Exceptions.illegalArgument(//
					"push service [%s] of mobile application [%s] not registered in AWS", //
					appId, service);

		String applicationArn = application.get().getPlatformApplicationArn();

		String endpointArn = null;

		try {
			endpointArn = getSnsClient()
					.createPlatformEndpoint(//
							new CreatePlatformEndpointRequest()//
									.withPlatformApplicationArn(applicationArn)//
									.withToken(token))//
					.getEndpointArn();

		} catch (InvalidParameterException e) {
			String message = e.getErrorMessage();
			Utils.info("Exception message: %s", message);
			Pattern p = Pattern.compile(".*Endpoint (arn:aws:sns[^ ]+) already exists " + "with the same token.*");
			Matcher m = p.matcher(message);
			if (m.matches()) {
				// The platform endpoint already exists for this token, but with
				// additional custom data that
				// createEndpoint doesn't want to overwrite. Just use the
				// existing platform endpoint.
				endpointArn = m.group(1);
			} else {
				throw e;
			}
		}

		if (endpointArn == null)
			throw new RuntimeException("failed to create device notification endpoint: try again later");

		boolean updateNeeded = false;

		try {
			GetEndpointAttributesResult endpointAttributes = getSnsClient()
					.getEndpointAttributes(new GetEndpointAttributesRequest().withEndpointArn(endpointArn));

			updateNeeded = !endpointAttributes.getAttributes().get("Token").equals(token)
					|| !endpointAttributes.getAttributes().get("Enabled").equalsIgnoreCase("true");

		} catch (NotFoundException nfe) {
			// We had a stored ARN, but the platform endpoint associated with it
			// disappeared. Recreate it.
			endpointArn = null;
		}

		if (endpointArn == null)
			throw new RuntimeException("failed to create device notification endpoint: try again later");

		if (updateNeeded) {
			// The platform endpoint is out of sync with the current data;
			// update the token and enable it.
			Map<String, String> attribs = new HashMap<>();
			attribs.put("Token", token);
			attribs.put("Enabled", "true");
			getSnsClient().setEndpointAttributes(//
					new SetEndpointAttributesRequest()//
							.withEndpointArn(endpointArn)//
							.withAttributes(attribs));
		}

		return endpointArn;
	}
 
开发者ID:spacedog-io,项目名称:spacedog-server,代码行数:73,代码来源:PushResource.java


示例10: createApplicationEndpoint

import com.amazonaws.services.sns.model.InvalidParameterException; //导入依赖的package包/类
String createApplicationEndpoint(String backendId, String appId, PushServices service, String token) {

		PlatformApplication application = getApplication(backendId, appId, service)//
				.orElseThrow(//
						() -> Exceptions.illegalArgument(//
								"push service [%s] not registered for mobile	application [%s]", //
								appId, service));

		String endpointArn = null;
		String applicationArn = application.getPlatformApplicationArn();

		try {
			endpointArn = getSnsClient()
					.createPlatformEndpoint(//
							new CreatePlatformEndpointRequest()//
									.withPlatformApplicationArn(applicationArn)//
									.withToken(token))//
					.getEndpointArn();

		} catch (InvalidParameterException e) {
			String message = e.getErrorMessage();
			Utils.info("Exception message: %s", message);
			Pattern p = Pattern.compile(".*Endpoint (arn:aws:sns[^ ]+) already exists " + "with the same token.*");
			Matcher m = p.matcher(message);
			if (m.matches()) {
				// The platform endpoint already exists for this token, but with
				// additional custom data that
				// createEndpoint doesn't want to overwrite. Just use the
				// existing platform endpoint.
				endpointArn = m.group(1);
			} else {
				throw e;
			}
		}

		if (endpointArn == null)
			throw new RuntimeException("failed to create device notification endpoint: try again later");

		boolean updateNeeded = false;

		try {
			GetEndpointAttributesResult endpointAttributes = getSnsClient()
					.getEndpointAttributes(new GetEndpointAttributesRequest().withEndpointArn(endpointArn));

			updateNeeded = !endpointAttributes.getAttributes().get("Token").equals(token)
					|| !endpointAttributes.getAttributes().get("Enabled").equalsIgnoreCase("true");

		} catch (NotFoundException nfe) {
			// We had a stored ARN, but the platform endpoint associated with it
			// disappeared. Recreate it.
			endpointArn = null;
		}

		if (endpointArn == null)
			throw new RuntimeException("failed to create device notification endpoint: try again later");

		if (updateNeeded) {
			// The platform endpoint is out of sync with the current data;
			// update the token and enable it.
			Map<String, String> attribs = new HashMap<String, String>();
			attribs.put("Token", token);
			attribs.put("Enabled", "true");
			getSnsClient().setEndpointAttributes(//
					new SetEndpointAttributesRequest()//
							.withEndpointArn(endpointArn)//
							.withAttributes(attribs));
		}

		return endpointArn;
	}
 
开发者ID:spacedog-io,项目名称:spacedog-server,代码行数:71,代码来源:PushResource2.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SwipeResultAction类代码示例发布时间:2022-05-23
下一篇:
Java DeformedComposedWordToImage类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap