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


Java Results类代码示例

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


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

示例1: publish

import br.com.caelum.vraptor.view.Results; //导入依赖的package包/类
@SimpleBrutauthRules({EnvironmentKarmaRule.class})
@EnvironmentAccessLevel(PermissionRules.MODERATE_EDITS)
   @Post
   public void publish(Long moderatableId, String moderatableType, Long aprovedInformationId,  String aprovedInformationType) {
   	Class<?> moderatableClass = urlMapping.getClassFor(moderatableType);
   	Information approved = informations.getById(aprovedInformationId, aprovedInformationType);
   	
       Moderatable moderatable = moderatables.getById(moderatableId, moderatableClass);
       List<Information> pending = informations.pendingFor(moderatableId, moderatableClass);
       
       if (!approved.isPending()) {
       	result.use(Results.http()).sendError(403);
       	return;
       }
       
       User approvedAuthor = approved.getAuthor();
       refusePending(aprovedInformationId, pending);
       currentUser.getCurrent().approve(moderatable, approved, environmentKarma);
       ReputationEvent editAppoved = new ReputationEvent(EventType.EDIT_APPROVED, moderatable.getQuestion(), approvedAuthor);
       int karma = calculator.karmaFor(editAppoved);
       approvedAuthor.increaseKarma(karma);
       reputationEvents.save(editAppoved);
       
       result.redirectTo(this).history();
   }
 
开发者ID:caelum,项目名称:mamute,代码行数:26,代码来源:HistoryController.java

示例2: delete

import br.com.caelum.vraptor.view.Results; //导入依赖的package包/类
@Delete
public void delete(Long commentId, String onWhat, Long postId) {
	Comment comment = comments.getById(commentId);
	if (!environment.supports("deletable.comments") || comment == null) {
		result.notFound();
		return;
	}
	if (!currentUser.isModerator() && !comment.hasAuthor(currentUser.getCurrent())) {
		result.use(http()).sendError(403);
		return;
	}
	Class<?> type = urlMapping.getClassFor(onWhat);
	org.mamute.model.Post post = comments.loadCommentable(type, postId);
	post.deleteComment(comment);
	comments.delete(comment);
	result.use(Results.referer()).redirect();
}
 
开发者ID:caelum,项目名称:mamute,代码行数:18,代码来源:CommentController.java

示例3: geraRelatorioHibernateCursor

import br.com.caelum.vraptor.view.Results; //导入依赖的package包/类
@Path("/hibernate-cursor")
public void geraRelatorioHibernateCursor() throws IOException{
	long antes = System.currentTimeMillis();
	ScrollableResults results = sessionFactory.openStatelessSession().createCriteria(Transacao.class).setMaxResults(QTD_REGISTROS).scroll();
	System.out.printf("Pesquisa feita em %dms%n", System.currentTimeMillis()-antes);
	PrintWriter writer = response.getWriter();
	SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
	int i=0;
	while(results.next()){
		if(i++%20000==0){
			System.out.println(i);
		}
		Transacao t = (Transacao) results.get()[0];
		writer.write(t.toFile(dateFormat)+"\n");
	}
	writer.close();
	result.use(Results.nothing());
	System.out.println(System.currentTimeMillis()-antes+" milisegundos");
}
 
开发者ID:tiarebalbi,项目名称:caelum-fj91-projeto,代码行数:20,代码来源:RelatorioDeTransacoesController.java

示例4: geraRelatorioHibernatePuro

import br.com.caelum.vraptor.view.Results; //导入依赖的package包/类
@Path("/hibernate-puro")
public void geraRelatorioHibernatePuro() throws IOException{
	long antes = System.currentTimeMillis();
	List<Transacao> list = session.createCriteria(Transacao.class).setMaxResults(200000).list();
	System.out.printf("Pesquisa feita em %dms%n", System.currentTimeMillis()-antes);
	PrintWriter writer = response.getWriter();
	SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
	int i=0;
	for (Transacao transacao : list) {
		if(i++%20000==0){
			System.out.println(i);
		}
		writer.write(transacao.toFile(dateFormat)+"\n");
	}
	writer.close();
	result.use(Results.nothing());
	System.out.println(System.currentTimeMillis()-antes+" milisegundos");
}
 
开发者ID:tiarebalbi,项目名称:caelum-fj91-projeto,代码行数:19,代码来源:RelatorioDeTransacoesController.java

示例5: options

