Java Code Examples for org.springframework.stereotype.Service

The following examples show how to use org.springframework.stereotype.Service. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: AthenaServing   Source File: ServiceVersionImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Response<ServiceVersionDetailResponseBody> add(AddServiceVersionRequestBody body) {
	// 通过id查询服务
	String serviceId = body.getServiceId();
	com.iflytek.ccr.polaris.cynosure.domain.Service service = this.serviceConditionimpl.findById(serviceId);
	if (null == service) {
		// 不存在该服务
		return new Response<>(SystemErrCode.ERRCODE_SERVICE_NOT_EXISTS, SystemErrCode.ERRMSG_SERVICE_NOT_EXISTS);
	}

	// 根据版本和服务id查询服务版本
	String version = body.getVersion();
	ServiceVersion serviceVersion = this.serviceVersionConditionImpl.find(version, serviceId);
	if (null != serviceVersion) {
		return new Response<>(SystemErrCode.ERRCODE_SERVICE_VERSION_EXISTS, SystemErrCode.ERRMSG_SERVICE_VERSION_EXISTS);
	}

	// 创建版本
	ServiceVersion newServiceVersion = this.serviceVersionConditionImpl.add(body);

	// 创建版本结果
	ServiceVersionDetailResponseBody result = this.createServiceVersionResult(newServiceVersion);
	return new Response<>(result);
}
 
Example 2
Source Project: AthenaServing   Source File: ClusterServiceImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Response<String> delete(IdRequestBody body) {
    //通过id查询服务列表
    String id = body.getId();
    Cluster cluster = this.clusterConditionImpl.findServiceListById(id);
    if (null == cluster) {
        //不存在该集群
        return new Response<>(SystemErrCode.ERRCODE_CLUSTER_NOT_EXISTS, SystemErrCode.ERRMSG_CLUSTER_NOT_EXISTS);
    }

    List<com.iflytek.ccr.polaris.cynosure.domain.Service> serviceList = cluster.getServiceList();
    if (null != serviceList && !serviceList.isEmpty()) {
        //该用户已创建服务
        return new Response<>(SystemErrCode.ERRCODE_SERVICE_CREATE, SystemErrCode.ERRMSG_SERVICE_CREATE);
    }

    //通过id删除集群
    this.clusterConditionImpl.deleteById(id);
    return new Response<>(null);
}
 
Example 3
Source Project: AthenaServing   Source File: ServiceApiVersionImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Response<ServiceApiVersionDetailResponseBody> add(AddServiceApiVersionRequestBody body) {
    //通过id查询服务
    String serviceId = body.getServiceId();
    com.iflytek.ccr.polaris.cynosure.domain.Service service = this.serviceConditionimpl.findById(serviceId);
    if (null == service) {
        //不存在该服务
        return new Response<>(SystemErrCode.ERRCODE_SERVICE_NOT_EXISTS, SystemErrCode.ERRMSG_SERVICE_NOT_EXISTS);
    }

    //根据版本和服务id查询服务版本
    String apiVersion = body.getApiVersion();
    ServiceApiVersion serviceApiVersion = this.serviceApiVersionConditionImpl.find(apiVersion, serviceId);
    if (null != serviceApiVersion) {
        return new Response<>(SystemErrCode.ERRCODE_SERVICE_VERSION_EXISTS, SystemErrCode.ERRMSG_SERVICE_VERSION_EXISTS);
    }

    //创建版本
    ServiceApiVersion newServiceApiVersion = this.serviceApiVersionConditionImpl.add(body);

    //创建版本结果
    ServiceApiVersionDetailResponseBody result = this.createServiceApiVersionResult(newServiceApiVersion);
    return new Response<>(result);
}
 
