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

Java Fields类代码示例

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

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



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

示例1: execute

import org.biokoframework.utils.fields.Fields; //导入依赖的package包/类
@Override
public Fields execute(Fields input) throws CommandException {
	logInput(input);
	Repository<? extends DomainEntity> repository = getRepository(fDomainEntityClass);
	
	String id = input.get(DomainEntity.ID);
	if (StringUtils.isEmpty(id)) {
		throw CommandExceptionsFactory.createExpectedFieldNotFound(DomainEntity.ID);
	}
	
	ArrayList<DomainEntity> response = new ArrayList<>();
	
	DomainEntity entity = repository.delete(id);
	if (entity == null) {
		throw CommandExceptionsFactory.createEntityNotFound(fDomainEntityClass, id);
	}
	response.add(entity);
	
	Fields output = new Fields(
			GenericFieldNames.RESPONSE, response);
	logOutput(output);
	return output;
}
 
开发者ID:bioko,项目名称:system,代码行数:24,代码来源:DeleteEntityCommand.java


示例2: twoWorkingCommands

import org.biokoframework.utils.fields.Fields; //导入依赖的package包/类
@Test
public void twoWorkingCommands() throws BiokoException {
	EntityBuilder<Login> login = new LoginBuilder().loadDefaultExample();
	login.setId("1");
	
	Fields input = new Fields();
	input.put(FieldNames.COMMAND_NAME, "POST_login");
	input.putAll(login.build(false).fields());
	
	Fields output = _system.execute(input);
	
	Fields input2 = new Fields();
	input2.put(FieldNames.COMMAND_NAME, "GET_login");
	input2.put(GenericFieldNames.USER_EMAIL, "matto");
	input2.put(GenericFieldNames.PASSWORD, "fatto");
	
	output = _system.execute(input2);
	
	assertEquals("[" + login.build(true).toJSONString() + "]", 
			JSONValue.toJSONString(output.get(GenericFieldNames.RESPONSE)));
}
 
开发者ID:bioko,项目名称:system-a-test,代码行数:22,代码来源:BasicXSystemTest.java


示例3: execute

import org.biokoframework.utils.fields.Fields; //导入依赖的package包/类
@Override
public Fields execute(Fields input) throws CommandException {
	logInput(input);

	Fields pushFields;
	while((pushFields = fPushQueueService.popFields(PUSH_QUEUE)) != null) {
		String userToken = pushFields.get(IPushNotificationService.USER_TOKEN);
		String content = pushFields.get(GenericFieldNames.CONTENT);
		Boolean production = pushFields.get(IPushNotificationService.PRODUCTION);

		try {
			if (StringUtils.isEmpty(userToken)) {
				sendBroadcastPush(content, production);
			} else {
				sendPush(userToken, content, production);
			}
		} catch (NotificationFailureException exception) {
			LOGGER.error("Pushing", exception);
		}
		
	}
		
	logOutput();
	return new Fields();
}
 
开发者ID:bioko,项目名称:system,代码行数:26,代码来源:SendPushCommand.java


示例4: execute

import org.biokoframework.utils.fields.Fields; //导入依赖的package包/类
@Override
public Fields execute(Fields input) throws CommandException {
	logInput(input);

	// save text mandatory field into dummy1 entity repo
	Repository<DummyEntity1> dummy1Repo = getRepository(DummyEntity1.class);
	DummyEntity1 dummy1 = new DummyEntity1();
	dummy1.set(DummyEntity1.VALUE, input.get(TEXT_MANDATORY_FIELD));
	dummy1 = SafeRepositoryHelper.save(dummy1Repo, dummy1);

	// save integer optional field into dummy2
	Long integerFieldValue = input.get(INTEGER_OPTIONAL_FIELD); 
	if (integerFieldValue != null) {
		Repository<DummyEntity2> dummy2Repo = getRepository(DummyEntity2.class);
		DummyEntity2 dummy2 = new DummyEntity2();
		dummy2.set(DummyEntity2.VALUE, input.get(INTEGER_OPTIONAL_FIELD));
		dummy2.set(DummyEntity2.ENTITY1_ID, dummy1.getId());
		dummy2 = SafeRepositoryHelper.save(dummy2Repo, dummy2);
	}

	logOutput();
	return new Fields(GenericFieldNames.RESPONSE, new ArrayList<DomainEntity>());
}
 
开发者ID:bioko,项目名称:system-a,代码行数:24,代码来源:ValidatedCommand.java