import br.com.caelum.vraptor.view.Results; //导入依赖的package包/类
@Options
@Path(value = "/*")
public void options(@Observes VRaptorRequestStarted requestInfo) {
		
	Set<HttpMethod> allowed = router.allowedMethodsFor(requestInfo.getRequest().getRequestedUri());
	String allowMethods = allowed.toString().replaceAll("\\[|\\]", "");
	
	result.use(Results.status()).header("Allow", allowMethods);
	result.use(Results.status()).header("Access-Control-Allow-Methods", allowMethods);
	result.use(Results.status()).header("Access-Control-Allow-Headers", "Content-Type, X-Requested-With, accept, Authorization, origin");
}
 
开发者ID:pedro-hos,项目名称:aprendendo-vraptor,代码行数:12,代码来源:CORSController.java

示例6: success

import br.com.caelum.vraptor.view.Results; //导入依赖的package包/类
protected <T extends Serializable> void success(T data, String message) {
	this.result.use(Results.json())
		.withoutRoot()
		.from(new Response<T>(true, message, null, data))
		.recursive().serialize();
	this.result.nothing();
}
 
开发者ID:progolden,项目名称:vraptor-boilerplate,代码行数:8,代码来源:AbstractController.java

示例7: tryToVoteVotable

import br.com.caelum.vraptor.view.Results; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
private void tryToVoteVotable(Long id, VoteType voteType, Class votableType) {
	try {
	    Votable votable = votes.loadVotable(votableType, id);
	    Vote current = new Vote(currentUser.getCurrent(), voteType);
	    votingMachine.register(votable, current, votableType);
	    votes.save(current);
	    result.use(Results.json()).withoutRoot().from(votable.getVoteCount()).serialize();
	} catch (IllegalArgumentException e) {
	    result.use(Results.http()).sendError(409);
	    return;
       }
}
 
开发者ID:caelum,项目名称:mamute,代码行数:14,代码来源:VoteController.java

示例8: tryToRemoveVoteVotable

import br.com.caelum.vraptor.view.Results; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
	private void tryToRemoveVoteVotable(Long id, VoteType voteType, Class votableType) {
		try {
		    Votable votable = votes.loadVotable(votableType, id);
		    Vote current = new Vote(currentUser.getCurrent(), voteType);
		    votingMachine.unRegister(votable, current, votableType);
//		    votes.save(current);
		    result.use(Results.json()).withoutRoot().from(votable.getVoteCount()).serialize();
		} catch (IllegalArgumentException e) {
		    result.use(Results.http()).sendError(409);
		    return;
        }
	}
 
开发者ID:caelum,项目名称:mamute,代码行数:14,代码来源:VoteController.java

示例9: edit

import br.com.caelum.vraptor.view.Results; //导入依赖的package包/类
@Post
public void edit(Long id, MarkedText comment) {
	Comment original = comments.getById(id);
	if (!currentUser.getCurrent().isAuthorOf(original)) {
		result.use(Results.status()).badRequest("comment.edit.not_author");
		return;
	}
	if (validator.validate(comment.getPure())) {
		original.setComment(comment);
		comments.save(original);
		result.forwardTo(BrutalTemplatesController.class).comment(original);
	}
	validator.onErrorUse(Results.http()).setStatusCode(400);
}
 
开发者ID:caelum,项目名称:mamute,代码行数:15,代码来源:CommentController.java

示例10: markAsSolution

import br.com.caelum.vraptor.view.Results; //导入依赖的package包/类
@Post
public void markAsSolution(Long solutionId) {
	Answer solution = answers.getById(solutionId);
	Question question = solution.getMainThread();
       if (!currentUser.getCurrent().isAuthorOf(question)) {
		result.use(Results.status()).forbidden(bundle.getMessage("answer.error.not_autor"));
		result.redirectTo(QuestionController.class).showQuestion(question,
				question.getSluggedTitle());
		return;
	} 
       markOrRemoveSolution(solution);
       result.nothing();
}
 
开发者ID:caelum,项目名称:mamute,代码行数:14,代码来源:AnswerController.java

示例11: edit

import br.com.caelum.vraptor.view.Results; //导入依赖的package包/类
@Post
@CustomBrutauthRules(EditQuestionRule.class)
public void edit(@Load Question original, String title, MarkedText description, String tagNames,
		String comment, List<Long> attachmentsIds) {

	List<String> splitedTags = splitter.splitTags(tagNames);
	List<Tag> loadedTags = tagsManager.findOrCreate(splitedTags);
	validate(loadedTags, splitedTags);

	QuestionInformation information = new QuestionInformation(title, description, this.currentUser, loadedTags, comment);
	brutalValidator.validate(information);
	UpdateStatus status = original.updateWith(information, new Updater(environmentKarma));

	validator.onErrorUse(Results.page()).of(this.getClass()).questionEditForm(original);

	result.include("editComment", comment);
	result.include("question", original);

	questions.save(original);
	List<Attachment> attachmentsLoaded = attachments.load(attachmentsIds);
	original.removeAttachments();
	original.add(attachmentsLoaded);
	index.indexQuestion(original);

	result.include("mamuteMessages",
			Arrays.asList(messageFactory.build("confirmation", status.getMessage())));
	result.redirectTo(this).showQuestion(original, original.getSluggedTitle());
}
 
