Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
ba0cdf1
Junit and Mock Test Cases
wahid-nur-dahlan Aug 17, 2017
ff63a82
Junit Test Cases for Models
wahid-nur-dahlan Aug 17, 2017
8847690
Junit Test Cases for Models
wahid-nur-dahlan Aug 17, 2017
6c4904d
adding ansible playbook in vprofile-project
wahid-nur-dahlan Aug 24, 2017
2eae1a7
updated vprofile.yml file for version change
wkhanvisualpathit Aug 24, 2017
5f45b41
adding DB dump
wahid-nur-dahlan Aug 28, 2017
62e2988
Merge branch 'vp-ansible' of https://github.com/wkhanvisualpathit/VPr…
wahid-nur-dahlan Aug 28, 2017
17f57b7
removing db.sql dump file
wahid-nur-dahlan Sep 14, 2017
17572c0
adding ansible playbook in vprofile-project
wahid-nur-dahlan Aug 24, 2017
8aa189c
updated vprofile.yml file for version change
wkhanvisualpathit Aug 24, 2017
fd1099e
adding DB dump
wahid-nur-dahlan Aug 28, 2017
a5ef338
removing db.sql dump file
wahid-nur-dahlan Sep 14, 2017
1a116c7
Merge branch 'master' of https://github.com/wkhanvisualpathit/VProfile
wahid-nur-dahlan Sep 14, 2017
781b7c2
Updated README.md file for dump mention
wkhanvisualpathit Sep 14, 2017
02ff6c2
updated pom.xml for change of version
wkhanvisualpathit Sep 25, 2017
ad26e65
change for artefact version
wahid-nur-dahlan Sep 26, 2017
8aa5db5
change for artefact version
wahid-nur-dahlan Sep 26, 2017
fd6f330
added memchached and image upload feature
wahid-nur-dahlan Oct 23, 2017
6d2581e
changing the version for artifact
wahid-nur-dahlan Oct 23, 2017
ff08080
changing the version for artifact
wahid-nur-dahlan Oct 23, 2017
3c82b9d
modified pom build plugins
wahid-nur-dahlan Oct 24, 2017
2150ea3
updated pom for formatting text
wkhanvisualpathit Oct 24, 2017
61e3f1d
updating pom for tag missing
wkhanvisualpathit Oct 24, 2017
0b48c96
updating plugin portion in pom
wkhanvisualpathit Oct 24, 2017
aecf657
Merge branch 'vp-memchached' of https://github.com/wkhanvisualpathit/…
wahid-nur-dahlan Oct 24, 2017
d0cacb4
adding new data dump
wahid-nur-dahlan Oct 24, 2017
62a4977
changes for the standby memcached
wahid-nur-dahlan Nov 1, 2017
4541568
deleting old db backup
wkhanvisualpathit Nov 6, 2017
5312b63
changing mysqldump file
Dec 7, 2017
7b33861
modifiying UI
Dec 7, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ MSQL DB Installation Steps for Linux ubuntu 14.04:
- $ sudo apt-get install mysql-server

Then look for the file :
- /src/main/resources/db.sql

- db.sql file contents all step for DB table creation commands.
- /src/main/resources/accountsdb
- accountsdb.sql file is a mysql dump file.we have to import this dump to mysql db server
- > mysql -u <user_name> -p accounts < accountsdb.sql


39 changes: 39 additions & 0 deletions ansible/vprofile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
- hosts: tomcatservers
become: yes
gather_facts: False
tasks:

- name: Install EPEL-release
yum: name=epel-release state=present


- name: Install java_1.8
yum: name=java-1.8.0-openjdk.x86_64 state=present

- name: Install tomcat
yum: name=tomcat state=present


- name: Download latest VProfile.war file
get_url: url=http://{{nexusip}}:8081/nexus/content/repositories/VProfile-repo/{{groupid}}/{{time}}/{{build}}/{{vprofile_version}} dest=/tmp/ mode=755

- name: Stop tomcat service
service: name=tomcat state=stopped

- name: Copy artifact to tomcat folder
shell: cp /tmp/{{vprofile_version}} /var/lib/tomcat/webapps

- name: Delete link to existing vprofile version
file: path=/var/lib/tomcat/webapps/VProfile state=absent

- name: Start tomcat service
service: name=tomcat state=started
- wait_for: path=/var/lib/tomcat/webapps/{{time}}-{{build}}

- name: Link latest vprofile version
file: src=/var/lib/tomcat/webapps/{{time}}-{{build}} dest=/var/lib/tomcat/webapps/VProfile state=link

- name: Stop iptables
service: name=iptables state=stopped

70 changes: 42 additions & 28 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.visualpathit</groupId>
<artifactId>VProfile</artifactId>
<artifactId>vprofile</artifactId>
<packaging>war</packaging>
<version>1.0</version>
<version>v1</version>
<name>Visualpathit VProfile Webapp</name>
<url>http://maven.apache.org</url>
<properties>
Expand All @@ -28,13 +28,13 @@
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>

<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
Expand Down Expand Up @@ -90,36 +90,51 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.9.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>3.2.3.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.9.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>3.2.3.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>net.spy</groupId>
<artifactId>spymemcached</artifactId>
<version>2.12.3</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
</dependencies>
<build>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.jetty</groupId>
Expand Down Expand Up @@ -157,4 +172,3 @@
</plugins>
</build>
</project>