示例5: createEntityNotFound

import org.biokoframework.utils.fields.Fields; //导入依赖的package包/类
public static CommandException createEntityNotFound(Class<? extends DomainEntity> entityClass, String fieldName, String fieldValue) {
	String[] message = sErrorMap.get(FieldNames.ENTITY_WITH_FIELD_NOT_FOUND_CODE);
	Fields fields = new Fields(
			ErrorEntity.ERROR_CODE, FieldNames.ENTITY_WITH_FIELD_NOT_FOUND_CODE,
			ErrorEntity.ERROR_MESSAGE, new StringBuilder()
				.append(message[0])
				.append(entityClass.getSimpleName())
				.append(message[1])
				.append(fieldName)
				.append(message[2])
				.append(fieldValue)
				.append(message[3])
				.toString());
	
	ErrorEntity entity = new ErrorEntity();
	entity.setAll(fields);
	return new EntityNotFoundException(entity);
}
 
开发者ID:bioko,项目名称:system,代码行数:19,代码来源:CommandExceptionsFactory.java


示例6: postOutputKeys

import org.biokoframework.utils.fields.Fields; //导入依赖的package包/类
private static <T extends DomainEntity> Fields postOutputKeys(Class<T> domainEntityClass) {
	ArrayList<String> entityKeys = null;
	try {
		entityKeys = ComponingFieldsFactory.create(domainEntityClass);
	} catch (Exception e) {
		LOGGER.error("Unable to get componing keys for entity " + domainEntityClass.getSimpleName(), e);
		return null;
	}

	ArrayList<DomainEntity> parameters = new ArrayList<DomainEntity>();
	ParameterEntityBuilder builder = new ParameterEntityBuilder();
	for (String aKey : entityKeys) {
		builder.set(ParameterEntity.NAME, aKey);
		parameters.add(builder.build(false));
	}
	
	builder.set(ParameterEntity.NAME, DomainEntity.ID);
	parameters.add(builder.build(false));
	
	return new Fields(GenericFieldNames.OUTPUT, parameters);
}
 
开发者ID:bioko,项目名称:system,代码行数:22,代码来源:CrudComponingKeysBuilder.java


示例7: emailConfirm

import org.biokoframework.utils.fields.Fields; //导入依赖的package包/类
@Test
public void emailConfirm() throws Exception {
    TestCurrentTimeService.setCalendar("2014-01-12T01:45:23+0100");

    Login login = fLoginBuilder.loadDefaultExample().build(false);
    login = fLoginRepo.save(login);

    String token = "00000000-0000-0000-0000-000000000001";

    EmailConfirmation confirmation = fInjector.getInstance(EmailConfirmation.class);
    confirmation.setAll(new Fields(
            EmailConfirmation.LOGIN_ID, login.getId(),
            EmailConfirmation.CONFIRMED, false,
            EmailConfirmation.TOKEN, token));

    confirmation = fConfirmRepo.save(confirmation);

    fService.confirmEmailAddress(login.getId(), token);

    EmailConfirmation confirmed = fConfirmRepo.retrieve(confirmation.getId());

    assertThat(confirmed, has(EmailConfirmation.LOGIN_ID, equalTo(login.getId())));
    assertThat(confirmed, has(EmailConfirmation.CONFIRMED, equalTo(true)));
    assertThat(confirmed, has(EmailConfirmation.TOKEN, equalTo(token)));
    assertThat(confirmed, has(EmailConfirmation.CONFIRMATION_TIMESTAMP, equalTo("2014-01-12T01:45:23+0100")));
}
 
开发者ID:bioko,项目名称:system,代码行数:27,代码来源:EmailConfirmationServiceTest.java


示例8: executeCommand

import org.biokoframework.utils.fields.Fields; //导入依赖的package包/类
@Override
public Fields executeCommand(Fields input) throws SystemException, ValidationException {
       AuthResponse authResponse = null;
	try {
		authResponse = fAuthService.authenticate(input, fRequiredRoles);
		input.putAll(authResponse.getMergeFields());
	} catch (AuthenticationFailureException exception) {
		if (fRequireValidAuthentication) {
			throw exception;
		}
	}
       Fields output = fWrappedHandler.executeCommand(input);
       if (authResponse != null && authResponse.getOverrideFields() != null) {
           output.putAll(authResponse.getOverrideFields());
       }
	return output;
}
 
开发者ID:bioko,项目名称:http-exposer,代码行数:18,代码来源:SecurityHandler.java


