private String getOutputFilePath(ServiceNode serviceNode) { String cUnit = serviceNode.getPosition().getSource().getCompilationUnitName(); String dir = cUnit.substring(0, cUnit.lastIndexOf(File.separator) + 1); String file = serviceNode.getName().getValue().toLowerCase(Locale.ENGLISH) + "_client.bal"; return dir + file; }
@SuppressWarnings("unchecked") @Override public void process(ServiceNode serviceNode, List<AnnotationAttachmentNode> annotations) { if (annotations.size() > 1) { int count = 0; for (AnnotationAttachmentNode annotation : annotations) { if (annotation.getAnnotationName().getValue().equals(WEBSOCKET_ANNOTATION_CONFIGURATION)) { count++; } } if (count > 1) { dlog.logDiagnostic(Diagnostic.Kind.ERROR, serviceNode.getPosition(), "There cannot be more than one " + WEBSOCKET_SERVICE + " annotations"); } } List<BLangFunction> resources = (List<BLangFunction>) serviceNode.getResources(); resources.forEach( res -> WebSocketResourceValidator.validate(res, dlog, isResourceReturnsErrorOrNil(res), false)); } }
@Override public void process(ServiceNode serviceNode, List<AnnotationAttachmentNode> annotations) { for (AnnotationAttachmentNode attachmentNode : annotations) { String annotationKey = attachmentNode.getAnnotationName().getValue(); try { AnnotationProcessorFactory.getAnnotationProcessorInstance(annotationKey).processAnnotation (serviceNode, attachmentNode); } catch (KubernetesPluginException e) { dlog.logDiagnostic(Diagnostic.Kind.ERROR, serviceNode.getPosition(), e.getMessage()); } } }
dlog.logDiagnostic(Diagnostic.Kind.ERROR, serviceNode.getPosition(), "Invalid multiple configurations for compression"); return; MimeUtil.validateContentType(contentType); } catch (MimeTypeParseException e) { dlog.logDiagnostic(Diagnostic.Kind.ERROR, serviceNode.getPosition(), "Invalid Content-Type value for compression: '" + contentType + "'"); return;
dlog.logDiagnostic(Diagnostic.Kind.ERROR, service.getPosition(), e.getMessage());
dlog.logDiagnostic(Diagnostic.Kind.ERROR, serviceNode.getPosition(), "There cannot be more than one service annotations"); return false;
if (serviceConfig.getRpcEndpoint() != null && (serviceConfig.isClientStreaming())) { if (resources.size() != 4) { dlog.logDiagnostic(Diagnostic.Kind.ERROR, serviceNode.getPosition(), "There should be four resources defined in client/bidirectional streaming services"); return false; return true; } else { dlog.logDiagnostic(Diagnostic.Kind.ERROR, serviceNode.getPosition(), "One or more resources(onOpen/onMessage/onError/onComplete) is not implemented in " + "client/bidirectional streaming service");
dlog.logDiagnostic(Diagnostic.Kind.ERROR, serviceNode.getPosition(), e.getMessage());
static File generateProtoDefinition(ServiceNode serviceNode) throws GrpcServerException { // Protobuf file definition builder. String packageName = serviceNode.getPosition().getSource().getPackageName(); File.Builder fileBuilder; if (!NO_PACKAGE_PATH.equals(packageName)) { fileBuilder = File.newBuilder(serviceNode.getName() + ServiceProtoConstants.PROTO_FILE_EXTENSION) .setSyntax(ServiceProtoConstants.PROTOCOL_SYNTAX).setPackage(serviceNode.getPosition().getSource() .getPackageName()); } else { fileBuilder = File.newBuilder(serviceNode.getName() + ServiceProtoConstants.PROTO_FILE_EXTENSION) .setSyntax(ServiceProtoConstants.PROTOCOL_SYNTAX); } ServiceConfiguration serviceConfig = getServiceConfiguration(serviceNode); Service serviceDefinition; if (serviceConfig.getRpcEndpoint() != null && (serviceConfig.isClientStreaming())) { serviceDefinition = getStreamingServiceDefinition(serviceNode, serviceConfig, fileBuilder); } else { serviceDefinition = getUnaryServiceDefinition(serviceNode, fileBuilder); } fileBuilder.setService(serviceDefinition); return fileBuilder.build(); }
@SuppressWarnings("unchecked") @Override public void process(ServiceNode serviceNode, List<AnnotationAttachmentNode> annotations) { int serviceConfigCount = 0; for (AnnotationAttachmentNode annotation : annotations) { if (annotation.getAnnotationName().getValue().equals(ANN_NAME_HTTP_SERVICE_CONFIG)) { handleServiceConfigAnnotation(serviceNode, (BLangAnnotationAttachment) annotation); serviceConfigCount++; } } if (serviceConfigCount > 1) { dlog.logDiagnostic(Diagnostic.Kind.ERROR, serviceNode.getPosition(), "multiple service configuration annotations found in service : " + serviceNode.getName().getValue()); } // final UserDefinedTypeNode serviceType = serviceNode.getServiceTypeStruct(); // if (serviceType != null && HttpConstants.HTTP_SERVICE_TYPE.equals(serviceType.getTypeName() // .getValue())) { List<BLangFunction> resources = (List<BLangFunction>) serviceNode.getResources(); resources.forEach(res -> { ResourceSignatureValidator.validateAnnotation(res, dlog); ResourceSignatureValidator.validate(res.getParameters(), dlog, res.pos); ResourceSignatureValidator.validateResourceReturnType(isResourceReturnsErrorOrNil(res), dlog, res.pos); }); // } // get value from endpoint. // ((BLangSimpleVarRef) serviceNode.getBoundEndpoints().get(0)).varSymbol.getType().tsymbol.name.value }