br.com.caelum.vraptor.Get Java Examples

The following examples show how to use br.com.caelum.vraptor.Get. 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 File: ListController.java    From mamute with Apache License 2.0 6 votes vote down vote up
@Get
public void withTag(String tagName, Integer p, boolean semRespostas) {
	Integer page = getPage(p);
	Tag tag = tags.findByName(tagName);
	if(tag == null){
		result.notFound();
		return;
	}
	List<Question> questionsWithTag = questions.withTagVisible(tag, page, semRespostas);
	result.include("totalPages", questions.numberOfPages(tag));
	result.include("tag", tag);
	result.include("recentTags", recentTagsContainer.getRecentTagsUsage());
	result.include("questions", questionsWithTag);
	result.include("currentPage", page);
	result.include("hasAbout", tags.hasAbout(tag));
	if (semRespostas) {
		result.include("unansweredActive", true);
		result.include("noDefaultActive", true);
		result.include("unansweredTagLinks", true);
	}
}
 
Example #2
Source File: AuthController.java    From mamute with Apache License 2.0 6 votes vote down vote up
@Public
@Get
public void loginForm(String redirectUrl) {
	if (loggedUser.isLoggedIn()) {
		result.include("loginRequiredMessages", Collections.emptyList());
		redirectToRightUrl(redirectUrl);
	} else {
		String facebookUrl = facebook.getOauthUrl(redirectUrl);
		String googleUrl = google.getOauthUrl(redirectUrl);
		if (redirectUrl != null && !redirectUrl.isEmpty()) {
			include("redirectUrl", redirectUrl);
		}
		result.include("facebookUrl", facebookUrl);
		result.include("googleUrl", googleUrl);
	}
}
 
Example #3
Source File: FacebookAuthController.java    From mamute with Apache License 2.0 6 votes vote down vote up
@Get("/sign-up/facebook/")
public void signupViaFacebook(String code, String state) {
	if (code == null) {
		includeAsList("mamuteMessages", i18n("error", "error.signup.facebook.unknown"));
		redirectTo(SignupController.class).signupForm();
		return;
	}
	
	Token token = service.getAccessToken(null, new Verifier(code));
	
	SocialAPI facebookAPI = new FacebookAPI(service, token);
	
	boolean success = loginManager.merge(MethodType.FACEBOOK, facebookAPI);
	if(!success) {
		includeAsList("mamuteMessages", i18n("error", "signup.errors.facebook.invalid_email", state));
		result.redirectTo(AuthController.class).loginForm(state);
		return;
	}
	redirectToRightUrl(state);
}
 
Example #4
Source File: RankingController.java    From mamute with Apache License 2.0 6 votes vote down vote up
@Get
public void tagRank(String tagName){
	Tag tag = tags.findByName(tagName);
	if (tag == null){
		result.notFound();
	}
	result.include("tag", tag);
	DateTime after = new DateTime().minusDays(30);
	result.include("tag", tag);
	result.include("answerersAllTime", reputationEvents.getTopAnswerersSummaryAllTime(tag));
	result.include("answerersLastMonth", reputationEvents.getTopAnswerersSummaryAfter(tag, after));
	result.include("askersAllTime", reputationEvents.getTopAskersSummaryAllTime(tag));
	result.include("askersLastMonth", reputationEvents.getTopAskersSummaryAfter(tag, after));
	result.include("usersActive", true);
	result.include("noDefaultActive", true);
}
 
Example #5
Source File: NewsController.java    From mamute with Apache License 2.0 6 votes vote down vote up
@Get
public void showNews(@Load News news, String sluggedTitle) {
	User current = currentUser.getCurrent();
	news.checkVisibilityFor(currentUser);
	redirectToRightUrl(news, sluggedTitle);
	viewCounter.ping(news);
	boolean isWatching = watchers.ping(news, current);
	
	result.include("commentsWithVotes", votes.previousVotesForComments(news, current));
	result.include("currentVote", votes.previousVoteFor(news.getId(), current, News.class));
	result.include("news", news);
	result.include("isWatching", isWatching);
	result.include("userMediumPhoto", true);
	result.include("newsActive", true);
	result.include("noDefaultActive", true);
}
 
Example #6
Source File: ListController.java    From mamute with Apache License 2.0 6 votes vote down vote up
@Get
public void home(Integer p) {
	Integer page = getPage(p);
	List<Question> visible = questions.allVisible(page);
	if (visible.isEmpty() && page != 1) {
		result.notFound();
		return;
	}
	List<String> tabs = asList("voted", "answered", "viewed");
	result.include("tabs", tabs);

	result.include("questions", visible);
	result.include("totalPages", questions.numberOfPages());
	result.include("currentPage", page);
	result.include("currentUser", loggedUser);

}
 
Example #7
Source File: NewsController.java    From mamute with Apache License 2.0 5 votes vote down vote up
@Get
@CustomBrutauthRules(EditNewsRule.class)
public void newsEditForm(@Load News news) {
	result.include("news", news);
	result.include("newsActive", true);
	result.include("noDefaultActive", true);
}
 