示例9: httpAuthenticate

import org.biokoframework.utils.fields.Fields; //导入依赖的package包/类
@Override
public Fields httpAuthenticate(Fields input) throws AuthenticationFailureException {
	String encodedAuth = getHeader(AUTHORIZATION);
	String decodedAuth = new String(Base64.decodeBase64(encodedAuth.substring(BASIC_AUTH_START.length())));
	
	String userName = decodedAuth.replaceFirst(":.*", "");
	String password = decodedAuth.replaceFirst(".*:", "");
	
	Login login = fLoginRepository.retrieveByForeignKey(GenericFieldNames.USER_EMAIL, userName);
	if (login == null) {
		throw CommandExceptionsFactory.createInvalidLoginException();
	} else if (!login.get(GenericFieldNames.PASSWORD).equals(password)) {
		throw CommandExceptionsFactory.createInvalidLoginException();
	}
	
	return new Fields(Login.class.getSimpleName(), login);
}
 
开发者ID:bioko,项目名称:http-exposer,代码行数:18,代码来源:BasicAccessAuthenticationStrategy.java


示例10: safelyParse

import org.biokoframework.utils.fields.Fields; //导入依赖的package包/类
@Override
protected Fields safelyParse(HttpServletRequest request) throws RequestNotSupportedException {
    Fields fields = new Fields();

    try {
        for(Part aPart : request.getParts()) {
            if (isAFilePart(aPart)) {
                fields.putAll(fFilePartParser.parse(aPart, chooseEncoding(request)));
            } else {
                fields.putAll(fStringPartParser.parse(aPart, chooseEncoding(request)));
            }
        }
    } catch (IOException | ServletException e) {
        e.printStackTrace();
    }

    return fields;
}
 
开发者ID:bioko,项目名称:http-exposer,代码行数:19,代码来源:MultipartFieldsParser.java


示例11: execute

import org.biokoframework.utils.fields.Fields; //导入依赖的package包/类
@Override
public Fields execute(Fields input) throws CommandException {
	logInput(input);
	Fields result = new Fields();
	BinaryEntityRepository blobRepo = getRepository(BinaryEntity.class);

	ArrayList<BinaryEntity> response = new ArrayList<BinaryEntity>();
	
	String blobId = input.get(DomainEntity.ID);
	if (blobId == null || blobId.isEmpty()) {
		throw CommandExceptionsFactory.createExpectedFieldNotFound(DomainEntity.ID);
	}
			
	BinaryEntity blob = blobRepo.retrieveWithoutFile(blobId);
	if (blob == null) {
		throw CommandExceptionsFactory.createEntityNotFound(BinaryEntity.class, blobId);
	}
	response.add(blob);

       String mediaType = blob.get(BinaryEntity.MEDIA_TYPE);
	result.put(GenericFieldNames.RESPONSE_CONTENT_TYPE, MediaType.parse(mediaType));
	result.put(GenericFieldNames.RESPONSE, response);
	
	logOutput(result);
	return result;
}
 
开发者ID:bioko,项目名称:system,代码行数:27,代码来源:HeadBinaryEntityCommand.java


示例12: testSuccessfulAuthenticationUsingToken

import org.biokoframework.utils.fields.Fields; //导入依赖的package包/类
@Test
public void testSuccessfulAuthenticationUsingToken() throws ValidationException, RepositoryException, AuthenticationFailureException {
    TestCurrentTimeService.setCalendar("2014-01-22T18:00:05Z");

    Login login = fLoginBuilder.loadDefaultExample().build(false);
    login = fLoginRepo.save(login);

    fAuthService = fInjector.getInstance(TokenAuthenticationServiceImpl.class);

    Authentication auth = fAuthBuilder.loadDefaultExample()
            .set(Authentication.LOGIN_ID, login.getId()).build(false);
    fAuthRepo.save(auth);

    Fields fields = new Fields("authToken", auth.get(Authentication.TOKEN));
    AuthResponse authResponse = fAuthService.authenticate(fields, Collections.<String>emptyList());

    assertThat(authResponse.getMergeFields(), contains(GenericFieldNames.AUTH_LOGIN_ID, login.getId()));

    DateTime authTokenExpire = ISODateTimeFormat.dateTimeNoMillis().parseDateTime((String) authResponse.getOverrideFields().get(Authentication.TOKEN_EXPIRE));
    assertThat(authTokenExpire, is(equalTo(fTimeService.getCurrentTimeAsDateTime().plus(fTokenValiditySecs * 1000))));
}
 
