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


Java SpeechletException类代码示例

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


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

示例1: onRequest

import com.amazon.speech.speechlet.SpeechletException; //导入依赖的package包/类
@Override
public SpeechletResponse onRequest(IntentRequest request, Session session) throws SpeechletException {
    IntentContext<BaseOperation<Namespace, NamespaceList, ?, ?>> ctx = createContext(request.getIntent(), session);
    LOGGER.info("Listing all namespaces.");

    try {
        List<String> namespaces = list(ctx)
                .getItems()
                .stream()
                .map(d -> d.getMetadata().getName()).collect(Collectors.toList());

        if (namespaces.isEmpty()) {
            return newResponse("No namespaces found.");
        } else {
            return newResponse("The available namespaces are: " + join(namespaces, ","));
        }
    } catch (KubernetesClientException e) {
        return newFailureNotice(e.getStatus().getMessage());
    }
}
 
开发者ID:fabric8io,项目名称:kubernetes-alexa,代码行数:21,代码来源:GetNamespaces.java

示例2: onRequest

import com.amazon.speech.speechlet.SpeechletException; //导入依赖的package包/类
@Override
public SpeechletResponse onRequest(IntentRequest request, Session session) throws SpeechletException {
    if (!getKubernetesClient().isAdaptable(OpenShiftClient.class)) {
        return newFailureNotice("Your cluster is not Openshift!");
    }

    IntentContext<BaseOperation<DeploymentConfig, DeploymentConfigList, ?, ?>> ctx = createContext(request.getIntent(), session);
    String namespace = ctx.getVariable(Variable.Namespace, getKubernetesClient().getNamespace());
    LOGGER.info("Listing all deployment configs for namespace:" + namespace);

    try {
        List<String> deployments = list(ctx)
                .getItems()
                .stream()
                .map(d -> d.getMetadata().getName()).collect(Collectors.toList());

        if (deployments.isEmpty()) {
            return newResponse("No deployment configs found.");
        } else {
            return newResponse("The available deployment configs are: " + join(deployments, ","));
        }
    } catch (KubernetesClientException e) {
        return newFailureNotice(e.getStatus().getMessage());
    }
}
 
开发者ID:fabric8io,项目名称:kubernetes-alexa,代码行数:26,代码来源:GetDeploymentConfigs.java

示例3: onRequest

import com.amazon.speech.speechlet.SpeechletException; //导入依赖的package包/类
@Override
public SpeechletResponse onRequest(IntentRequest request, Session session) throws SpeechletException {
    IntentContext<BaseOperation<Pod, PodList, ?, ?>> ctx = createContext(request.getIntent(), session);
    String namespace = ctx.getVariable(Variable.Namespace, getKubernetesClient().getNamespace());
    LOGGER.info("Listing all failing pods for namespace:" + namespace);

    try {
        List<String> pods = list(ctx)
                .getItems()
                .stream()
                .filter(p -> FAILED_PHASE.equalsIgnoreCase(p.getStatus().getPhase()))
                .map(d -> d.getMetadata().getName()).collect(Collectors.toList());

        if (pods.isEmpty()) {
            return newResponse("No failing pods found in namespace " + namespace);
        } else {
            return newResponse("The failing pods in namespace " + namespace + " are: " + join(pods, ","));
        }
    } catch (KubernetesClientException e) {
        return newFailureNotice(e.getStatus().getMessage());
    }
}
 
开发者ID:fabric8io,项目名称:kubernetes-alexa,代码行数:23,代码来源:GetFailingPods.java

示例4: onRequest

import com.amazon.speech.speechlet.SpeechletException; //导入依赖的package包/类
@Override
public SpeechletResponse onRequest(IntentRequest request, Session session) throws SpeechletException {
    IntentContext<BaseOperation<Deployment, DeploymentList, ?, ?>> ctx = createContext(request.getIntent(), session);
    String namespace = ctx.getVariable(Variable.Namespace, getKubernetesClient().getNamespace());
    LOGGER.info("Listing all deployments for namespace:" + namespace);

    try {
        List<String> deployments = list(ctx)
                .getItems()
                .stream()
                .map(d -> d.getMetadata().getName()).collect(Collectors.toList());

        if (deployments.isEmpty()) {
            return newResponse("No deployments found.");
        } else {
            return newResponse("The available deployments are: " + join(deployments, ","));
        }
    } catch (KubernetesClientException e) {
        return newFailureNotice(e.getStatus().getMessage());
    }
}
 