Example 4
Source Project: AthenaServing   Source File: ServiceImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Response<ServiceDetailResponseBody> add(AddServiceRequestBody body) {
    //根据id查询集群信息
    String clusterId = body.getClusterId();
    Cluster cluster = this.clusterConditionImpl.findById(clusterId);
    if (null == cluster) {
        return new Response<>(SystemErrCode.ERRCODE_CLUSTER_NOT_EXISTS, SystemErrCode.ERRMSG_CLUSTER_NOT_EXISTS);
    }

    //根据服务名和集群id查询服务
    String name = body.getName();
    com.iflytek.ccr.polaris.cynosure.domain.Service service = this.serviceConditionImpl.find(name, clusterId);
    if (null != service) {
        //已存在该服务
        return new Response<>(SystemErrCode.ERRCODE_SERVICE_EXISTS, SystemErrCode.ERRMSG_SERVICE_EXISTS);
    }

    //创建服务
    com.iflytek.ccr.polaris.cynosure.domain.Service newService = this.serviceConditionImpl.add(body);

    //创建服务结果
    ServiceDetailResponseBody result = this.createServiceResult(newService);
    return new Response<>(result);
}
 
Example 5
Source Project: AthenaServing   Source File: ServiceImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Response<String> delete(IdRequestBody body) {
    //通过id查询版本列表
    String id = body.getId();
    com.iflytek.ccr.polaris.cynosure.domain.Service service = this.serviceConditionImpl.findServiceVersionListById(id);
    if (null == service) {
        //不存在该服务
        return new Response<>(SystemErrCode.ERRCODE_SERVICE_NOT_EXISTS, SystemErrCode.ERRMSG_SERVICE_NOT_EXISTS);
    }

    List<ServiceVersion> serviceVersionList = service.getServiceVersionList();
    if (null != serviceVersionList && !serviceVersionList.isEmpty()) {
        //该用户已经创建版本
        return new Response<>(SystemErrCode.ERRCODE_SERVICE_VERSION_CREATE, SystemErrCode.ERRMSG_SERVICE_VERSION_CREATE);
    }

    //根据id删除服务
    this.serviceConditionImpl.deleteById(id);
    return new Response<>(null);
}
 
Example 6
Source Project: AthenaServing   Source File: ServiceConditionImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public com.iflytek.ccr.polaris.cynosure.domain.Service add(AddServiceRequestBody body) {
    String name = body.getName();
    String desc = body.getDesc();
    String userId = this.getUserId();
    String clusterId = body.getClusterId();

    //新增
    Date now = new Date();
    com.iflytek.ccr.polaris.cynosure.domain.Service service = new com.iflytek.ccr.polaris.cynosure.domain.Service();
    service.setId(SnowflakeIdWorker.getId());
    service.setName(name);
    service.setDescription(desc);
    service.setUserId(userId);
    service.setGroupId(clusterId);
    service.setCreateTime(now);
    try {
        this.serviceMapper.insert(service);
        return service;
    } catch (DuplicateKeyException ex) {
        logger.warn("service duplicate key " + ex.getMessage());
        return this.find(name, clusterId);
    }
}
 
Example 7
Source Project: cloudbreak   Source File: MockUserManagementService.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * NOTE: This is a mock implementation and meant only for testing.
 * This implementation returns hard coded pre-defined set of response for workload credentials.
 * For any integration test of debugging purpose, this should not be used and intent is purely mock.
 * Hashed value used internally is sha256 hash of <i>Password123!</i>.
 */
@Override
public void getActorWorkloadCredentials(GetActorWorkloadCredentialsRequest request,
        io.grpc.stub.StreamObserver<GetActorWorkloadCredentialsResponse> responseObserver) {
    GetActorWorkloadCredentialsResponse.Builder builder = GetActorWorkloadCredentialsResponse.newBuilder(actorWorkloadCredentialsResponse);
    builder.setPasswordHashExpirationDate(System.currentTimeMillis() + PASSWORD_LIFETIME);
    if (sshPublicKey.isPresent()) {
        Crn actorCrn = Crn.safeFromString(request.getActorCrn());
        builder.addSshPublicKey(SshPublicKey.newBuilder(sshPublicKey.get())
                .setCrn(Crn.builder()
                        .setAccountId(actorCrn.getAccountId())
                        .setPartition(actorCrn.getPartition())
                        .setService(Crn.Service.IAM)
                        .setResourceType(ResourceType.PUBLIC_KEY)
                        .setResource(UUID.randomUUID().toString())
                        .build()
                        .toString())
                .build());
    }

    responseObserver.onNext(builder.build());
    responseObserver.onCompleted();
}
 