45 changes: 45 additions & 0 deletions src/main/java/com/visualpathit/account/beans/Components.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.visualpathit.account.beans;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class Components {

@Value("${memcached.active.host}")
private String activeHost;
@Value("${memcached.active.port}")
private String activePort;
@Value("${memcached.standBy.host}")
private String standByHost;
@Value("${memcached.standBy.port}")
private String standByPort;

public String getActiveHost() {
return activeHost;
}
public String getActivePort() {
return activePort;
}
public String getStandByHost() {
return standByHost;
}
public String getStandByPort() {
return standByPort;
}
public void setActiveHost(String activeHost) {
this.activeHost = activeHost;
}
public void setActivePort(String activePort) {
this.activePort = activePort;
}
public void setStandByHost(String standByHost) {
this.standByHost = standByHost;
}
public void setStandByPort(String standByPort) {
this.standByPort = standByPort;
}



}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package com.visualpathit.account.controller;

import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
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.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import com.visualpathit.account.model.User;
import com.visualpathit.account.service.UserService;

@Controller
public class FileUploadController {
@Autowired
private UserService userService;
private static final Logger logger = LoggerFactory
.getLogger(FileUploadController.class);

/**
* Upload single file using Spring Controller
*/
@RequestMapping(value = { "/upload"} , method = RequestMethod.GET)
public final String upload(final Model model) {
return "upload";
}
@RequestMapping(value = "/uploadFile", method = RequestMethod.POST)
public @ResponseBody
String uploadFileHandler(@RequestParam("name") String name,@RequestParam("userName") String userName,
@RequestParam("file") MultipartFile file) {

System.out.println("Called the upload file :::" );
if (!file.isEmpty()) {
try {
byte[] bytes = file.getBytes();

// Creating the directory to store file
String rootPath = System.getProperty("catalina.home");
System.out.println("Path ::::" +rootPath);
File dir = new File(rootPath + File.separator + "tmpFiles");
if (!dir.exists())
dir.mkdirs();

// Create the file on server
File serverFile = new File(dir.getAbsolutePath()
+ File.separator + name+".png");
//image saving
User user = userService.findByUsername(userName);
user.setProfileImg(name +".png");
user.setProfileImgPath(serverFile.getAbsolutePath());
userService.save(user);

BufferedOutputStream stream = new BufferedOutputStream(
new FileOutputStream(serverFile));
stream.write(bytes);
stream.close();

logger.info("Server File Location="
+ serverFile.getAbsolutePath());

return "You successfully uploaded file=" + name +".png";
} catch (Exception e) {
return "You failed to upload " + name +".png" + " => " + e.getMessage();
}
} else {
return "You failed to upload " + name +".png"
+ " because the file was empty.";
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
import com.visualpathit.account.model.User;
import com.visualpathit.account.service.SecurityService;
import com.visualpathit.account.service.UserService;
import com.visualpathit.account.utils.MemcachedUtils;
import com.visualpathit.account.validator.UserValidator;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
/**{@author waheedk}*/
Expand Down Expand Up @@ -68,4 +72,86 @@ public final String welcome(final Model model) {
public final String indexHome(final Model model) {
return "index_home";
}
@RequestMapping(value = "/users", method = RequestMethod.GET)
public String getAllUsers(Model model)
{

List<User> users = userService.getList();
//JSONObject jsonObject
System.out.println("All User Data:::" + users);
model.addAttribute("users", users);
return "userList";
}

@RequestMapping(value = "/users/{id}", method = RequestMethod.GET)
public String getOneUser(@PathVariable(value="id") String id,Model model)
{
String Result ="";
try{
if( id != null && MemcachedUtils.memcachedGetData(id)!= null){
User userData = MemcachedUtils.memcachedGetData(id);
Result ="Data is From Chache";
System.out.println("--------------------------------------------");
System.out.println("Data is From Chache !!");
System.out.println("--------------------------------------------");
System.out.println("Father ::: "+userData.getFatherName());
model.addAttribute("user", userData);
model.addAttribute("Result", Result);
}
else{
User user = userService.findById(Long.parseLong(id));
Result = MemcachedUtils.memcachedSetData(user,id);
if(Result == null ){
Result ="Memcached Connection Failure !!";
}
System.out.println("--------------------------------------------");
System.out.println("Data is From Database");
System.out.println("--------------------------------------------");
System.out.println("Result ::: "+ Result);
model.addAttribute("user", user);
model.addAttribute("Result", Result);
}
} catch (Exception e) {
System.out.println( e.getMessage() );
}
return "user";
}

/** {@inheritDoc} */
@RequestMapping(value = { "/user/{username}"} , method = RequestMethod.GET)
public final String userUpdate(@PathVariable(value="username") String username,final Model model) {
User user = userService.findByUsername(username);
System.out.println("User Data:::" + user);
model.addAttribute("user", user);
return "userUpdate";
}
@RequestMapping(value = { "/user/{username}"} , method = RequestMethod.POST)
public final String userUpdateProfile(@PathVariable(value="username") String username,final @ModelAttribute("user") User userForm,final Model model) {
User user = userService.findByUsername(username);
user.setUsername(userForm.getUsername());
user.setUserEmail(userForm.getUserEmail());
user.setDateOfBirth(userForm.getDateOfBirth());
user.setFatherName(userForm.getFatherName());
user.setMotherName(userForm.getMotherName());
user.setGender(userForm.getGender());
user.setLanguage(userForm.getLanguage());
user.setMaritalStatus(userForm.getMaritalStatus());
user.setNationality(userForm.getNationality());
user.setPermanentAddress(userForm.getPermanentAddress());
user.setTempAddress(userForm.getTempAddress());
user.setPhoneNumber(userForm.getPhoneNumber());
user.setSecondaryPhoneNumber(userForm.getSecondaryPhoneNumber());
user.setPrimaryOccupation(userForm.getPrimaryOccupation());
user.setSecondaryOccupation(userForm.getSecondaryOccupation());
user.setSkills(userForm.getSkills());
user.setWorkingExperience(userForm.getWorkingExperience());
userService.save(user);
/*model.addAttribute("user", user);*/
return "welcome";
}





}
Loading