开发者ID:fabric8io,项目名称:kubernetes-alexa,代码行数:22,代码来源:GetDeployments.java

示例5: onRequest

import com.amazon.speech.speechlet.SpeechletException; //导入依赖的package包/类
@Override
public SpeechletResponse onRequest(IntentRequest request, Session session) throws SpeechletException {
    IntentContext<BaseOperation<Pod, PodList, ?, ?>> ctx = createContext(request.getIntent(), session);
    String namespace = ctx.getVariable(Variable.Namespace, getKubernetesClient().getNamespace());
    LOGGER.info("Listing all pods for namespace:" + namespace);

    try {
        List<String> pods = list(ctx)
                .getItems()
                .stream()
                .map(d -> d.getMetadata().getName()).collect(Collectors.toList());

        if (pods.isEmpty()) {
            return newResponse("No pods found in namespace " + namespace);
        } else {
            return newResponse("The available pods in namespace " + namespace + " are: " + join(pods, ","));
        }
    } catch (KubernetesClientException e) {
        return newFailureNotice(e.getStatus().getMessage());
    }
}
 
开发者ID:fabric8io,项目名称:kubernetes-alexa,代码行数:22,代码来源:GetPods.java

示例6: onRequest

import com.amazon.speech.speechlet.SpeechletException; //导入依赖的package包/类
@Override
public SpeechletResponse onRequest(IntentRequest request, Session session) throws SpeechletException {
    IntentContext<BaseOperation<Namespace, NamespaceList, ?, ?>> ctx = createContext(request.getIntent(), session);
    String namespace = ctx.getVariable(Variable.Namespace, null);
    if (Utils.isNullOrEmpty(namespace)) {
        throw new IllegalStateException("Namespace needs to be specified either via intent slots, or via session attributes.");
    }
    try {
        LOGGER.info("Create namespace:" + namespace);

        newOperation().create(new NamespaceBuilder()
                .withNewMetadata()
                .withName(namespace)
                .endMetadata()
                .build());


        return newResponse("Successfully created namespace " + namespace);
    } catch (KubernetesClientException e) {
        return newFailureNotice(e.getStatus().getMessage());
    }
}
 
开发者ID:fabric8io,项目名称:kubernetes-alexa,代码行数:23,代码来源:CreateNamespace.java

示例7: onRequest

import com.amazon.speech.speechlet.SpeechletException; //导入依赖的package包/类
@Override
public SpeechletResponse onRequest(IntentRequest request, Session session) throws SpeechletException {
    IntentContext<BaseOperation<Service, ServiceList, ?, ?>> ctx = createContext(request.getIntent(), session);
    String namespace = ctx.getVariable(Variable.Namespace, getKubernetesClient().getNamespace());
    LOGGER.info("Listing all services for namespace:" + namespace);

    try {
        List<String> services = list(ctx)
                .getItems()
                .stream()
                .map(d -> d.getMetadata().getName()).collect(Collectors.toList());

        if (services.isEmpty()) {
            return newResponse("No services found in namespace " + namespace);
        } else {
            return newResponse("The available services in namespace " + namespace + " are: " + join(services, ","));
        }
    } catch (KubernetesClientException e) {
        return newFailureNotice(e.getStatus().getMessage());
    }
}
 
开发者ID:fabric8io,项目名称:kubernetes-alexa,代码行数:22,代码来源:GetServices.java

示例8: onRequest

import com.amazon.speech.speechlet.SpeechletException; //导入依赖的package包/类
@Override
public SpeechletResponse onRequest(IntentRequest request, Session session) throws SpeechletException {
    if (!getKubernetesClient().isAdaptable(OpenShiftClient.class)) {
        return newFailureNotice("Your cluster is not Openshift!");
    }

    IntentContext<BaseOperation<Project, ProjectList, ?, ?>> ctx = createContext(request.getIntent(), session);
    LOGGER.info("Listing all projects.");

    try {
        List<String> projects = list(ctx)
                .getItems()
                .stream()
                .map(d -> d.getMetadata().getName()).collect(Collectors.toList());

        if (projects.isEmpty()) {
            return newResponse("No projects found.");
        } else {
            return newResponse("The available projects are: " + join(projects, ","));
        }
    } catch (KubernetesClientException e) {
        return newFailureNotice(e.getStatus().getMessage());
    }
}
 