Example 8
Source Project: AthenaServing   Source File: CopyAndAddTransactional.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 复制集群
 *
 * @param body
 * @return
 */
@Transactional
public Cluster copyAndAddCluster(CopyClusterRequestBody body) {
	AddClusterRequestBody addClusterRequestBody = new AddClusterRequestBody(body.getClusterName(), body.getDesc(), body.getProjectId());

	// (一)新增集群
	Cluster cluster = this.clusterConditionImpl.add(addClusterRequestBody);
	String newClusterId = cluster.getId();

	// (二)根据被复制的集群id查询tb_service表,若该集群下存在服务,则复制服务
	String oldClusterId = body.getOldClusterId();
	List<String> clusterIds = new ArrayList<>();
	clusterIds.add(oldClusterId);
	List<com.iflytek.ccr.polaris.cynosure.domain.Service> serviceList = this.serviceConditionImpl.findList(clusterIds);
	if (null != serviceList && !serviceList.isEmpty()) {
		for (com.iflytek.ccr.polaris.cynosure.domain.Service service : serviceList) {
			CopyServiceRequestBody body1 = new CopyServiceRequestBody(newClusterId, service.getId(), service.getName(), service.getDescription());
			copyAndAddService(body1);
		}
	}

	return cluster;
}
 
Example 9
Source Project: jhipster-operator   Source File: K8SCoreRuntime.java    License: Apache License 2.0 6 votes vote down vote up
private String tryIstioGatewayApproach() {
    String istioIP = "N/A";
    ServiceList list = kubernetesClient.services().inNamespace("istio-system").list();
    for (io.fabric8.kubernetes.api.model.Service s : list.getItems()) {
        if (s.getMetadata().getName().equals("istio-ingressgateway")) {
            List<LoadBalancerIngress> ingress = s.getStatus().getLoadBalancer().getIngress();
            if (ingress.size() == 1) {
                istioIP = ingress.get(0).getIp();
            }
        } else {
            logger.error(">> Trying to resolve External IP from istio-ingressgateway failed. There will be no external IP for your apps.");
            logger.error(">> Trying to use port-forward:  'kubectl port-forward svc/jhipster-operator 8081:80 " +
                    "-n jhipster' and then access using http://localhost:8081/apps/");
        }
    }
    return istioIP;
}
 
Example 10
@Test
public void testWithComponentAnnotationOnly() {
	ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false);
	provider.addIncludeFilter(new AnnotationTypeFilter(Component.class));
	provider.addExcludeFilter(new AnnotationTypeFilter(Repository.class));
	provider.addExcludeFilter(new AnnotationTypeFilter(Service.class));
	provider.addExcludeFilter(new AnnotationTypeFilter(Controller.class));
	Set<BeanDefinition> candidates = provider.findCandidateComponents(TEST_BASE_PACKAGE);
	assertEquals(3, candidates.size());
	assertTrue(containsBeanClass(candidates, NamedComponent.class));
	assertTrue(containsBeanClass(candidates, ServiceInvocationCounter.class));
	assertTrue(containsBeanClass(candidates, BarComponent.class));
	assertFalse(containsBeanClass(candidates, FooServiceImpl.class));
	assertFalse(containsBeanClass(candidates, StubFooDao.class));
	assertFalse(containsBeanClass(candidates, NamedStubDao.class));
}
 