开发者ID:bioko,项目名称:system,代码行数:22,代码来源:TokenAuthenticationServiceImplTest.java


示例13: test

import org.biokoframework.utils.fields.Fields; //导入依赖的package包/类
@Test
public void test() {
	RouteMatcherImpl matcher = new RouteMatcherImpl(HttpMethod.POST, SIMPLE_POST_COMMAND);
	
	IRoute route = new RouteImpl(HttpMethod.POST, "/simple-post-command", new Fields());
	assertThat(matcher, matches(route));
	assertThat(route.getFields(), is(empty()));
	route = new RouteImpl(HttpMethod.POST, "/simple-post-command/", new Fields());
	assertThat(matcher, matches(route));
	assertThat(route.getFields(), is(empty()));

	route = new RouteImpl(HttpMethod.POST, "/an-other-command", new Fields());
	assertThat(matcher, not(matches(route)));
	
	route = new RouteImpl(HttpMethod.PUT, "/simple-post-command", new Fields());
	assertThat(matcher, not(matches(route)));
}
 
开发者ID:bioko,项目名称:http-exposer,代码行数:18,代码来源:RouteMatcherImplTest.java


示例14: outputKeys

import org.biokoframework.utils.fields.Fields; //导入依赖的package包/类
public static <T extends DomainEntity> LinkedHashMap<String, Fields> outputKeys(Class<T> domainEntityClass) {
		String entityName = EntityClassNameTranslator.toHyphened(domainEntityClass.getSimpleName());
		LinkedHashMap<String, Fields> outputKeysMap = new LinkedHashMap<String, Fields>();
		
		outputKeysMap.put(
				GenericCommandNames.composeRestCommandName(HttpMethod.POST, entityName),
				postOutputKeys(domainEntityClass));
	
		 outputKeysMap.put(
				 GenericCommandNames.composeRestCommandName(HttpMethod.PUT, entityName),
				 putOutputKeys(domainEntityClass));

		outputKeysMap.put(
				GenericCommandNames.composeRestCommandName(HttpMethod.GET, entityName),
				getOutputKeys(domainEntityClass));

		outputKeysMap.put(
				GenericCommandNames.composeRestCommandName(HttpMethod.DELETE, entityName),
				deleteOutputKeys(domainEntityClass));
	
	return outputKeysMap;
}
 
开发者ID:bioko,项目名称:system,代码行数:23,代码来源:CrudComponingKeysBuilder.java


示例15: testWithRegexpedParameter

import org.biokoframework.utils.fields.Fields; //导入依赖的package包/类
@Test
public void testWithRegexpedParameter() {
	RouteMatcherImpl matcher = new RouteMatcherImpl(HttpMethod.GET, DUMMY_CRUD);
	
	IRoute route = new RouteImpl(HttpMethod.GET, "/dummy-crud/", new Fields());
	assertThat(matcher, matches(route));
	assertThat(route.getFields(), is(empty()));

	route = new RouteImpl(HttpMethod.GET, "/dummy-crud/43", new Fields());
	assertThat(matcher, matches(route));
	assertThat(route.getFields(), is(not(empty())));
	assertThat(route.getFields(), contains("id", "43"));
	
	route = new RouteImpl(HttpMethod.GET, "/dummy-crud/NaN", new Fields());
	assertThat(matcher, not(matches(route)));
}
 
开发者ID:bioko,项目名称:http-exposer,代码行数:17,代码来源:RouteMatcherImplTest.java


示例16: parseWithHeaders

import org.biokoframework.utils.fields.Fields; //导入依赖的package包/类
@Test
public void parseWithHeaders() throws Exception {
    Map<String, String > headersConversionMap = new HashMap<>();
    headersConversionMap.put("An-Header", "anHeader");

    fParser = new HttpRouteParserImpl(Collections.<IHttpFieldsParser>singleton(fMockFieldsParser), headersConversionMap);

    MockRequest request = new MockRequest(HttpMethod.GET.toString(), "/url");
    request.setHeader("An-Header", "aValue");

    IRoute route = fParser.getRoute(request);
    assertThat(route, is(notNullValue()));
    assertThat(route.getMethod(), is(equalTo(HttpMethod.GET)));
    assertThat(route.getPath(), is(equalTo("/url/")));
    assertThat(fMockFieldsParser.wasCalledParse(), is(false));
    assertThat(route.getFields(), is(equalTo(new Fields(
            "anHeader", "aValue"
    ))));
}
 