开发者ID:fabric8io,项目名称:kubernetes-alexa,代码行数:25,代码来源:GetProjects.java

示例9: onIntent

import com.amazon.speech.speechlet.SpeechletException; //导入依赖的package包/类
public SpeechletResponse onIntent(IntentRequest request, Session session) throws SpeechletException {
    LOGGER.info("onRequest requestId={}, sessionId={}", request.getRequestId(), session.getSessionId());
    // Get intent from the request object.
    Intent intent = request.getIntent();
    String intentName = (intent != null) ? intent.getName() : null;

    RequestHandlerFactory factory = GetRequestHandlerFactory.FUNCTION.apply(intentName);

    if (factory != null) {
        return factory.create(context).onRequest(request, session);
    } else {
        return new SpeechletResponseBuilder()
                .withNewPlainTextOutputSpeechOutputSpeech()
                    .withText("I don't know how to do that.")
                .endPlainTextOutputSpeechOutputSpeech()
                .build();
    }
}
 
开发者ID:fabric8io,项目名称:kubernetes-alexa,代码行数:19,代码来源:RequestDispatcher.java

示例10: onSessionStarted

import com.amazon.speech.speechlet.SpeechletException; //导入依赖的package包/类
@Override
public void onSessionStarted(final SessionStartedRequest request, final Session session)
        throws SpeechletException {
    log.info("onSessionStarted requestId={}, sessionId={}", request.getRequestId(),
            session.getSessionId());
    //All session initialization goes here - Beginning of lifecycle
    
    
    //TODO EDIT HERE: Add Conversation objects to registry
    supportedConversations.add(new KnockKnockConversation());
    
    
    //Populate a map of supported intents to conversations for later dispatch
    for(Conversation convo : supportedConversations) {
    	for(String intentName : convo.getSupportedIntentNames()) {
    		supportedIntentsByConversation.put(intentName, convo);
    	}
    }
}
 
开发者ID:jneong,项目名称:CS370_Echo_Demo,代码行数:20,代码来源:TemplateBaseSkillSpeechlet.java

示例11: onIntent

import com.amazon.speech.speechlet.SpeechletException; //导入依赖的package包/类
@Override
public SpeechletResponse onIntent(final IntentRequest request, final Session session)
        throws SpeechletException {
    log.info("onIntent requestId={}, sessionId={}", request.getRequestId(),
            session.getSessionId());

    SpeechletResponse response = null;
    Intent intent = request.getIntent();
    String intentName = (intent != null) ? intent.getName() : null;
    
    //Check for convo handling
    Conversation convo = getConvoForIntent(intentName);
    if(convo != null) {
    	response = convo.respondToIntentRequest(request, session);
    }
    else {
        throw new SpeechletException("Invalid Intent");
    }
    
    return response;
}
 
开发者ID:jneong,项目名称:CS370_Echo_Demo,代码行数:22,代码来源:TemplateBaseSkillSpeechlet.java

示例12: onIntent

import com.amazon.speech.speechlet.SpeechletException; //导入依赖的package包/类
@Override
public SpeechletResponse onIntent(IntentRequest request, Session session) throws SpeechletException {
	Intent intent = request.getIntent();
	
	if (Constants.INTENT_QUERY_TRAIN_STATUS.equals(intent.getName())) {
		return responseShortStatus(intent, session);
	} else if ("AMAZON.YesIntent".equals(intent.getName())) {
		return responseYes(intent, session);
	} else if ("AMAZON.NoIntent".equals(intent.getName())) {
		return responseNo(intent, session);
	} else if ("AMAZON.HelpIntent".equals(intent.getName())) {
		return help(intent, session);
	} else if ("AMAZON.CancelIntent".equals(intent.getName()) || 
		"AMAZON.StopIntent".equals(intent.getName())) {
		return responseText("See you!");
	} else {
		return responseText("Sorry, I didn't get that. Please try again now. Like: What is the status of seven?", false);
	}
}
 