Example 11
@Test
@SuppressWarnings("unchecked")
public void findAnnotationDescriptorForTypesWithMetaAnnotationWithOverriddenAttributes() throws Exception {
	Class<?> startClass = MetaConfigWithOverriddenAttributesTestCase.class;
	Class<ContextConfiguration> annotationType = ContextConfiguration.class;

	UntypedAnnotationDescriptor descriptor = findAnnotationDescriptorForTypes(startClass, Service.class,
		ContextConfiguration.class, Order.class, Transactional.class);

	assertNotNull(descriptor);
	assertEquals(startClass, descriptor.getRootDeclaringClass());
	assertEquals(annotationType, descriptor.getAnnotationType());
	assertArrayEquals(new Class[] {}, ((ContextConfiguration) descriptor.getAnnotation()).value());
	assertArrayEquals(new Class[] { MetaAnnotationUtilsTests.class },
		descriptor.getAnnotationAttributes().getClassArray("classes"));
	assertNotNull(descriptor.getComposedAnnotation());
	assertEquals(MetaConfig.class, descriptor.getComposedAnnotationType());
}
 
Example 12
Source Project: java-technology-stack   Source File: MetaAnnotationUtilsTests.java    License: MIT License 6 votes vote down vote up
@SuppressWarnings("unchecked")
private void assertAtComponentOnComposedAnnotationForMultipleCandidateTypes(Class<?> startClass,
		Class<?> rootDeclaringClass, Class<?> declaringClass, String name,
		Class<? extends Annotation> composedAnnotationType) {

	Class<Component> annotationType = Component.class;
	UntypedAnnotationDescriptor descriptor = findAnnotationDescriptorForTypes(
			startClass, Service.class, annotationType, Order.class, Transactional.class);

	assertNotNull("UntypedAnnotationDescriptor should not be null", descriptor);
	assertEquals("rootDeclaringClass", rootDeclaringClass, descriptor.getRootDeclaringClass());
	assertEquals("declaringClass", declaringClass, descriptor.getDeclaringClass());
	assertEquals("annotationType", annotationType, descriptor.getAnnotationType());
	assertEquals("component name", name, ((Component) descriptor.getAnnotation()).value());
	assertNotNull("composedAnnotation should not be null", descriptor.getComposedAnnotation());
	assertEquals("composedAnnotationType", composedAnnotationType, descriptor.getComposedAnnotationType());
}
 
Example 13
Source Project: java-technology-stack   Source File: MetaAnnotationUtilsTests.java    License: MIT License 6 votes vote down vote up
@Test
@SuppressWarnings("unchecked")
public void findAnnotationDescriptorForTypesWithMetaAnnotationWithOverriddenAttributes() {
	Class<?> startClass = MetaConfigWithOverriddenAttributesTestCase.class;
	Class<ContextConfiguration> annotationType = ContextConfiguration.class;

	UntypedAnnotationDescriptor descriptor = findAnnotationDescriptorForTypes(
			startClass, Service.class, ContextConfiguration.class, Order.class, Transactional.class);

	assertNotNull(descriptor);
	assertEquals(startClass, descriptor.getRootDeclaringClass());
	assertEquals(annotationType, descriptor.getAnnotationType());
	assertArrayEquals(new Class<?>[] {}, ((ContextConfiguration) descriptor.getAnnotation()).value());
	assertArrayEquals(new Class<?>[] {MetaAnnotationUtilsTests.class},
			descriptor.getAnnotationAttributes().getClassArray("classes"));
	assertNotNull(descriptor.getComposedAnnotation());
	assertEquals(MetaConfig.class, descriptor.getComposedAnnotationType());
}
 