Example #8
Source File: ListController.java    From mamute with Apache License 2.0 5 votes vote down vote up
@Get
public void unanswered(Integer p) {
	Integer page = getPage(p);
	result.include("questions", questions.unanswered(page));
	result.include("recentTags", recentTagsContainer.getRecentTagsUsage());
	result.include("currentPage", page);
	result.include("totalPages", questions.totalPagesWithoutAnswers());
	result.include("unansweredActive", true);
	result.include("noDefaultActive", true);
}
 
Example #9
Source File: ListController.java    From mamute with Apache License 2.0 5 votes vote down vote up
@Get
public void unsolved(Integer p) {
	Integer page = getPage(p);
	result.include("questions", questions.unsolvedVisible(page));
	result.include("recentTags", recentTagsContainer.getRecentTagsUsage());
	result.include("currentPage", page);
	result.include("totalPages", questions.totalPagesUnsolvedVisible());
}
 
Example #10
Source File: ListController.java    From mamute with Apache License 2.0 5 votes vote down vote up
@Get
public void news(Integer p) {
	Integer page = getPage(p);
	List<News> visible = newses.allVisible(page, 25);
	if (visible.isEmpty() && page != 1) {
		result.notFound();
		return;
	}
	result.include("newses", visible);
	result.include("totalPages", newses.numberOfPages(25));
	result.include("currentPage", page);
	result.include("newsActive", true);
	result.include("noDefaultActive", true);
}
 
Example #11
Source File: TagPageController.java    From mamute with Apache License 2.0 5 votes vote down vote up
@Get
@CustomBrutauthRules(ModeratorOnlyRule.class)
public void tagPageForm(String tagName){
	if(validator.validateCreationWithTag(tagName)){
		result.include("tag", tags.findByName(tagName));
	}
}
 
Example #12
Source File: RssController.java    From mamute with Apache License 2.0 5 votes vote down vote up
@Get
public void rss() throws IOException {
	List<RssContent> orderedByDate = questions.orderedByCreationDate(MAX_RESULTS);
	String title = bundle.getMessage("questions.rss.title", bundle.getMessage("site.name"));
	String description = bundle.getMessage("questions.rss.description", bundle.getMessage("site.name"));
	buildRss(orderedByDate, title, description);
}
 
Example #13
Source File: TelefoneController.java    From aprendendo-vraptor with Apache License 2.0 5 votes vote down vote up
@Get
@Path(value = { "/tipo", "/tipo/" })
public void tipos() {
	result.use(json())
		  .withoutRoot()
		  .from(TipoTelefone.values())
		  .serialize();
}
 
Example #14
Source File: ContatoController.java    From aprendendo-vraptor with Apache License 2.0 5 votes vote down vote up
@Get
@Path(value = {"/", ""})
public void todos() {
	result.use(json())
		  .withoutRoot()
		  .from(contatos.todosAtivos())
		  .include("telefones")
		  .serialize();
}
 
Example #15
Source File: ForgotPasswordController.java    From mamute with Apache License 2.0 5 votes vote down vote up
@Get
public void changePasswordForm(Long id, String token) {
	validateTokenAndGetUser(id, token);
	
	result.include("id", id);
	result.include("token", token);
}
 
Example #16
Source File: HistoryController.java    From mamute with Apache License 2.0 5 votes vote down vote up
@Get
public void questionHistory(Long questionId) {
	result.include("histories", informations.historyForQuestion(questionId));
	result.include("post", moderatables.getById(questionId, Question.class));
	result.include("userMediumPhoto", true);
	result.include("isHistoryQuestion", true);
}
 
Example #17
Source File: GoogleAuthController.java    From mamute with Apache License 2.0 5 votes vote down vote up
@Get("/sign-up/google/")
public void signUpViaGoogle(String state, String code) {
	Token token = service.getAccessToken(null, new Verifier(code));
	SocialAPI googleAPI = new GoogleAPI(token, service);
    
	loginManager.merge(MethodType.GOOGLE, googleAPI);
	
    redirectToRightUrl(state);
}
 
Example #18
Source File: FlagController.java    From mamute with Apache License 2.0 5 votes vote down vote up
@CustomBrutauthRules(ModeratorOnlyRule.class)
@Get
public void topFlagged() {
	List<FlaggableAndFlagCount> flaggedQuestions = flaggables.flaggedButVisible(Question.class);
	List<FlaggableAndFlagCount> flaggedAnswers = flaggables.flaggedButVisible(Answer.class);
	List<FlaggableAndFlagCount> flaggedComments = flaggables.flaggedButVisible(Comment.class);
	
	List<Question> commentQuestions = new ArrayList<>();

	Iterator<FlaggableAndFlagCount> iterator = flaggedComments.iterator();
	while (iterator.hasNext()) {
		Comment comment = (Comment) iterator.next().getFlaggable();
		Question q = questions.fromCommentId(comment.getId());
		if (q != null) {
			commentQuestions.add(q);
			continue;
		}
		Answer answerFromComment = answers.fromCommentId(comment.getId());
		if (answerFromComment != null) {
			commentQuestions.add(answerFromComment.getQuestion());
			continue;
		}
		// some flags may be related to news (not questions nor answers)
		iterator.remove();
	}


	result.include("questions", flaggedQuestions);
	result.include("answers", flaggedAnswers);
	result.include("comments", flaggedComments);
	result.include("commentQuestions", commentQuestions);
}
 