开发者ID:speedyllama,项目名称:nyctransit,代码行数:20,代码来源:MTAStatusSpeechlet.java

示例13: handleResponseEvent

import com.amazon.speech.speechlet.SpeechletException; //导入依赖的package包/类
/**
 * Handle an event that requires an response to the user.
 *
 * @param name Name of the event.
 * @param request The request.
 * @param session The session.
 * @param <T> The request type
 * @return A SpeechletResponse to return
 * @throws SpeechletException Thrown when stuff goes bad. Real bad.
 */
private <T extends SpeechletRequest> SpeechletResponse handleResponseEvent(String name, T request, Session session) throws SpeechletException {
    try {
        LOGGER.fine("Doing response event " + name);
        List<InvokableMethod> matches = methods.get(name);
        if (matches == null || matches.isEmpty()) {
            LOGGER.log(Level.SEVERE, "No handler available for '" + name + "' on path " + ((Skill) data.getType().getAnnotation(Skill.class)).path());
            throw new SpeechletException("No handler available for '" + name + "'");
        }
        if (matches.size() == 1) {
            InvokableMethod method = matches.iterator().next();
            LOGGER.fine("Found single match method " + method.getNativeMethod().toGenericString());
            List<ParameterValue> values = synthesizeValues(data, method, request, session);
            return invokeResponseEvent(method, values, request, session);
        } else {
            MethodEvaluation evaluation = findMethodEvaluation(request, session, matches);
            LOGGER.fine("Decided to call " + evaluation.method.getNativeMethod().toGenericString());
            return invokeResponseEvent(evaluation.method, evaluation.values, request, session);
        }
    } catch(RuntimeException e){
        LOGGER.log(Level.SEVERE, "Exception handling response event ", e);
        throw e;
    }
}
 
开发者ID:kebernet,项目名称:skillz,代码行数:34,代码来源:DynamicSpeechlet.java

示例14: onUnknownIntent

import com.amazon.speech.speechlet.SpeechletException; //导入依赖的package包/类
@Test(expected = SpeechletException.class)
public void onUnknownIntent() throws Exception {
    IntrospectionData data = registry.getDataForPath("/invoked").orElseThrow(RuntimeException::new);
    final ArrayListMultimap<String, InvokableMethod> methods = ArrayListMultimap.create();
    data.getMethods().forEach(m->methods.put(m.getName(), m));
    InvokedTestSkill skill = new InvokedTestSkill();
    DynamicSpeechlet speechlet = new DynamicSpeechlet(methods, data, new FormatterMappings(),
            registry, skill, new DefaultTypeFactory());

    com.amazon.speech.slu.Intent intent = com.amazon.speech.slu.Intent.builder()
            .withName("missing")
            .build();
    IntentRequest request = IntentRequest.builder()
            .withRequestId("id")
            .withTimestamp(new Date())
            .withIntent(intent)
            .build();

    speechlet.onIntent(request, session);
}
 
开发者ID:kebernet,项目名称:skillz,代码行数:21,代码来源:SimpleSpeechletInvocationTests.java

示例15: onIntent

import com.amazon.speech.speechlet.SpeechletException; //导入依赖的package包/类
@Override
public SpeechletResponse onIntent(final IntentRequest request, final Session session)
		throws SpeechletException {
	log.info("onIntent requestId={}, sessionId={}", request.getRequestId(),
			session.getSessionId());

	Intent intent = request.getIntent();
	String intentName = (intent != null) ? intent.getName() : null;

	if ("PlayRecordingIntent".equals(intentName)) {
		return getPlayRecordingResponse(intent);
	} else if ("FastForwardIntent".equals(intentName)) {
		return getFastForwardResponse(intent);
	} else if ("RewindIntent".equals(intentName)) {
		return getRewindResponse(intent);
	} else if ("PauseIntent".equals(intentName)) {
		return getPauseResponse();
	} else if ("StopIntent".equals(intentName)) {
		return getStopResponse();
	} else if ("AMAZON.HelpIntent".equals(intentName)) {
		return getHelpResponse();
	} else {
		throw new SpeechletException("Invalid Intent");
	}
}
 
开发者ID:bellissimo,项目名称:AlexaSky,代码行数:26,代码来源:SkySpeechlet.java


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