Example 14
Source Project: paas   Source File: MonitorServiceImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public ResultVO getDockerInfo() {
    try {
        Info info = dockerClient.info();
        List<Node> nodes = dockerSwarmClient.listNodes();
        List<com.spotify.docker.client.messages.swarm.Service> services = dockerSwarmClient.listServices();

        DockerInfoVO infoVO = genDockerInfoVO(info);
        infoVO.setNodes(genDockerNodeInfoVO(nodes));
        infoVO.setServiceNum(services.size());

        return ResultVOUtils.success(infoVO);
    } catch (Exception e) {
        log.error("读取Docker宿主机信息错误,错误位置:{},错误栈:{}",
                "MonitorServiceImpl.getDockerInfo()", HttpClientUtils.getStackTraceAsString(e));
        return ResultVOUtils.error(ResultEnum.DOCKER_EXCEPTION);
    }
}
 
Example 15
Source Project: aaden-pay   Source File: ThirdBankRoute.java    License: Apache License 2.0 6 votes vote down vote up
public ThirdBankVerifyService route(BankRequest request) throws Exception {
	if (request == null || request.getInfo().getChannel() == null) {
		throw new Exception("当前暂不支持的第三方支付渠道");
	}

	if (thirdClassList == null)
		throw new Exception("当前暂不支持的第三方支付渠道");

	for (Class<?> clz : thirdClassList) {
		ChannelValue comment = clz.getAnnotation(ChannelValue.class);
		if (comment == null)
			continue;
		if (comment.channel() != request.getInfo().getChannel())
			continue;

		Service service = clz.getAnnotation(Service.class);
		if (service == null)
			continue;

		return (ThirdBankVerifyService) SpringContextHelper.getBean(service.value());
	}

	throw new Exception("当前暂不支持的第三方支付渠道");
}
 
Example 16
Source Project: AthenaServing   Source File: BaseService.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 创建服务结果
 *
 * @param service
 * @return
 */
protected ServiceDetailResponseBody createServiceResult(com.iflytek.ccr.polaris.cynosure.domain.Service service) {
    ServiceDetailResponseBody result = new ServiceDetailResponseBody();
    result.setId(service.getId());
    result.setName(service.getName());
    result.setDesc(service.getDescription());
    result.setClusterId(service.getGroupId());
    result.setCreateTime(service.getCreateTime());
    result.setUpdateTime(service.getUpdateTime());
    return result;
}
 
Example 17
Source Project: AthenaServing   Source File: ServiceVersionImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Response<ServiceVersionDetailResponseBody> copy(CopyServiceVersionRequestBody body) {
	// 根据服务id查询复制后的版本所属的服务是否存在,若不存在,直接返回
	String serviceId = body.getServiceId();
	com.iflytek.ccr.polaris.cynosure.domain.Service service = this.serviceConditionimpl.findById(serviceId);
	if (null == service) {
		return new Response<>(SystemErrCode.ERRCODE_SERVICE_NOT_EXISTS, SystemErrCode.ERRMSG_SERVICE_NOT_EXISTS);
	}

	// 根据新的版本version和所属服务的id查询该版本是否已经存在,若存在,直接返回
	String version = body.getVersion();
	ServiceVersion serviceVersion = this.serviceVersionConditionImpl.find(version, serviceId);
	if (null != serviceVersion) {
		return new Response<>(SystemErrCode.ERRCODE_SERVICE_VERSION_EXISTS, SystemErrCode.ERRMSG_SERVICE_VERSION_EXISTS);
	}

	// 根据版本id查询被复制的版本是否存在,若不存在,直接返回
	String oldVersionId = body.getOldVersionId();
	ServiceVersion versionCopy = this.serviceVersionConditionImpl.findById(oldVersionId);
	if (null == versionCopy) {
		return new Response<>(SystemErrCode.ERRCODE_SERVICE_VERSION_NOT_EXISTS, SystemErrCode.ERRMSG_SERVICE_VERSION_NOT_EXISTS);
	}
	
	// 复制版本
	ServiceVersion newServiceVersion = this.copyAndAddTransactional.copyAndAddVersion(body,versionCopy.getUpdateTime());

	// 版本结果
	ServiceVersionDetailResponseBody result = this.createServiceVersionResult(newServiceVersion);
	return new Response<>(result);
}
 