开发者ID:bioko,项目名称:http-exposer,代码行数:20,代码来源:HttpRouteParserImplTest.java


示例17: authenticate

import org.biokoframework.utils.fields.Fields; //导入依赖的package包/类
@Override
public AuthResponse authenticate(Fields fields, List<String> requiredRoles) throws AuthenticationFailureException {
	for (IAuthenticationService anAuthService : fAuthServices) {
		if (!(anAuthService instanceof AllAuthenticationService)) {
               try {
                   AuthResponse authResponse = anAuthService.authenticate(fields, requiredRoles);
                   if (authResponse != null) {
                       return authResponse;
                   }
               } catch (AuthenticationFailureException exception) {
                   Long errorCode = exception.getErrors().get(0).get(ErrorEntity.ERROR_CODE);
                   if (FieldNames.AUTHENTICATION_REQUIRED_CODE != errorCode) {
                       throw exception;
                   }
               }
		}
	}
	
	throw CommandExceptionsFactory.createUnauthorisedAccessException();
}
 
开发者ID:bioko,项目名称:system,代码行数:21,代码来源:AllAuthenticationService.java


示例18: headerTest

import org.biokoframework.utils.fields.Fields; //导入依赖的package包/类
@Test
public void headerTest() throws Exception {
    MockBuilder mockContentBuilder = new MockBuilder(null, null);
    HttpResponseBuilderImpl builder = new HttpResponseBuilderImpl(
            Collections.singletonMap("aField", "The-Header"),
            Collections.<IResponseContentBuilder>singleton(mockContentBuilder)
    );

    MockRequest httpRequest = new MockRequest("GET", "/something.json");
    MockResponse httpResponse = new MockResponse();

    Fields input = new Fields();
    Fields output = new Fields("aField", "hasAStringValue");

    builder.build(httpRequest, httpResponse, input, output);

    assertThat(httpResponse.getStatus(), is(200));
    assertThat(httpResponse.getHeader("The-Header"), is(equalTo("hasAStringValue")));
}
 
开发者ID:bioko,项目名称:http-exposer,代码行数:20,代码来源:HttpResponseBuilderTest.java


示例19: forcedContentTypeTest

import org.biokoframework.utils.fields.Fields; //导入依赖的package包/类
@Test
public void forcedContentTypeTest() throws Exception {
    MockBuilder mockContentBuilder = new MockBuilder(null, null);
    HttpResponseBuilderImpl builder = new HttpResponseBuilderImpl(
            Collections.<String, String>emptyMap(),
            Collections.<IResponseContentBuilder>singleton(mockContentBuilder)
    );

    MockRequest httpRequest = new MockRequest("GET", "/something.html");
    MockResponse httpResponse = new MockResponse();

    Fields input = new Fields();
    Fields output = new Fields(
            "mediaType", MediaType.JSON_UTF_8,
            "RESPONSE", new Fields("a", "value"));

    builder.build(httpRequest, httpResponse, input, output);

    assertThat(mockContentBuilder.fCapturedTypes, contains(MediaType.JSON_UTF_8));
}
 
开发者ID:bioko,项目名称:http-exposer,代码行数:21,代码来源:HttpResponseBuilderTest.java


示例20: testNestedBiokoException

import org.biokoframework.utils.fields.Fields; //导入依赖的package包/类
@Test
public void testNestedBiokoException() throws IOException {
	ExceptionResponseBuilderImpl builder = new ExceptionResponseBuilderImpl(fCodesMap);
	
	MockResponse mockResponse = new MockResponse();
	ErrorEntity error = new ErrorEntity();
	error.setAll(new Fields(
			ErrorEntity.ERROR_CODE, 12345,
			ErrorEntity.ERROR_MESSAGE, "Failed at life"));
	MockException mockException = new MockException(new CommandException(error));
	
	mockResponse = (MockResponse) builder.build(mockResponse, mockException, null, null);
	
	assertThat(mockResponse.getContentType(), is(equalTo(ContentType.APPLICATION_JSON.toString())));
	assertThat(mockResponse.getStatus(), is(equalTo(626)));
	assertThat(mockResponse, hasToString(
			matchesPattern("^.*An unexpected exception as been captured [\\w\\.\\$]+MockException .*Caused by [\\w\\.\\$]+CommandException.*$")));
	
}
 
开发者ID:bioko,项目名称:http-exposer,代码行数:20,代码来源:ExceptionResponseBuilderTest.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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