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


Java Fields类代码示例

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


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


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