开发者ID:caelum,项目名称:mamute,代码行数:29,代码来源:QuestionController.java

示例12: newQuestion

import br.com.caelum.vraptor.view.Results; //导入依赖的package包/类
@Post
@CustomBrutauthRules({LoggedRule.class, InputRule.class})
public void newQuestion(String title, MarkedText description, String tagNames, boolean watching,
						List<Long> attachmentsIds) {
	List<Attachment> attachments = this.attachments.load(attachmentsIds);
	attachmentsValidator.validate(attachments);
	List<String> splitedTags = splitter.splitTags(tagNames);

	List<Tag> foundTags = tagsManager.findOrCreate(splitedTags);
	validate(foundTags, splitedTags);

	QuestionInformation information = new QuestionInformation(title, description, currentUser, foundTags, "new question");
	brutalValidator.validate(information);
	User author = currentUser.getCurrent();
	Question question = new Question(information, author);
	result.include("question", question);
	validator.onErrorUse(Results.page()).of(this.getClass()).questionForm();

	questions.save(question);
	index.indexQuestion(question);
	question.add(attachments);

	ReputationEvent reputationEvent = new ReputationEvent(EventType.CREATED_QUESTION, question, author);
	author.increaseKarma(reputationEvent.getKarmaReward());
	reputationEvents.save(reputationEvent);
	if (watching) {
		watchers.add(question, new Watcher(author));
	}

	questionCreated.fire(new QuestionCreated(question));
	result.include("mamuteMessages", asList(messageFactory.build("alert", "question.quality_reminder")));
	result.redirectTo(this).showQuestion(question, question.getSluggedTitle());
}
 
开发者ID:caelum,项目名称:mamute,代码行数:34,代码来源:QuestionController.java

示例13: handle

import br.com.caelum.vraptor.view.Results; //导入依赖的package包/类
@Override
public void handle() {
	if("application/json".equals(req.getHeader("Accept"))){
		result.use(Results.http()).body(bundle.getMessage("error.requires_login")).sendError(403);			
	}else{
		result.include("loginRequiredMessages", asList(messageFactory.build("alert", "auth.access.denied")));
		String redirectUrl = req.getRequestURL().toString();
		result.redirectTo(AuthController.class).loginForm(redirectUrl);
	}
}
 
开发者ID:caelum,项目名称:mamute,代码行数:11,代码来源:LoggedHandler.java

示例14: geraRelatorioJdbc

import br.com.caelum.vraptor.view.Results; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Path("/jdbc")
public void geraRelatorioJdbc() throws IOException, SQLException{
	long antes = System.currentTimeMillis();
	Connection connection = session.connection();
	PreparedStatement statement = connection.prepareStatement("select * from Transacao limit 0,200000");
	ResultSet set = statement.executeQuery();
	System.out.printf("Pesquisa feita em %dms%n", System.currentTimeMillis()-antes);
	PrintWriter writer = response.getWriter();
	SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
	int i=0;
	while(set.next()){
		if(i++%20000==0){
			System.out.println(i);
		}
		Transacao t = new Transacao();
		t.setId(set.getLong(1));
		Calendar instance = Calendar.getInstance();
		instance.setTimeInMillis(set.getDate(2).getTime());
		t.setData(instance);
		t.setTipoDeTransacao(Tipo.values()[set.getInt(3)]);
		t.setValor(new BigDecimal(set.getDouble(4)));
		writer.write(t.toFile(dateFormat)+"\n");
	}
	writer.close();
	result.use(Results.nothing());
	System.out.println(System.currentTimeMillis()-antes+" milisegundos");
}
 
开发者ID:tiarebalbi,项目名称:caelum-fj91-projeto,代码行数:29,代码来源:RelatorioDeTransacoesController.java

示例15: forward

import br.com.caelum.vraptor.view.Results; //导入依赖的package包/类
public void forward(@Observes RequestSucceded event) {
	if (result.used() || event.getResponse().isCommitted()) {
		logger.debug("Request already dispatched and commited somewhere else, not forwarding.");
		return;
	}
	
	logger.debug("forwarding to the dafault page for this logic");
	result.use(Results.page()).defaultView();
}
 
开发者ID:caelum,项目名称:vraptor4,代码行数:10,代码来源:ForwardToDefaultView.java


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