Example #19
Source File: ContatoController.java    From aprendendo-vraptor with Apache License 2.0 5 votes vote down vote up
@Get
@Path(value = "/tipo")
public void tipos() {
	result.use(json())
		  .withoutRoot()
		  .from(TipoContato.values())
		  .serialize();
}
 
Example #20
Source File: RssController.java    From mamute with Apache License 2.0 5 votes vote down vote up
@Get
public void rssByTag(String tagName) throws IOException {
	Tag tag = tags.findByName(tagName);
	if (tag == null) {
		result.notFound();
		return;
	}
	
	List<RssContent> orderedByDate = questions.orderedByCreationDate(MAX_RESULTS, tag);
	String title = bundle.getMessage("questions.rss.title", bundle.getMessage("site.name"));
	String description = bundle.getMessage("questions.rss.description", bundle.getMessage("site.name"));
	buildRss(orderedByDate, title, description);
}
 
Example #21
Source File: RssController.java    From mamute with Apache License 2.0 5 votes vote down vote up
@Get
public void newsRss() throws IOException {
	List<RssContent> orderedByDate = news.orderedByCreationDate(MAX_RESULTS);
	String title = bundle.getMessage("news.rss.title", bundle.getMessage("site.name"));
	String description = bundle.getMessage("news.rss.description", bundle.getMessage("site.name"));
	buildRss(orderedByDate, title, description);
}
 
Example #22
Source File: SignupController.java    From mamute with Apache License 2.0 5 votes vote down vote up
@Get
public void signupForm() {
	checkSignup();

	result.include("facebookUrl", facebook.getOauthUrl(null));
	result.include("googleUrl", google.getOauthUrl(null));
}
 
Example #23
Source File: TelefoneController.java    From aprendendo-vraptor with Apache License 2.0 5 votes vote down vote up
@Get
@Path(value = { "/tipo", "/tipo/" })
public void tipos() {
	result.use(json())
		  .withoutRoot()
		  .from(TipoTelefone.values())
		  .serialize();
}
 
Example #24
Source File: ContatoController.java    From aprendendo-vraptor with Apache License 2.0 5 votes vote down vote up
@Get
@Path(value = "/tipo")
public void tipos() {
	result.use(json())
		  .withoutRoot()
		  .from(TipoContato.values())
		  .serialize();
}
 
Example #25
Source File: ContatoController.java    From aprendendo-vraptor with Apache License 2.0 5 votes vote down vote up
@Get
@Path(value = {"/", ""})
public void todos() {
	result.use(json())
		  .withoutRoot()
		  .from(contatos.todosAtivos())
		  .include("telefones")
		  .serialize();
}
 
Example #26
Source File: UpdateOccurrenceController.java    From hurraa with GNU General Public License v2.0 5 votes vote down vote up
@Get
@Path("/{occurrenceId}")
public void form(Long occurrenceId){
	Occurrence occurrence = occurrenceBean.findById(occurrenceId);
	if(occurrence != null){
	    result.include("problemTypes", problemTypeBean.findAll());
		result.include("sectors", sectorBean.findAll());
		result.include("occurrenceStates" , occurrenceStateBean.findAll() );
		result.include("occurrence", occurrence);
	}
}
 
Example #27
Source File: OpenOccurrenceController.java    From hurraa with GNU General Public License v2.0 5 votes vote down vote up
@Get
@Path("/")
public void form() {
	result.include("problemTypes", problemTypeBean.findAll());
	result.include("sectors", sectorBean.findAll());
	result.include("occurrenceStates" , occurrenceStateBean.findAll() );
}
 
Example #28
Source File: PostController.java    From tutorials with MIT License 5 votes vote down vote up
@Get("/post/add")
public void addForm() {

    if(Objects.isNull(userInfo.getUser())) {
        result.include("error", "Please Login to Proceed");
        result.redirectTo(AuthController.class).loginForm();
        return;
    }

    result.use(FreemarkerView.class).withTemplate("posts/add");
}
 
Example #29
Source File: MusicController.java    From vraptor4 with Apache License 2.0 5 votes vote down vote up
@Path("/musics/download/{m.id}")
@Get
public Download download(Music m) throws FileNotFoundException {
	Music music = musicDao.load(m);
	File file = musics.getFile(music);
	String contentType = "audio/mpeg";
	String filename = music.getTitle() + ".mp3";

	return new FileDownload(file, contentType, filename);
}
 
Example #30
Source File: DefaultLogicResult.java    From vraptor4 with Apache License 2.0 5 votes vote down vote up
protected boolean acceptsHttpGet(Method method) {
	if (method.isAnnotationPresent(Get.class)) {
		return true;
	}

	for (HttpMethod httpMethod : HttpMethod.values()) {
		if (method.isAnnotationPresent(httpMethod.getAnnotation())) {
			return false;
		}
	}

	return true;
}