olha que coisa estranha :
init:
undeploy-clean:
deps-clean:
do-clean:
Deleting directory /home/junior/vraptor-mydvds-3.1.0/build
check-clean:
clean:
init:
deps-module-jar:
deps-ear-jar:
deps-jar:
Created dir: /home/junior/vraptor-mydvds-3.1.0/build/web/WEB-INF/classes
Copying 10 files to /home/junior/vraptor-mydvds-3.1.0/build/web
Copying 60 files to /home/junior/vraptor-mydvds-3.1.0/build/web/WEB-INF
library-inclusion-in-archive:
Copying 1 file to /home/junior/vraptor-mydvds-3.1.0/build/web/WEB-INF/lib
Copying 1 file to /home/junior/vraptor-mydvds-3.1.0/build/web/WEB-INF/lib
Copying 1 file to /home/junior/vraptor-mydvds-3.1.0/build/web/WEB-INF/lib
Copying 1 file to /home/junior/vraptor-mydvds-3.1.0/build/web/WEB-INF/lib
Copying 1 file to /home/junior/vraptor-mydvds-3.1.0/build/web/WEB-INF/lib
Copying 1 file to /home/junior/vraptor-mydvds-3.1.0/build/web/WEB-INF/lib
Copying 1 file to /home/junior/vraptor-mydvds-3.1.0/build/web/WEB-INF/lib
Copying 1 file to /home/junior/vraptor-mydvds-3.1.0/build/web/WEB-INF/lib
Copying 1 file to /home/junior/vraptor-mydvds-3.1.0/build/web/WEB-INF/lib
Copying 1 file to /home/junior/vraptor-mydvds-3.1.0/build/web/WEB-INF/lib
Copying 1 file to /home/junior/vraptor-mydvds-3.1.0/build/web/WEB-INF/lib
Copying 1 file to /home/junior/vraptor-mydvds-3.1.0/build/web/WEB-INF/lib
Copying 1 file to /home/junior/vraptor-mydvds-3.1.0/build/web/WEB-INF/lib
Copying 1 file to /home/junior/vraptor-mydvds-3.1.0/build/web/WEB-INF/lib
Copying 1 file to /home/junior/vraptor-mydvds-3.1.0/build/web/WEB-INF/lib
library-inclusion-in-manifest:
Created dir: /home/junior/vraptor-mydvds-3.1.0/build/empty
Compiling 18 source files to /home/junior/vraptor-mydvds-3.1.0/build/web/WEB-INF/classes
/home/junior/vraptor-mydvds-3.1.0/src/br/com/caelum/vraptor/mydvds/controller/DvdsController.java:52: cannot find symbol
symbol : method onErrorUsuario(java.lang.Class<capture#734 of ? extends br.com.caelum.vraptor.view.PageResult>)
location: interface br.com.caelum.vraptor.Validator
validator.onErrorUsuario(Results.page()).of(UsuarioController.class).home();
^
/home/junior/vraptor-mydvds-3.1.0/src/br/com/caelum/vraptor/mydvds/controller/DvdsController.java:67: cannot find symbol
symbol : method usuario(java.lang.Class<br.com.caelum.vraptor.view.LogicResult>)
location: interface br.com.caelum.vraptor.Result
result.usuario(Results.logic()).redirectTo(UsuarioController.class).home();
^
/home/junior/vraptor-mydvds-3.1.0/src/br/com/caelum/vraptor/mydvds/controller/HomeController.java:48: cannot find symbol
symbol : method onErrorUsuario(java.lang.Class<capture#201 of ? extends br.com.caelum.vraptor.view.PageResult>)
location: interface br.com.caelum.vraptor.Validator
validator.onErrorUsuario(Results.page()).of(HomeController.class).login();
^
/home/junior/vraptor-mydvds-3.1.0/src/br/com/caelum/vraptor/mydvds/controller/HomeController.java:53: cannot find symbol
symbol : method usuario(java.lang.Class<br.com.caelum.vraptor.view.LogicResult>)
location: interface br.com.caelum.vraptor.Result
result.usuario(Results.logic()).redirectTo(UsuarioController.class).home();
^
/home/junior/vraptor-mydvds-3.1.0/src/br/com/caelum/vraptor/mydvds/controller/HomeController.java:59: cannot find symbol
symbol : method usuario(java.lang.Class<br.com.caelum.vraptor.view.LogicResult>)
location: interface br.com.caelum.vraptor.Result
result.usuario(Results.logic()).redirectTo(HomeController.class).login();
^
/home/junior/vraptor-mydvds-3.1.0/src/br/com/caelum/vraptor/mydvds/interceptor/AuthorizationInterceptor.java:58: cannot find symbol
symbol : method usuario(java.lang.Class<br.com.caelum.vraptor.view.LogicResult>)
location: interface br.com.caelum.vraptor.Result
result.usuario(logic()).redirectTo(HomeController.class).login();
^
6 errors
/home/junior/vraptor-mydvds-3.1.0/nbproject/build-impl.xml:405: The following error occurred while executing this line:
/home/junior/vraptor-mydvds-3.1.0/nbproject/build-impl.xml:228: Compile failed; see the compiler error output for details.
FALHA NA CONSTRUÇÃO (tempo total: 4 segundos)
package br.com.caelum.vraptor.mydvds.controller;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import br.com.caelum.vraptor.Get;
import br.com.caelum.vraptor.Post;
import br.com.caelum.vraptor.Resource;
import br.com.caelum.vraptor.Result;
import br.com.caelum.vraptor.Validator;
import br.com.caelum.vraptor.ioc.ComponentFactory;
import br.com.caelum.vraptor.mydvds.dao.DefaultUsuarioDao;
import br.com.caelum.vraptor.mydvds.dao.UsuarioDao;
import br.com.caelum.vraptor.mydvds.interceptor.UsuarioInfo;
import br.com.caelum.vraptor.mydvds.model.Usuario;
import br.com.caelum.vraptor.validator.Validations;
import br.com.caelum.vraptor.view.Results;
@Resource
public class HomeController {
private final Result result;
private final Validator validator;
private final UsuarioInfo usuarioInfo;
private final UsuarioDao dao;
public HomeController(UsuarioDao dao, UsuarioInfo usuarioInfo, Result result, Validator validator) {
this.dao = dao;
this.result = result;
this.validator = validator;
this.usuarioInfo = usuarioInfo;
}
@Post
public void login(String login, String password) {
// search for the usuario in the database
final Usuario currentUsuario = dao.find(login, password);
validator.checking(new Validations() {{
that(currentUsuario, is(notNullValue()), "login", "invalid_login_or_password");
}});
validator.onErrorUsuario(Results.page()).of(HomeController.class).login();
// the login was valid, add usuario to session
usuarioInfo.login(currentUsuario);
result.usuario(Results.logic()).redirectTo(UsuarioController.class).home();
}
public void logout() {
usuarioInfo.logout();
// after logging out, we want to be redirected to home index.
result.usuario(Results.logic()).redirectTo(HomeController.class).login();
}
@Get
public void login() {
}
}
package br.com.caelum.vraptor.mydvds.controller;
import static br.com.caelum.vraptor.mydvds.validation.CustomMatchers.notEmpty;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import org.apache.log4j.Logger;
import br.com.caelum.vraptor.Get;
import br.com.caelum.vraptor.Path;
import br.com.caelum.vraptor.Post;
import br.com.caelum.vraptor.Resource;
import br.com.caelum.vraptor.Result;
import br.com.caelum.vraptor.Validator;
import br.com.caelum.vraptor.interceptor.multipart.UploadedFile;
import br.com.caelum.vraptor.mydvds.dao.DvdDao;
import br.com.caelum.vraptor.mydvds.interceptor.UsuarioInfo;
import br.com.caelum.vraptor.mydvds.model.Dvd;
import br.com.caelum.vraptor.mydvds.model.DvdRental;
import br.com.caelum.vraptor.validator.Validations;
import br.com.caelum.vraptor.view.Results;
@Resource
public class DvdsController {
private static final Logger LOG = Logger.getLogger(DvdsController.class);
private final Result result;
private final Validator validator;
private final UsuarioInfo usuarioInfo;
private final DvdDao dao;
public DvdsController(DvdDao dao, UsuarioInfo usuarioInfo, Result result, Validator validator) {
this.dao = dao;
this.result = result;
this.validator = validator;
this.usuarioInfo = usuarioInfo;
}
@Path("/dvds")
@Post
public void add(final Dvd dvd, UploadedFile file) {
validator.checking(new Validations() {{
that(dvd.getTitle(), is(notEmpty()), "login", "invalid_title");
that(dvd.getType(), is(notNullValue()), "name", "invalid_type");
that(dvd.getDescription(), is(notEmpty()), "description", "invalid_description");
that(dvd.getDescription().length() >= 6, "description", "invalid_description");
}});
validator.onErrorUsuario(Results.page()).of(UsuarioController.class).home();
// is there a file?
if (file != null) {
// usually we would save the file, in this case, we just log :)
LOG.info("Uploaded file: " + file.getFileName());
}
dao.add(dvd);
dao.add(new DvdRental(usuarioInfo.getUsuario(), dvd));
// you can add objects to result even in redirects. Added objects will
// survive one more request when redirecting.
result.include("notice", dvd.getTitle() + " dvd added");
result.usuario(Results.logic()).redirectTo(UsuarioController.class).home();
}
@Path("/dvds/{dvd.id}")
@Get
public void show(Dvd dvd) {
result.include("dvd", dvd);
}
@Path("/dvds/search")
@Get
public void search(Dvd dvd) {
if (dvd.getTitle() == null) {
dvd.setTitle("");
}
result.include("dvds", this.dao.searchSimilarTitle(dvd.getTitle()));
}
}
package br.com.caelum.vraptor.mydvds.interceptor;
import static br.com.caelum.vraptor.view.Results.logic;
import java.lang.reflect.Method;
import java.util.Arrays;
import br.com.caelum.vraptor.InterceptionException;
import br.com.caelum.vraptor.Intercepts;
import br.com.caelum.vraptor.Result;
import br.com.caelum.vraptor.core.InterceptorStack;
import br.com.caelum.vraptor.interceptor.Interceptor;
import br.com.caelum.vraptor.mydvds.controller.HomeController;
import br.com.caelum.vraptor.mydvds.controller.UsuarioController;
import br.com.caelum.vraptor.mydvds.dao.UsuarioDao;
import br.com.caelum.vraptor.resource.ResourceMethod;
import br.com.caelum.vraptor.validator.ValidationMessage;
@Intercepts
public class AuthorizationInterceptor implements Interceptor {
private final UsuarioInfo info;
private final UsuarioDao dao;
private final Result result;
public AuthorizationInterceptor(UsuarioInfo info, UsuarioDao dao, Result result) {
this.info = info;
this.dao = dao;
this.result = result;
}
@Override
public boolean accepts(ResourceMethod method) {
return notLogin(method) && notNewusuario(method);
}
private boolean notNewusuario(ResourceMethod method) {
Method invokedMethod = method.getMethod();
if (invokedMethod.getDeclaringClass().equals(UsuarioController.class)) {
return !"add".equals(invokedMethod.getName()) && !"usuarioAdded".equals(invokedMethod.getName());
}
return true;
}
private boolean notLogin(ResourceMethod method) {
return !method.getMethod().getDeclaringClass().equals(HomeController.class);
}
@Override
public void intercept(InterceptorStack stack, ResourceMethod method, Object resourceInstance)
throws InterceptionException {
if (info.getUsuario() == null) {
result.include("errors", Arrays.asList(new ValidationMessage("usuario is not logged in", "usuario")));
result.usuario(logic()).redirectTo(HomeController.class).login();
} else {
dao.refresh(info.getUsuario());
// continues execution
stack.next(method, resourceInstance);
}
}
}