Example 18
Source Project: AthenaServing   Source File: TrackServiceImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Response<QueryPagingListResponseBody> findList(BaseRequestBody body) {
    QueryPagingListResponseBody result;
    //查询项目列表
    HashMap<String, Object> map = new HashMap<>();
    map.put("userId", this.getUserId());
    List<Project> projectList = this.projectConditionImpl.findList(map);
    if (null == projectList || projectList.isEmpty()) {
        result = PagingUtil.createResult(body, 0);
        return new Response<>(result);
    }
    int totalCount = projectList.size();
    result = PagingUtil.createResult(body, totalCount);

    //查询集群列表
    List<String> projectIds = projectList.stream().map(x -> x.getId()).collect(toList());
    List<Cluster> clusterList = this.clusterConditionImpl.findList(projectIds);

    //查询服务列表
    List<com.iflytek.ccr.polaris.cynosure.domain.Service> serviceList = new ArrayList<>();
    if (null != clusterList && !clusterList.isEmpty()) {
        List<String> clusterIds = clusterList.stream().map(x -> x.getId()).collect(toList());
        serviceList = this.serviceConditionImpl.findList(clusterIds);
    }

    //查询版本列表
    List<ServiceApiVersion> serviceApiVersionList = new ArrayList<>();
    if (null != serviceList && !serviceList.isEmpty()) {
        List<String> serviceIds = serviceList.stream().map(x -> x.getId()).collect(toList());
        serviceApiVersionList = this.serviceApiVersionCondition.findList(serviceIds);
    }

    //创建列表
    List<QueryProjectResponseBodyByQuickStart> list = this.createList(projectList, clusterList, serviceList, serviceApiVersionList);
    result.setList(list);
    return new Response<>(result);
}
 
Example 19
/**
 * @since 4.0.3
 */
@Test
@SuppressWarnings("unchecked")
public void findAnnotationDescriptorForTypesOnAnnotatedClassWithMissingTargetMetaAnnotation() {
	// InheritedAnnotationClass is NOT annotated or meta-annotated with @Component,
	// @Service, or @Order, but it is annotated with @Transactional.
	UntypedAnnotationDescriptor descriptor = findAnnotationDescriptorForTypes(InheritedAnnotationClass.class,
		Service.class, Component.class, Order.class);
	assertNull("Should not find @Component on InheritedAnnotationClass", descriptor);
}
 
Example 20
Source Project: cuba   Source File: CubaMethodValidationPostProcessor.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void afterPropertiesSet() {
    Pointcut pointcut = new AnnotationMatchingPointcut(Service.class, Validated.class, true);
    DefaultPointcutAdvisor advisor = new DefaultPointcutAdvisor(pointcut, createMethodValidationAdvice(this.beanValidation));
    advisor.setOrder(2);
    this.advisor = advisor;
}
 
Example 21
Source Project: AthenaServing   Source File: QuickStartServiceImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Response<QueryPagingListResponseBody> findList1(BaseRequestBody body) {
    QueryPagingListResponseBody result;
    //查询项目列表
    HashMap<String, Object> map = new HashMap<>();
    map.put("userId", this.getUserId());
    List<Project> projectList = this.projectConditionImpl.findList(map);
    if (null == projectList || projectList.isEmpty()) {
        result = PagingUtil.createResult(body, 0);
        return new Response<>(result);
    }
    int totalCount = projectList.size();
    result = PagingUtil.createResult(body, totalCount);

    //查询集群列表
    List<String> projectIds = projectList.stream().map(x -> x.getId()).collect(toList());
    List<Cluster> clusterList = this.clusterConditionImpl.findList(projectIds);

    //查询服务列表
    List<com.iflytek.ccr.polaris.cynosure.domain.Service> serviceList = new ArrayList<>();
    if (null != clusterList && !clusterList.isEmpty()) {
        List<String> clusterIds = clusterList.stream().map(x -> x.getId()).collect(toList());
        serviceList = this.serviceConditionImpl.findList(clusterIds);
    }

    //查询版本列表
    List<ServiceApiVersion> serviceApiVersionList = new ArrayList<>();
    if (null != serviceList && !serviceList.isEmpty()) {
        List<String> serviceIds = serviceList.stream().map(x -> x.getId()).collect(toList());
        serviceApiVersionList = this.serviceApiVersionImpl.findList1(serviceIds);
    }

    //创建列表
    List<QueryProjectResponseBodyByQuickStart> list = this.createList1(projectList, clusterList, serviceList, serviceApiVersionList);
    result.setList(list);
    return new Response<>(result);
}
 
