diff --git a/main/java/com/PetStop/PetStopApplication.java b/main/java/com/PetStop/PetStopApplication.java new file mode 100644 index 0000000..454f9c3 --- /dev/null +++ b/main/java/com/PetStop/PetStopApplication.java @@ -0,0 +1,65 @@ +package com.PetStop; + +import java.util.HashSet; +import java.util.Set; + +import javax.sql.DataSource; +import javax.transaction.Transactional; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.CommandLineRunner; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.domain.EntityScan; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; + +import com.PetStop.model.Pet; +import com.PetStop.model.User; +import com.PetStop.repository.PetRepository; +import com.PetStop.repository.UserRepository; + +@SpringBootApplication +@EntityScan(basePackages="com.PetStop.*") +@EnableJpaRepositories +public class PetStopApplication {//implements CommandLineRunner { + + /*@Autowired + DataSource dataSource; + @Autowired + PetRepository petRepository; + @Autowired + UserRepository userRepository; +*/ + static final Logger logger = LoggerFactory.getLogger(PetStopApplication.class); + public static void main(String[] args) { + SpringApplication.run(PetStopApplication.class, "1", "geetham"); + } + /*@Transactional + @Override + public void run(String... args) throws Exception { + // TODO Auto-generated method stub + User user1 = new User(18,"var1","varsh"); + userRepository.save(user1); + Set petss = new HashSet(); + Pet pp = new Pet(144,"juli",9,"sg"); + petss.add(pp); + pp.setUser(user1); + petRepository.save(pp); + System.out.println("mapped two tables successfully"); + + Pageable pageable = PageRequest.of(0, 4); + Page pets = petRepository.findAll(pageable); + //System.out.println(pets); + + for(Pet p:pets){ + System.out.println(p.getPetId()+" "+p.getPetName()+" "+p.getPetAge()+" "+p.getPetPlace()); + } + System.out.println("finished"); + +}*/ +} diff --git a/main/java/com/PetStop/SecurityConfiguration/UserSecurityConfig.java b/main/java/com/PetStop/SecurityConfiguration/UserSecurityConfig.java new file mode 100644 index 0000000..fbfd1f9 --- /dev/null +++ b/main/java/com/PetStop/SecurityConfiguration/UserSecurityConfig.java @@ -0,0 +1,48 @@ +package com.PetStop.SecurityConfiguration; +import java.util.List; + +import javax.sql.DataSource; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.builders.WebSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; + +import com.PetStop.model.User; +import com.PetStop.repository.UserRepository; + +@Configuration +@EnableWebSecurity +public class UserSecurityConfig extends WebSecurityConfigurerAdapter{ + @Autowired + DataSource dataSource; + @Autowired + UserRepository userRepository; + + //Enable jdbc authentication + @Autowired + public void configAuthentication(AuthenticationManagerBuilder auth) throws Exception { + System.out.println("inside auth method"); + List u = userRepository.findAll(); + for(User us:u){ + System.out.println(us.getUserName()+" "+us.getPassword()+" "+us.getOwnerId()); + } + System.out.println("THANKYOU"); + auth.jdbcAuthentication().dataSource(dataSource); + } + + @Override + public void configure(WebSecurity web) throws Exception { + web.ignoring().antMatchers("/resources/**"); + } + + @Override + protected void configure(HttpSecurity http) throws Exception { + http.authorizeRequests().antMatchers("/").permitAll(); + http.csrf().disable(); + + } +} diff --git a/main/java/com/PetStop/ServletInitializer.java b/main/java/com/PetStop/ServletInitializer.java new file mode 100644 index 0000000..500304a --- /dev/null +++ b/main/java/com/PetStop/ServletInitializer.java @@ -0,0 +1,13 @@ +package com.PetStop; + +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; + +public class ServletInitializer extends SpringBootServletInitializer { + + @Override + protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { + return application.sources(PetStopApplication.class); + } + +} diff --git a/main/java/com/PetStop/controller/LoginController.java b/main/java/com/PetStop/controller/LoginController.java new file mode 100644 index 0000000..8bb9a75 --- /dev/null +++ b/main/java/com/PetStop/controller/LoginController.java @@ -0,0 +1,99 @@ +package com.PetStop.controller; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.ui.ModelMap; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.SessionAttributes; +import org.springframework.web.servlet.ModelAndView; + +import com.PetStop.model.User; +import com.PetStop.service.UserService; +import com.PetStop.validation.UserValidator; +@Controller +@Scope("request") +@SessionAttributes("sessionuser") +public class LoginController { + + + /*@Autowired + + private User user;*/ + + @Autowired + + private UserService userService; + + @Autowired + + private UserValidator userValidator; + + + + @RequestMapping(value = "/login", method = RequestMethod.GET) + public String init(Model model ) { + //model.addAttribute("user",new User()); + return "login"; + } + + @RequestMapping(value="/receivevalues", method = RequestMethod.POST) + public ModelAndView submit(Model model,@ModelAttribute("user") User user,HttpSession session) { + User u = userService.searchByUserNameAndPassword(user.getUserName(),user.getPassword()); + System.out.println(u); + + if(u==null) + { + System.out.println("Invalid user"); + model.addAttribute("error", "Invalid Details"); + return new ModelAndView("redirect:/login"); + } + else{ + System.out.println("valid user"); + model.addAttribute("msg","Welcome "+u.getUserName()); + session.setAttribute("sessionuser", u); + return new ModelAndView("redirect:/pet/home"); + } + } + + @GetMapping("/registration") + + public ModelAndView registration(Model model) + + { + + return new ModelAndView("registration","userForm",new User()); + + } + + + + @PostMapping("/registration") + + public String registration(@ModelAttribute("userForm") User userForm, BindingResult bindingResult,Model model) { + + userValidator.validate(userForm, bindingResult); + + if (bindingResult.hasErrors()) { + + return "registration"; + + } + + userService.save(userForm); + + model.addAttribute("user",userForm.getUserName()); + + return "successfullreg"; + + } +} diff --git a/main/java/com/PetStop/controller/PetsAppController.java b/main/java/com/PetStop/controller/PetsAppController.java new file mode 100644 index 0000000..69ac8b3 --- /dev/null +++ b/main/java/com/PetStop/controller/PetsAppController.java @@ -0,0 +1,115 @@ +package com.PetStop.controller; + +import java.util.List; +import java.util.Optional; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; +import javax.sql.DataSource; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.support.PagedListHolder; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.ServletRequestBindingException; +import org.springframework.web.bind.ServletRequestUtils; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.SessionAttributes; +import org.springframework.web.servlet.ModelAndView; + +import com.PetStop.model.Pet; +import com.PetStop.model.User; +import com.PetStop.service.PetService; +import com.PetStop.service.UserService; + +@Controller +@RequestMapping(value="/pet") +@Scope("request") +@SessionAttributes("sessionuser") + +public class PetsAppController { + @Autowired + PetService petService; + @Autowired + DataSource datasource; + + + + @RequestMapping("/home") + public ModelAndView showHome(){ + //command is a reserved request attribute name, now use
tag to show object data + return new ModelAndView("redirect:/pet/viewallpets","command",new Pet()); + } + @RequestMapping("/addPet") + public String addPet(Model model){ + //command is a reserved request attribute name, now use tag to show object data + model.addAttribute("addPet", new Pet()); + return "addPet"; + + } + + @RequestMapping(value="/advanceSearch", method=RequestMethod.POST) + public String searchPet(@ModelAttribute("pet") Pet pet,HttpServletRequest request,ModelMap modelMap) throws ServletRequestBindingException{ + + System.out.println("inside advance serarch metthod"); + String petName = request.getParameter("petName"); + + int petAge=Integer.parseInt(request.getParameter("petAge")); + + + String petPlace = request.getParameter("petPlace"); + //int petAge = ServletRequestUtils.getIntParameter(request, "petAge"); + List pt = petService.searchAllByPetNameOrPetAgeOrPetPlace(petName,petAge,petPlace); + //model.addAttribute("searchList", pt); + PagedListHolder pagedListHolder = new PagedListHolder(pt); + int page = ServletRequestUtils.getIntParameter(request, "p", 0); + pagedListHolder.setPage(page); + pagedListHolder.setPageSize(5); + modelMap.put("pagedListHolder", pagedListHolder); + return "searchResult"; + + } + @RequestMapping(value = "/viewallpets",method = RequestMethod.GET) + public String index(HttpServletRequest request, ModelMap modelMap) { + System.out.println("in home page"); + List pets = (List)petService.searchAll(); + PagedListHolder pagedListHolder = new PagedListHolder(pets); + int page = ServletRequestUtils.getIntParameter(request, "p", 0); + pagedListHolder.setPage(page); + pagedListHolder.setPageSize(5); + modelMap.put("pagedListHolder", pagedListHolder); + return "homepage"; + + } + @RequestMapping(value = "/viewmypets") + public String myPets(HttpServletRequest request,HttpSession session,ModelMap modelMap) { + System.out.println(session.getAttribute("sessionuser")); + User user = (User) session.getAttribute("sessionuser"); + List pets= petService.searchAllByUser(user); + PagedListHolder pagedListHolder = new PagedListHolder(pets); + int page = ServletRequestUtils.getIntParameter(request, "p", 0); + pagedListHolder.setPage(page); + pagedListHolder.setPageSize(3); + modelMap.put("pagedListHolder", pagedListHolder); + return "viewMyPets"; + + } + + + @RequestMapping(value="/savePet", method=RequestMethod.POST) + public ModelAndView savePet(@ModelAttribute Pet pet,HttpSession session){ + System.out.println("Pet Details Requested: All Pets"); + System.out.println(pet); + User user = (User) session.getAttribute("sessionuser"); + pet.setUser(user); + System.out.println( pet.getUser()); + petService.savePet(pet); + return new ModelAndView("redirect:/pet/viewallpets","command",new Pet()); + } + +} diff --git a/main/java/com/PetStop/model/Pet.java b/main/java/com/PetStop/model/Pet.java new file mode 100644 index 0000000..1c9eeef --- /dev/null +++ b/main/java/com/PetStop/model/Pet.java @@ -0,0 +1,121 @@ +package com.PetStop.model; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; +import javax.persistence.Transient; + +import org.springframework.context.annotation.Scope; + +import java.io.*; + +@Entity +@Table(name="pets", schema="geetham") + +public class Pet { + +@Id +@GeneratedValue(strategy=GenerationType.SEQUENCE,generator="pets_petid_seq") +@Column(name="petid") +private Integer petId; +@Column(name="petname") +private String petName; +@Column(name="petage") +private Integer petAge; +@Column(name="petplace") +private String petPlace; + +//@Transient +//private int ownerId; + +@ManyToOne +@JoinColumn(name="ownerid") +private User user; + + +public Pet() { + + // TODO Auto-generated constructor stub +} + +public Pet(Integer petId, String petName, Integer petAge, String petPlace) { + super(); + this.petId = petId; + this.petName = petName; + this.petAge = petAge; + this.petPlace = petPlace; + //this.ownerId = ownerId; +} + + + + + +public Integer getPetId() { + return petId; +} + + +public void setPetId(Integer petId) { + this.petId = petId; +} + + +public String getPetName() { + return petName; +} + + +public void setPetName(String petName) { + this.petName = petName; +} + + +public Integer getPetAge() { + return petAge; +} + + +public void setPetAge(Integer petAge) { + this.petAge = petAge; +} + + +public String getPetPlace() { + return petPlace; +} + + +public void setPetPlace(String petPlace) { + this.petPlace = petPlace; +} + +/*public int getOwnerId() { + return ownerId; +} + +public void setOwnerId(int ownerId) { + this.ownerId = ownerId; +}*/ +public User getUser() { + return user; +} + +public void setUser(User user) { + this.user = user; +} + +@Override +public String toString() { + return "Pet [petId=" + petId + ", petName=" + petName + ", petAge=" + petAge + ", petPlace=" + petPlace + "]"; +} + + + + +} diff --git a/main/java/com/PetStop/model/User.java b/main/java/com/PetStop/model/User.java new file mode 100644 index 0000000..dde413b --- /dev/null +++ b/main/java/com/PetStop/model/User.java @@ -0,0 +1,102 @@ +package com.PetStop.model; + +import java.util.List; +import java.util.Set; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.OneToMany; +import javax.persistence.Table; +import javax.persistence.Transient; + +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import java.io.*; + +@Entity +@Table(name="petuser", schema="geetham") +@Scope("session") +public class User { +@Id +@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="petuser_ownerid_seq") +@Column(name="ownerid") +private int ownerId; + +@Column(name="username",unique=true) +private String userName; + +@Column(name="userpasswd") +private String password; + +@Transient +private String passwordConfirm; + +@OneToMany(mappedBy="user", cascade = CascadeType.ALL) +private List pet; + +public User() { + super(); + // TODO Auto-generated constructor stub +} + +public User(int ownerId, String userName, String password, String passwordConfirm) { + super(); + this.ownerId = ownerId; + this.userName = userName; + this.password = password; + this.passwordConfirm = passwordConfirm; +} + +public int getOwnerId() { + return ownerId; +} + +public void setOwnerId(int ownerId) { + this.ownerId = ownerId; +} + +public String getUserName() { + return userName; +} + +public void setUserName(String userName) { + this.userName = userName; +} + +public String getPassword() { + return password; +} + +public void setPassword(String password) { + this.password = password; +} + +public String getPasswordConfirm() { + return passwordConfirm; +} + +public void setPasswordConfirm(String passwordConfirm) { + this.passwordConfirm = passwordConfirm; +} + +public List getPet() { + return pet; +} + +public void setPet(List pet) { + this.pet = pet; +} + +@Override +public String toString() { + return "User [ownerId=" + ownerId + ", userName=" + userName + ", password=" + password + ", pet=" + pet + "]"; +} + + + +} diff --git a/main/java/com/PetStop/repository/PetRepository.java b/main/java/com/PetStop/repository/PetRepository.java new file mode 100644 index 0000000..cf91aaf --- /dev/null +++ b/main/java/com/PetStop/repository/PetRepository.java @@ -0,0 +1,33 @@ +package com.PetStop.repository; + +import java.util.List; +import java.util.Optional; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +import com.PetStop.model.Pet; +import com.PetStop.model.User; + +@Repository +public interface PetRepository extends PagingAndSortingRepository,JpaRepository { + + + + public List findAllByPetNameOrPetAgeOrPetPlace(String petname,int petage,String petplace); + //public List findAllByOwnerId(int ownerid); + //public void save(pet); + //List findAll(); + //Page findAll(Pageable pagable); + public List findAllByUser(User user); + + /*@Query(name="select * from pets where ownerid=:ownerid", nativeQuery=true) + public List findAllByUser(@Param("ownerid") int ownerid); + }*/ +} \ No newline at end of file diff --git a/main/java/com/PetStop/repository/UserRepository.java b/main/java/com/PetStop/repository/UserRepository.java new file mode 100644 index 0000000..a8ebe0b --- /dev/null +++ b/main/java/com/PetStop/repository/UserRepository.java @@ -0,0 +1,29 @@ +package com.PetStop.repository; + +import java.util.List; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +import com.PetStop.model.Pet; +import com.PetStop.model.User; + +@Repository +public interface UserRepository extends JpaRepository { + //public void buyPet(); + //public List getMyPets(); + //public void authenticateUser(); + public User save(User user); + public List findAll(); + /*@Query(value="select petuser.id from petuser where petuser.username=?", nativeQuery=true) + public User findUserById(@Param("username") String username);*/ + /*@Query(value="select * from petuser u where u.userpasswd=:password and u.username=:username",nativeQuery=true) + public User findUserByName(@Param("password") String password,@Param("username") String username);*/ + public User findByUserNameAndPassword(String userName, String password); + public int findOwnerIdByUserName(String userName); + + public User findByUserName(String userName); +} diff --git a/main/java/com/PetStop/service/PetService.java b/main/java/com/PetStop/service/PetService.java new file mode 100644 index 0000000..cda5926 --- /dev/null +++ b/main/java/com/PetStop/service/PetService.java @@ -0,0 +1,16 @@ +package com.PetStop.service; + +import java.util.List; + +import com.PetStop.model.Pet; +import com.PetStop.model.User; + + +public interface PetService { + public List searchAllByPetNameOrPetAgeOrPetPlace(String petname,int petage,String petplace); + public void savePet(Pet pet); + List searchAllByUser(User user); + //public List searchAllByOwnerId(int ownerid); + //public List searchAllByUser(int ownerid); + List searchAll(); +} diff --git a/main/java/com/PetStop/service/PetServiceImpl.java b/main/java/com/PetStop/service/PetServiceImpl.java new file mode 100644 index 0000000..8eea468 --- /dev/null +++ b/main/java/com/PetStop/service/PetServiceImpl.java @@ -0,0 +1,63 @@ +package com.PetStop.service; + +import java.util.List; + +import javax.servlet.http.HttpSession; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.web.bind.annotation.SessionAttribute; +import org.springframework.web.bind.annotation.SessionAttributes; + +import com.PetStop.model.Pet; +import com.PetStop.model.User; +import com.PetStop.repository.PetRepository; + +@Service +@SessionAttributes("sessionuser") +public class PetServiceImpl implements PetService { + + @Autowired + PetRepository petRepository; + + + @Override + public void savePet(Pet pet) { + petRepository.save(pet); + } + + + + + + @Override + public List searchAllByPetNameOrPetAgeOrPetPlace(String petname, int petage, String petplace) { + // TODO Auto-generated method stub + return petRepository.findAllByPetNameOrPetAgeOrPetPlace(petname, petage, petplace); + } + + @Override + public List searchAll() { + // TODO Auto-generated method stub + return petRepository.findAll(); + } + + + + + + @Override + public List searchAllByUser(User user) { + // TODO Auto-generated method stub + return petRepository.findAllByUser(user); + } + + + + + + + + + +} diff --git a/main/java/com/PetStop/service/UserService.java b/main/java/com/PetStop/service/UserService.java new file mode 100644 index 0000000..24ec272 --- /dev/null +++ b/main/java/com/PetStop/service/UserService.java @@ -0,0 +1,13 @@ +package com.PetStop.service; + +import com.PetStop.model.User; + +public interface UserService { + + public User searchByUserNameAndPassword(String userName, String password); + public int searchOwnerIdByUserName(String userName); + + void save(User user); + + public User searchByUserName(String userName); +} diff --git a/main/java/com/PetStop/service/UserServiceImpl.java b/main/java/com/PetStop/service/UserServiceImpl.java new file mode 100644 index 0000000..b6c3ed7 --- /dev/null +++ b/main/java/com/PetStop/service/UserServiceImpl.java @@ -0,0 +1,40 @@ +package com.PetStop.service; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.PetStop.model.User; +import com.PetStop.repository.UserRepository; + +@Service +public class UserServiceImpl implements UserService { + @Autowired + UserRepository userRepository; + @Override + public User searchByUserNameAndPassword(String userName, String password) { + // TODO Auto-generated method stub + return userRepository.findByUserNameAndPassword(userName, password); + } + @Override + public int searchOwnerIdByUserName(String userName) { + // TODO Auto-generated method stub + return userRepository.findOwnerIdByUserName(userName); + } + @Override + + public void save(User user) { + + userRepository.save(user); + + } + + @Override + + public User searchByUserName(String userName) { + + return userRepository.findByUserName(userName); + + } + + +} diff --git a/main/java/com/PetStop/validation/UserValidator.java b/main/java/com/PetStop/validation/UserValidator.java new file mode 100644 index 0000000..ea47a03 --- /dev/null +++ b/main/java/com/PetStop/validation/UserValidator.java @@ -0,0 +1,88 @@ +package com.PetStop.validation; + +import org.springframework.beans.factory.annotation.Autowired; + +import org.springframework.stereotype.Component; + +import org.springframework.validation.Errors; + +import org.springframework.validation.ValidationUtils; + +import org.springframework.validation.Validator; + +import com.PetStop.model.User; +import com.PetStop.service.UserService; + + + +@Component + +public class UserValidator implements Validator + +{ + + @Autowired + + private UserService userService; + + + + @Override + + public boolean supports(Class aClass) { + + return User.class.equals(aClass); + + } + + @Override + + public void validate(Object o, Errors errors) { + + User user = (User) o; + + + + + + ValidationUtils.rejectIfEmptyOrWhitespace(errors, "userName", "NotEmpty"); + + if (user.getUserName().length() < 6 || user.getUserName().length() > 32) { + + errors.rejectValue("userName", "Size.userForm.userName"); + + } + + if (userService.searchByUserName(user.getUserName()) != null) { + + errors.rejectValue("userName", "Duplicate.userForm.userName"); + + } + + + + ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password", "NotEmpty"); + + if (user.getPassword().length() < 8 || user.getPassword().length() > 32) { + + errors.rejectValue("password", "Size.userForm.password"); + + } + + + + if (!user.getPasswordConfirm().equals(user.getPassword())) { + + errors.rejectValue("passwordConfirm", "Diff.userForm.passwordConfirm"); + + } + + } + +} + + + + + + \ No newline at end of file diff --git a/main/resources/application.properties b/main/resources/application.properties new file mode 100644 index 0000000..4492518 --- /dev/null +++ b/main/resources/application.properties @@ -0,0 +1,29 @@ +server.port = 8088 +# create and drop tables and sequences, loads import.sql +spring.jpa.hibernate.ddl-auto=none +spring.profiles.active=@spring.profiles.active@ + +# Oracle settings +spring.datasource.url=jdbc:oracle:thin:@localhost:1521:xe +spring.datasource.username=geetham +spring.datasource.password=geetham11 +spring.datasource.driver-class=oracle.jdbc.driver.OracleDriver +spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.Oracle10gDialect +spring.jpa.show-sql=true +# HikariCP settings +# spring.datasource.hikari.* +#spring.h2.console.enabled=true +spring.datasource.hikari.connection-timeout=60000 +spring.datasource.hikari.maximum-pool-size=5 + +# logging +logging.pattern.console=%d{yyyy-MM-dd HH:mm:ss} %-5level %logger{36} - %msg%n +logging.level.org.hibernate.SQL=debug +#logging.level.org.hibernate.type.descriptor.sql=trace +logging.level.=error + +#viewResolver +spring.mvc.view.prefix=/WEB-INF/jsp/ +spring.mvc.view.suffix=.jsp + +spring.messages.basename=validation \ No newline at end of file diff --git a/main/resources/static/index.css b/main/resources/static/index.css new file mode 100644 index 0000000..d45633b --- /dev/null +++ b/main/resources/static/index.css @@ -0,0 +1 @@ +@CHARSET "ISO-8859-1"; diff --git a/main/resources/validation.properties b/main/resources/validation.properties new file mode 100644 index 0000000..e16cf32 --- /dev/null +++ b/main/resources/validation.properties @@ -0,0 +1,11 @@ +NotEmpty=This field is required. + +Size.userForm.userName=Please use between 6 and 32 characters. + +Duplicate.userForm.userName=Someone already has that userName. + +Size.userForm.password=Try one with at least 8 characters. + +Diff.userForm.passwordConfirm=These passwords don't match. + + \ No newline at end of file diff --git a/main/webapp/WEB-INF/jsp/addPet.jsp b/main/webapp/WEB-INF/jsp/addPet.jsp new file mode 100644 index 0000000..f49a30a --- /dev/null +++ b/main/webapp/WEB-INF/jsp/addPet.jsp @@ -0,0 +1,44 @@ +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> + + + + +Insert title here + + +
+ + + + + + + + + + + + + + + + + + <%-- + + + --%> + + + + +
NAME :
AGE :
PLACE :
+ + +
+
+
+ + \ No newline at end of file diff --git a/main/webapp/WEB-INF/jsp/homepage.jsp b/main/webapp/WEB-INF/jsp/homepage.jsp new file mode 100644 index 0000000..2031a2a --- /dev/null +++ b/main/webapp/WEB-INF/jsp/homepage.jsp @@ -0,0 +1,128 @@ +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> + <%@ taglib prefix="tg" tagdir="/WEB-INF/tags"%> +<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%> +<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%> + + + + + +PET STOP + + + + + + +

PET STOP

+
+ + + + + + + + + +ViewMyPets +AddPet +Logout

+
AdvanceSearch
+ + + + + + + + + + + <%-- --%> + + + + + +
Sr NoPET IDPET NAMEPET AGEPET PLACEACTION
${status.index + 1}${temp.petId}${temp.petName}${temp.petAge}${temp.petPlace}${temp.ownerId} + + +
+ +
+ + + + +

+ +

+
+ + Close + +

Advance Search

+ + +
+ + +

+ +

+
+
+
+ +
+
+ + + + \ No newline at end of file diff --git a/main/webapp/WEB-INF/jsp/login.jsp b/main/webapp/WEB-INF/jsp/login.jsp new file mode 100644 index 0000000..32719a3 --- /dev/null +++ b/main/webapp/WEB-INF/jsp/login.jsp @@ -0,0 +1,41 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" +pageEncoding="UTF-8"%> <%@taglib +uri="http://www.springframework.org/tags/form" prefix="form"%> + + + + +Login Form + + +

Welcome to PetStop

+

Sign in

+ +
+ +<%-- --%> + + + + + + + + + + + + + + + + + +
User Name
Password
+
New User: Register
+
${error}
+ +
+
+ + \ No newline at end of file diff --git a/main/webapp/WEB-INF/jsp/registration.jsp b/main/webapp/WEB-INF/jsp/registration.jsp new file mode 100644 index 0000000..87479fd --- /dev/null +++ b/main/webapp/WEB-INF/jsp/registration.jsp @@ -0,0 +1,111 @@ +<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> +<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> + + + + + + + Pet Stop + + + + + + + + +
+ USER REGISTRATION + + + + + + + + + + + + +
+
+ + + + + + +
+ +
+ + + + + + + + + + + + + + + + + + +
+

USER REGISTRATION

+
+ Username
Password
Confirm Password
+ + + + diff --git a/main/webapp/WEB-INF/jsp/searchResult.jsp b/main/webapp/WEB-INF/jsp/searchResult.jsp new file mode 100644 index 0000000..40ee8a5 --- /dev/null +++ b/main/webapp/WEB-INF/jsp/searchResult.jsp @@ -0,0 +1,40 @@ +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> + + + + +Insert title here + + + +

SEARCHED RESULT

+
+ + + + + + + + + + + + + + + + + + + + + +
PET IDPET NAMEPET AGEPET PLACE
${temp.petId}${temp.petName}${temp.petAge}${temp.petPlace}
+ + + \ No newline at end of file diff --git a/main/webapp/WEB-INF/jsp/successfullreg.jsp b/main/webapp/WEB-INF/jsp/successfullreg.jsp new file mode 100644 index 0000000..bc09a05 --- /dev/null +++ b/main/webapp/WEB-INF/jsp/successfullreg.jsp @@ -0,0 +1,33 @@ +<%@ page language="java" + + contentType="text/html; charset=ISO-8859-1" + + pageEncoding="ISO-8859-1"%> + + + + + + + + Successfully Registered + + + + + + + +

Hi ${user} You are Successfully Registered!!!

+ + + + + + + +
please Sign in Click here
+ + + + \ No newline at end of file diff --git a/main/webapp/WEB-INF/jsp/viewMyPets.jsp b/main/webapp/WEB-INF/jsp/viewMyPets.jsp new file mode 100644 index 0000000..abd0ac7 --- /dev/null +++ b/main/webapp/WEB-INF/jsp/viewMyPets.jsp @@ -0,0 +1,49 @@ +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> + <%@ taglib prefix="tg" tagdir="/WEB-INF/tags"%> +<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%> +<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%> + + + + + +PET STOP + + + + + +

My Page

+
+ + + + + + <%-- --%> + + + + + + + + + + + + + + +
Sr NoPET IDPET NAMEPET AGEPET PLACE
${status.index + 1}${temp.petId}${temp.petName}${temp.petAge}${temp.petPlace}
+ +
+ + + + \ No newline at end of file diff --git a/main/webapp/WEB-INF/tags/paging.tag b/main/webapp/WEB-INF/tags/paging.tag new file mode 100644 index 0000000..334ccbd --- /dev/null +++ b/main/webapp/WEB-INF/tags/paging.tag @@ -0,0 +1,54 @@ +<%@ tag language="java" pageEncoding="ISO-8859-1"%> +<%@ tag import="org.springframework.util.StringUtils"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> +<%@ attribute name="pagedListHolder" required="true" + type="org.springframework.beans.support.PagedListHolder"%> +<%@ attribute name="pagedLink" required="true" type="java.lang.String"%> + + + + + + + \ No newline at end of file