Example 22
Source Project: AthenaServing   Source File: ServiceImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Response<QueryPagingListResponseBody> findList(QueryServiceListRequestBody body) {
    String projectName = body.getProject();
    String clusterName = body.getCluster();
    if (StringUtils.isBlank(projectName) || StringUtils.isBlank(clusterName)) {
        return new Response<>(PagingUtil.createResult(body, 0));
    }

    //创建分页查询条件
    HashMap<String, Object> map = PagingUtil.createCondition(body);
    map.put("projectName", projectName);
    map.put("clusterName", clusterName);

    //查询总数
    int totalCount = this.serviceConditionImpl.findTotalCount(map);

    //创建分页结果
    QueryPagingListResponseBody result = PagingUtil.createResult(body, totalCount);
    if (0 == totalCount) {
        return new Response<>(result);
    }

    //查询列表
    List<ServiceDetailResponseBody> list = new ArrayList<>();
    Optional<List<com.iflytek.ccr.polaris.cynosure.domain.Service>> serviceList = Optional.ofNullable(this.serviceConditionImpl.findList(map));
    serviceList.ifPresent(x -> {
        x.forEach(y -> {
            //创建服务结果
            ServiceDetailResponseBody serviceDetail = this.createServiceResult(y);
            list.add(serviceDetail);
        });
    });
    result.setList(list);
    return new Response<>(result);
}
 
Example 23
Source Project: olat   Source File: CoreSpringFactory.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Prototype-method : Get service which is annotated with '@Service'.
 * 
 * @param <T>
 * @param serviceType
 * @return Service of requested type, must not be casted.
 * @throws RuntimeException
 *             when more than one service of the same type is registered. RuntimeException when servie is not annotated with '@Service'.
 * 
 *             *******not yet in use********
 */
private static <T> T getService(Class<T> serviceType) {
    ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(CoreSpringFactory.servletContext);
    Map<String, T> m = context.getBeansOfType(serviceType);
    if (m.size() > 1) {
        throw new OLATRuntimeException("found more than one service for: " + serviceType + ". Calling this method should only find one service-bean!", null);
    }
    T service = context.getBean(serviceType);
    Map<String, ?> services = context.getBeansWithAnnotation(org.springframework.stereotype.Service.class);
    if (services.containsValue(service)) {
        return service;
    } else {
        throw new OLATRuntimeException("Try to get Service which is not annotated with '@Service', services must have '@Service'", null);
    }
}
 
Example 24
Source Project: waltz   Source File: EndpointArchitectureCompliance.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void extractorsNeedServiceAnnotation() {
    ArchRule rule = classes().that()
            .areAssignableTo(DataExtractor.class)
            .and()
            .dontHaveSimpleName("DataExtractor")
            .should()
            .haveNameMatching(".*Extractor")
            .andShould()
            .beAnnotatedWith(Service.class);
    rule.check(waltzOnlyClasses);
}
 
Example 25
@Test
public void transactionProxyIsCreated() {
	AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(EnableTxConfig.class, TxManagerConfig.class);
	TransactionalTestBean bean = ctx.getBean(TransactionalTestBean.class);
	assertTrue("testBean is not a proxy", AopUtils.isAopProxy(bean));
	Map<?,?> services = ctx.getBeansWithAnnotation(Service.class);
	assertTrue("Stereotype annotation not visible", services.containsKey("testBean"));
	ctx.close();
}
 
Example 26
Source Project: AthenaServing   Source File: ServiceConditionImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public com.iflytek.ccr.polaris.cynosure.domain.Service find(String name, String clusterId) {
    com.iflytek.ccr.polaris.cynosure.domain.Service service = new com.iflytek.ccr.polaris.cynosure.domain.Service();
    service.setGroupId(clusterId);
    service.setName(name);
    return this.serviceMapper.find(service);
}
 
Example 27
Source Project: javamelody   Source File: JavaMelodyAutoConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Monitoring of beans having the {@link Service} annotation.
 * @return MonitoringSpringAdvisor
 */
@Bean
@ConditionalOnProperty(prefix = JavaMelodyConfigurationProperties.PREFIX, name = "spring-monitoring-enabled", matchIfMissing = true)
public MonitoringSpringAdvisor monitoringSpringServiceAdvisor() {
	return createMonitoringSpringAdvisorWithExclusions(
			new AnnotationMatchingPointcut(Service.class),
			monitoredWithSpringAnnotationPointcut, asyncAnnotationPointcut,
			scheduledAnnotationPointcut);
}
 
Example 28
Source Project: AthenaServing   Source File: ServiceConditionImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public com.iflytek.ccr.polaris.cynosure.domain.Service findServiceJoinGroupJoinProjectByName(String project, String group, String service) {
    HashMap<String, Object> map = new HashMap<>();
    map.put("project", project);
    map.put("group", group);
    map.put("service", service);
    return this.serviceMapper.findServiceJoinGroupJoinProjectByMap(map);
}
 
Example 29
Source Project: cloudbreak   Source File: GcpDiskEncryptionService.java    License: Apache License 2.0 5 votes vote down vote up
private byte[] getEncryptionKeyBytes(String encryptionKey) {
    try {
        MessageDigest digest = MessageDigest.getInstance(HASH_ALGORITHM);
        return digest.digest(Optional.ofNullable(encryptionKey).orElse("").getBytes(StandardCharsets.UTF_8));
    } catch (NoSuchAlgorithmException e) {
        List<String> supportedAlgorithms = Arrays.stream(Security.getProviders())
                .map(Provider::getServices).flatMap(Set::stream).map(Provider.Service::getAlgorithm).collect(Collectors.toList());
        throw new CloudbreakServiceException("Hashing algorithm, " + HASH_ALGORITHM + " not supported. Supported algorithms: " + supportedAlgorithms, e);
    }
}
 
Example 30
Source Project: cloudbreak   Source File: MockUserManagementService.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void listMachineUsers(ListMachineUsersRequest request, StreamObserver<ListMachineUsersResponse> responseObserver) {
    if (request.getMachineUserNameOrCrnCount() == 0) {
        responseObserver.onNext(ListMachineUsersResponse.newBuilder().build());
    } else {
        String machineUserIdOrCrn = request.getMachineUserNameOrCrn(0);
        String[] splittedCrn = machineUserIdOrCrn.split(":");
        String userName;
        String accountId = request.getAccountId();
        String crnString;
        if (splittedCrn.length > 1) {
            userName = splittedCrn[6];
            crnString = machineUserIdOrCrn;
        } else {
            userName = machineUserIdOrCrn;
            Crn crn = mockCrnService.createCrn(accountId, Crn.Service.IAM, ResourceType.MACHINE_USER, userName);
            crnString = crn.toString();
        }
        responseObserver.onNext(
                ListMachineUsersResponse.newBuilder()
                        .addMachineUser(MachineUser.newBuilder()
                                .setMachineUserId(UUID.nameUUIDFromBytes((accountId + '#' + userName).getBytes()).toString())
                                .setCrn(crnString)
                                .setWorkloadUsername(sanitizeWorkloadUsername(userName))
                                .build())
                        .build());
    }
    responseObserver.onCompleted();
}