first commit

This commit is contained in:
Dhanraj
2024-09-22 10:21:52 +05:30
parent 9c6c3abc32
commit bd5119fc3c
697 changed files with 112184 additions and 10841 deletions

View File

@ -0,0 +1,74 @@
package net.shyshkin.study.fullstack.supportportal.backend.config;
import net.shyshkin.study.fullstack.supportportal.backend.domain.User;
import net.shyshkin.study.fullstack.supportportal.backend.repository.UserRepository;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.crypto.password.PasswordEncoder;
import java.util.UUID;
import static net.shyshkin.study.fullstack.supportportal.backend.constant.Authority.*;
@Configuration
public class DataInitializer {
@Bean
public CommandLineRunner init(UserRepository userRepository, PasswordEncoder passwordEncoder) {
return args -> {
System.out.println("Running DataInitializer...");
// Initialize users
createUserIfNotExists(userRepository, passwordEncoder, "admin", "adminpassword", "admin@example.com", "Admin", "User", "ROLE_ADMIN");
createUserIfNotExists(userRepository, passwordEncoder, "hr", "hrpassword", "hr@example.com", "HR", "User", "ROLE_HR");
createUserIfNotExists(userRepository, passwordEncoder, "manager", "managerpassword", "manager@example.com", "Manager", "User", "ROLE_MANAGER");
createUserIfNotExists(userRepository, passwordEncoder, "user", "userpassword", "user@example.com", "Regular", "User", "ROLE_USER");
createUserIfNotExists(userRepository, passwordEncoder, "superadmin", "superadminpassword", "superadmin@example.com", "Super", "Admin", "ROLE_SUPER_ADMIN");
};
}
private void createUserIfNotExists(UserRepository userRepository, PasswordEncoder passwordEncoder,
String username, String password, String email,
String firstName, String lastName, String role) {
if (userRepository.findByUsername(username).isEmpty()) {
String encodedPassword = passwordEncoder.encode(password);
User user = User.builder()
.email(email)
.firstName(firstName)
.lastName(lastName)
.username(username)
.password(encodedPassword)
.userId(UUID.randomUUID())
.isActive(true)
.isNotLocked(true)
.role(role)
.authorities(getAuthoritiesByRole(role))
.build();
userRepository.save(user);
System.out.println(role + " user created successfully.");
} else {
System.out.println(role + " user already exists.");
}
}
private String[] getAuthoritiesByRole(String role) {
switch (role) {
case "ROLE_ADMIN":
return ADMIN_AUTHORITIES;
case "ROLE_HR":
return HR_AUTHORITIES;
case "ROLE_MANAGER":
return MANAGER_AUTHORITIES;
case "ROLE_USER":
return USER_AUTHORITIES;
case "ROLE_SUPER_ADMIN":
return SUPER_ADMIN_AUTHORITIES;
default:
throw new IllegalArgumentException("Invalid role: " + role);
}
}
}

View File

@ -0,0 +1,19 @@
// package com.example.tamilnadureservoir.config;
package net.shyshkin.study.fullstack.supportportal.backend.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;
@Configuration
public class RestTemplateConfig {
@Bean
public RestTemplate restTemplate() {
return new RestTemplate();
}
}

View File

@ -14,4 +14,10 @@ public class FileConstant {
public static final String NOT_AN_IMAGE_FILE = " is not an image file. Please upload an image file";
public static final String TEMP_PROFILE_IMAGE_BASE_URL = "https://robohash.org/";
// public static final String PROFESSOR_IMAGE_PATH = "/professor/image/";
// public static final String PROFESSOR_FOLDER = System.getProperty("user.home") + "/supportportal/professor/";
// public static final String DEFAULT_PROFESSOR_IMAGE_URI_PATTERN = "/professor/%s/profile-image";
// public static final String PROFESSOR_IMAGE_FILENAME = "avatar.jpg";
}

View File

@ -0,0 +1,58 @@
package net.shyshkin.study.fullstack.supportportal.backend.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import net.shyshkin.study.fullstack.supportportal.backend.domain.Event;
import net.shyshkin.study.fullstack.supportportal.backend.repository.EventRepository;
import java.util.List;
import java.util.Optional;
@RestController
@RequestMapping("/api/events")
public class EventController {
@Autowired
private EventRepository eventRepository;
@GetMapping
public ResponseEntity<List<Event>> getAllEvents() {
List<Event> events = eventRepository.findAll();
return new ResponseEntity<>(events, HttpStatus.OK);
}
@GetMapping("/{id}")
public ResponseEntity<Event> getEventById(@PathVariable Long id) {
Optional<Event> event = eventRepository.findById(id);
return event.map(ResponseEntity::ok)
.orElseGet(() -> ResponseEntity.notFound().build());
}
@PostMapping
public ResponseEntity<Event> createEvent(@RequestBody Event event) {
Event savedEvent = eventRepository.save(event);
return new ResponseEntity<>(savedEvent, HttpStatus.CREATED);
}
@PutMapping("/{id}")
public ResponseEntity<Event> updateEvent(@PathVariable Long id, @RequestBody Event event) {
if (!eventRepository.existsById(id)) {
return ResponseEntity.notFound().build();
}
event.setId(id);
Event updatedEvent = eventRepository.save(event);
return new ResponseEntity<>(updatedEvent, HttpStatus.OK);
}
@DeleteMapping("/{id}")
public ResponseEntity<Void> deleteEvent(@PathVariable Long id) {
if (!eventRepository.existsById(id)) {
return ResponseEntity.notFound().build();
}
eventRepository.deleteById(id);
return ResponseEntity.noContent().build();
}
}

View File

@ -0,0 +1,141 @@
package net.shyshkin.study.fullstack.supportportal.backend.controller;
import net.shyshkin.study.fullstack.supportportal.backend.domain.Post;
import net.shyshkin.study.fullstack.supportportal.backend.domain.Professor;
import net.shyshkin.study.fullstack.supportportal.backend.domain.dto.PostDto;
import net.shyshkin.study.fullstack.supportportal.backend.repository.PostRepository;
import net.shyshkin.study.fullstack.supportportal.backend.repository.ProfessorRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import com.amazonaws.services.secretsmanager.model.ResourceNotFoundException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
@RestController
@RequestMapping("/api/posts")
public class PostController {
@Autowired
private PostRepository postRepository;
// Get all posts where isPosted is true
@GetMapping("/posted")
public ResponseEntity<List<Post>> getAllPostedPosts() {
try {
List<Post> posts = postRepository.findAllByIsPostedTrue();
return ResponseEntity.ok(posts);
} catch (Exception e) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
}
}
// Get all unique tags with count
@GetMapping("/tags/count")
public ResponseEntity<Map<String, Long>> getTagsWithCount() {
try {
List<Object[]> tagCounts = postRepository.findTagsWithCount();
Map<String, Long> tagCountMap = new HashMap<>();
for (Object[] tagCount : tagCounts) {
tagCountMap.put((String) tagCount[0], (Long) tagCount[1]);
}
return ResponseEntity.ok(tagCountMap);
} catch (Exception e) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
}
}
// Get all posts associated with a specific tag where isPosted is true
@GetMapping("/tag/{tag}")
public ResponseEntity<List<Post>> getPostsByTag(@PathVariable String tag) {
try {
List<Post> posts = postRepository.findAllByTagAndIsPostedTrue(tag);
return ResponseEntity.ok(posts);
} catch (Exception e) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
}
}
// Get all posts
@GetMapping
public List<Post> getAllPosts() {
return postRepository.findAll();
}
// Get a single post by ID
@GetMapping("/{id}")
public ResponseEntity<Post> getPostById(@PathVariable Long id) {
return postRepository.findById(id)
.map(post -> ResponseEntity.ok(post))
.orElse(ResponseEntity.notFound().build());
}
@Autowired
private ProfessorRepository professorRepository;
@PostMapping
public ResponseEntity<?> createPost(@RequestBody PostDto postDto) {
Post post = new Post();
post.setTitle(postDto.getTitle());
post.setContent(postDto.getContent());
post.setPosted(postDto.isPosted());
// Fetch professors from IDs, filter out null IDs
List<Long> validProfessorIds = postDto.getProfessors().stream()
.filter(Objects::nonNull)
.collect(Collectors.toList());
List<Professor> professors = professorRepository.findAllById(validProfessorIds);
post.setProfessors(professors);
// Set tags
post.setTags(postDto.getTags());
// Save the post
postRepository.save(post);
return ResponseEntity.status(HttpStatus.CREATED).build();
}
@PutMapping("/{id}")
public ResponseEntity<?> updatePost(@PathVariable Long id, @RequestBody PostDto postDto) {
Post post = postRepository.findById(id).orElseThrow(() -> new ResourceNotFoundException("Post not found"));
post.setTitle(postDto.getTitle());
post.setContent(postDto.getContent());
post.setPosted(postDto.isPosted());
// Fetch professors from IDs, filter out null IDs
List<Long> validProfessorIds = postDto.getProfessors().stream()
.filter(Objects::nonNull)
.collect(Collectors.toList());
List<Professor> professors = professorRepository.findAllById(validProfessorIds);
post.setProfessors(professors);
// Set tags
post.setTags(postDto.getTags());
// Save the updated post
postRepository.save(post);
return ResponseEntity.ok().build();
}
@DeleteMapping("/{id}")
public ResponseEntity<Void> deletePost(@PathVariable Long id) {
return postRepository.findById(id)
.map(post -> {
postRepository.delete(post);
return ResponseEntity.noContent().<Void>build(); // Explicitly specify the type parameter
})
.orElse(ResponseEntity.notFound().build());
}
}

View File

@ -0,0 +1,36 @@
package net.shyshkin.study.fullstack.supportportal.backend.controller;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class PostDTO
{
@NotNull
private String title;
@NotNull
private String content;
@NotEmpty(message = "At least one professor must be selected.")
private List<Long> professors;
private List<String> tags;
private boolean posted;
// Getters and setters
// ...
}

View File

@ -0,0 +1,93 @@
package net.shyshkin.study.fullstack.supportportal.backend.controller;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.shyshkin.study.fullstack.supportportal.backend.domain.HttpResponse;
import net.shyshkin.study.fullstack.supportportal.backend.domain.Professor;
import net.shyshkin.study.fullstack.supportportal.backend.domain.dto.ProfessorDto;
import net.shyshkin.study.fullstack.supportportal.backend.service.ProfessorService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.validation.Valid;
import java.util.UUID;
import static org.springframework.http.HttpStatus.OK;
@Slf4j
@RestController
@RequestMapping("professor")
@RequiredArgsConstructor
public class ProfessorResource {
private final ProfessorService professorService;
@GetMapping("home")
public String showProfessor() {
return "Application works";
}
@PostMapping("register")
public Professor register(@RequestBody Professor professor) {
return professorService.register(professor.getFirstName(), professor.getLastName(), professor.getEmail(), professor.getDepartment(), professor.getPosition());
}
@PostMapping("add")
public ResponseEntity<Professor> addNewProfessor(@Valid ProfessorDto professorDto) {
log.debug("Professor DTO: {}", professorDto);
Professor professor = professorService.addNewProfessor(professorDto);
return ResponseEntity.ok(professor);
}
@PutMapping("{professorId}")
public Professor updateProfessor(@PathVariable UUID professorId, @Valid ProfessorDto professorDto) {
log.debug("Professor DTO: {}", professorDto);
return professorService.updateProfessor(professorId, professorDto);
}
@GetMapping("{professorId}")
public Professor findProfessorById(@PathVariable UUID professorId) {
return professorService.findByProfessorId(professorId);
}
@GetMapping("email/{email}")
public Professor findProfessorByEmail(@PathVariable String email) {
return professorService.findByEmail(email);
}
@GetMapping
public Page<Professor> getAllProfessors(Pageable pageable) {
return professorService.findAll(pageable);
}
@DeleteMapping("{professorId}")
public HttpResponse deleteProfessor(@PathVariable UUID professorId) {
professorService.deleteProfessor(professorId);
return HttpResponse.builder()
.httpStatusCode(OK.value())
.httpStatus(OK)
.reason(OK.getReasonPhrase())
.message("Professor deleted successfully")
.build();
}
@PutMapping("{professorId}/profile-image")
public Professor updateProfileImage(@PathVariable UUID professorId, @RequestParam MultipartFile profileImage) {
return professorService.updateProfileImage(professorId, profileImage);
}
@GetMapping(path = "{professorId}/profile-image/{filename}", produces = MediaType.IMAGE_JPEG_VALUE)
public byte[] getProfileImageByProfessorId(@PathVariable UUID professorId, @PathVariable String filename) {
return professorService.getImageByProfessorId(professorId, filename);
}
@GetMapping(path = "{professorId}/profile-image", produces = MediaType.IMAGE_JPEG_VALUE)
public byte[] getDefaultProfileImage(@PathVariable UUID professorId) {
return professorService.getDefaultProfileImage(professorId);
}
}

View File

@ -0,0 +1,198 @@
// package com.example.tamilnadureservoir.controller;
package net.shyshkin.study.fullstack.supportportal.backend.controller;
import java.io.StringReader;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.dom.DOMSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import net.shyshkin.study.fullstack.supportportal.backend.domain.ConferenceData;
import net.shyshkin.study.fullstack.supportportal.backend.repository.ConferenceDataRepository;
@CrossOrigin(origins = "*", maxAge = 3600)
@RestController
@RequestMapping("/soap")
public class SoapController {
private final RestTemplate restTemplate;
private final ConferenceDataRepository conferenceDataRepository;
@Autowired
public SoapController(RestTemplate restTemplate, ConferenceDataRepository conferenceDataRepository) {
this.restTemplate = restTemplate;
this.conferenceDataRepository = conferenceDataRepository;
}
@PostMapping("/insertConferenceData")
public ResponseEntity<String> insertConferenceData(@RequestBody ConferenceData conferenceData) {
try {
// Save the conferenceData object to the database
ConferenceData savedConferenceData = conferenceDataRepository.save(conferenceData);
return new ResponseEntity<>("ConferenceData inserted with ID: " + savedConferenceData.getId(),
HttpStatus.CREATED);
} catch (Exception e) {
e.printStackTrace();
return new ResponseEntity<>("Failed to insert ConferenceData: " + e.getMessage(),
HttpStatus.INTERNAL_SERVER_ERROR);
}
}
@GetMapping("/getAllConferenceData")
public ResponseEntity<List<ConferenceData>> getAllConferenceData() {
List<ConferenceData> conferenceDataList = conferenceDataRepository.findAll();
return new ResponseEntity<>(conferenceDataList, HttpStatus.OK);
}
@PutMapping("/updateConferenceData/{id}")
public ResponseEntity<ConferenceData> updateConferenceData(@PathVariable Long id,
@RequestBody ConferenceData updatedData) {
// Implement the logic to update conference data by ID
Optional<ConferenceData> existingData = conferenceDataRepository.findById(id);
if (existingData.isPresent()) {
ConferenceData dataToUpdate = existingData.get();
// Update the fields of dataToUpdate with values from updatedData
// e.g., dataToUpdate.setName(updatedData.getName());
// ...
// Save the updated data
conferenceDataRepository.save(dataToUpdate);
return new ResponseEntity<>(dataToUpdate, HttpStatus.OK);
} else {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
}
@PatchMapping("/partialUpdateConferenceData/{id}")
public ResponseEntity<ConferenceData> partialUpdateConferenceData(@PathVariable Long id,
@RequestBody Map<String, Object> updates) {
// Implement the logic to partially update conference data by ID
Optional<ConferenceData> existingData = conferenceDataRepository.findById(id);
if (existingData.isPresent()) {
ConferenceData dataToUpdate = existingData.get();
// Apply updates from the request body to dataToUpdate
for (Map.Entry<String, Object> entry : updates.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
// Update specific fields based on the key-value pairs
// e.g., if (key.equals("name")) dataToUpdate.setName((String) value);
// ...
}
// Save the partially updated data
conferenceDataRepository.save(dataToUpdate);
return new ResponseEntity<>(dataToUpdate, HttpStatus.OK);
} else {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
}
@DeleteMapping("/deleteConferenceData/{id}")
public ResponseEntity<Void> deleteConferenceData(@PathVariable Long id) {
// Implement the logic to delete conference data by ID
conferenceDataRepository.deleteById(id);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@GetMapping("/getConferenceDataByPhone/{phone}")
public ResponseEntity<Object> getConferenceDataByPhone(@PathVariable("phone") String phone) {
Optional<ConferenceData> conferenceDataOptional = conferenceDataRepository.findByPhone(phone);
if (conferenceDataOptional.isPresent()) {
ConferenceData conferenceData = conferenceDataOptional.get();
return new ResponseEntity<>(conferenceData, HttpStatus.OK);
} else {
return new ResponseEntity<>("ConferenceData not found for phone: " + phone, HttpStatus.NOT_FOUND);
}
}
@PostMapping(value = "/callWebService", consumes = "application/soap+xml", produces = MediaType.APPLICATION_XML_VALUE)
public String callWebService(
@RequestBody String soapRequest,
@RequestHeader("Content-Type") String contentType,
@RequestHeader("SOAPAction") String soapAction) {
// Log or use the 'Content-Type' and 'SOAPAction' headers as needed
System.out.println("Content-Type: " + contentType);
System.out.println("SOAPAction: " + soapAction);
// Specify the SOAP action for your ASMX web service
String soapActionValue = soapAction;
String url = "https://clin.cmcvellore.ac.in/newconference/ConferencePay.asmx";
try {
// Create a DocumentBuilder to parse the SOAP request string
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document requestDoc = builder.parse(new InputSource(new StringReader(soapRequest)));
// Create a DOMSource from the parsed SOAP request
DOMSource requestSource = new DOMSource(requestDoc);
// Create a DOMResult to capture the response
DOMResult responseResult = new DOMResult();
// Set the Content-Type header to specify the SOAP format
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.TEXT_XML);
// Set the SOAPAction header to specify the SOAP action
headers.set("SOAPAction", soapActionValue);
// Create a HttpEntity with the headers
HttpEntity<DOMSource> httpEntity = new HttpEntity<>(requestSource, headers);
// Send the SOAP request to the external ASMX web service
ResponseEntity<String> responseEntity = restTemplate.exchange(
url,
HttpMethod.POST,
httpEntity,
String.class);
// Extract the response XML from the ResponseEntity
String responseXml = responseEntity.getBody();
// Handle the SOAP response as needed
return responseXml;
} catch (Exception e) {
// Handle exceptions
e.printStackTrace(); // You can log the exception details
return null; // Return an appropriate response or handle differently
}
}
}

View File

@ -1,5 +1,6 @@
package net.shyshkin.study.fullstack.supportportal.backend.controller;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.shyshkin.study.fullstack.supportportal.backend.constant.SecurityConstants;
@ -32,6 +33,13 @@ import static org.springframework.http.HttpStatus.OK;
@RequiredArgsConstructor
public class UserResource {
@Data
public static class UserDTO{
String username;
String password;
}
private final UserService userService;
private final AuthenticationManager authenticationManager;
private final JwtTokenProvider jwtTokenProvider;
@ -47,7 +55,8 @@ public class UserResource {
}
@PostMapping("login")
public ResponseEntity<User> login(@RequestBody User user) {
public ResponseEntity<User> login(@RequestBody UserDTO user) {
// public ResponseEntity<User> login(@RequestBody User user) {
authenticate(user.getUsername(), user.getPassword());
User byUsername = userService.findByUsername(user.getUsername());

View File

@ -0,0 +1,45 @@
package net.shyshkin.study.fullstack.supportportal.backend.domain;
import javax.persistence.*;
import java.time.LocalDateTime;
@MappedSuperclass
public abstract class BaseEntity {
@Column(nullable = false, updatable = false)
private LocalDateTime createdDate;
@Column(nullable = false)
private LocalDateTime updatedDate;
@Column(nullable = false)
private boolean isDeleted = false;
@PrePersist
protected void onCreate() {
createdDate = LocalDateTime.now();
updatedDate = LocalDateTime.now();
}
@PreUpdate
protected void onUpdate() {
updatedDate = LocalDateTime.now();
}
public LocalDateTime getCreatedDate() {
return createdDate;
}
public LocalDateTime getUpdatedDate() {
return updatedDate;
}
public boolean isDeleted() {
return isDeleted;
}
public void setDeleted(boolean deleted) {
isDeleted = deleted;
}
}

View File

@ -0,0 +1,68 @@
package net.shyshkin.study.fullstack.supportportal.backend.domain;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import lombok.Data;
@Entity
@Data
public class ConferenceData {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
// Request fields
private String conferencecode;
private String conferenceyear;
private String bankname;
private String remoteip;
private String regno;
private String candidatename;
private String nameinreceipt;
private String address1;
private String address2;
private String city;
private String state;
private String country;
private String pincode;
private String phone;
private String mobile;
private String email;
private String foodtype;
private String participanttype;
private String practicetype;
private String accompanymembers;
private String paymentamount;
private String ToWards;
private String Allow80G;
private String PanCardNo;
private String hasgst;
private String GSTReg;
private String gstnumber;
private String gstmobileno;
private String gstemailid;
private String inputcaption1;
private String inputvalue1;
private String inputcaption2;
private String inputvalue2;
private String inputcaption3;
private String inputvalue3;
private String inputcaption4;
private String inputvalue4;
private String inputcaption5;
private String inputvalue5;
// Response fields
private String responseTransid;
private String responseResultCode;
private String responseResult;
private String responseURL;
// Constructors, getters, and setters
// You can generate getters and setters for each field using your IDE or
// manually.
}

View File

@ -0,0 +1,86 @@
package net.shyshkin.study.fullstack.supportportal.backend.domain;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.Builder;
import javax.persistence.*;
import java.util.List;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Entity
@Table(name = "events")
public class Event {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(nullable = false, unique = true)
private String code;
@Column(nullable = false)
private String year;
@Column(nullable = false)
private String subject;
@Column(nullable = false)
private String title;
private String subTitle;
@Column(nullable = false)
private String date;
@ElementCollection
@CollectionTable(name = "venues", joinColumns = @JoinColumn(name = "event_id"))
private List<Venue> venue;
@ElementCollection
@CollectionTable(name = "highlights", joinColumns = @JoinColumn(name = "event_id"))
private List<String> highlights;
@ElementCollection
@CollectionTable(name = "organisers", joinColumns = @JoinColumn(name = "event_id"))
private List<String> organisers;
// @ElementCollection
// @CollectionTable(name = "fees", joinColumns = @JoinColumn(name = "event_id"))
// private List<Fee> fee;
@Column(nullable = false)
private String phone;
@Column(nullable = false)
private String email;
@Column(nullable = false)
private Boolean isActive;
@ManyToMany
@JoinTable(
name = "event_professors",
joinColumns = @JoinColumn(name = "event_id"),
inverseJoinColumns = @JoinColumn(name = "professor_id")
)
private List<Professor> professors;
// Assuming you have these classes defined as well
@Embeddable
public static class Venue {
private String title;
private String date;
private String address;
private String info;
}
@Embeddable
public static class Fee {
private String desc;
private Integer cost;
}
}

View File

@ -0,0 +1,41 @@
package net.shyshkin.study.fullstack.supportportal.backend.domain;
import javax.persistence.*;
import java.util.List;
import lombok.*;
@Entity
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@ToString
@EqualsAndHashCode(callSuper = true)
public class Post extends BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(nullable = false)
private String title;
@Column(columnDefinition = "LONGTEXT", nullable = false)
private String content;
@ManyToMany
@JoinTable(
name = "post_professors",
joinColumns = @JoinColumn(name = "post_id"),
inverseJoinColumns = @JoinColumn(name = "professor_id")
)
private List<Professor> professors;
@Column(nullable = false)
private boolean isPosted;
@ElementCollection
@CollectionTable(name = "post_tags", joinColumns = @JoinColumn(name = "post_id"))
@Column(name = "tag")
private List<String> tags;
}

View File

@ -0,0 +1,53 @@
package net.shyshkin.study.fullstack.supportportal.backend.domain;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.*;
import org.hibernate.annotations.Type;
import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
import java.util.UUID;
@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
@Builder
public class Professor implements Serializable {
private static final long serialVersionUID = -4372214856545239049L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
// @EqualsAndHashCode.Include
// @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private Long id;
@Type(type = "org.hibernate.type.UUIDCharType")
@Column(length = 36, columnDefinition = "varchar(36)", updatable = false, nullable = false)
private UUID professorId;
private String firstName;
private String lastName;
private String email;
private String department;
private String position;
private String officeLocation;
private LocalDateTime joinDate;
private String profileImageUrl;
@Enumerated(EnumType.STRING)
private WorkingStatus status; // Use enum to track detailed working status
@ManyToMany(mappedBy = "professors")
@JsonIgnore
private List<Post> posts;
}

View File

@ -0,0 +1,7 @@
package net.shyshkin.study.fullstack.supportportal.backend.domain;
public enum WorkingStatus {
ACTIVE,
ON_LEAVE,
RETIRED
}

View File

@ -0,0 +1,37 @@
package net.shyshkin.study.fullstack.supportportal.backend.domain.dto;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class PostDto {
@NotNull
private String title;
@NotNull
private String content;
@NotEmpty(message = "At least one professor must be selected.")
private List<Long> professors;
private List<String> tags;
private boolean posted;
// Getters and setters
// ...
}

View File

@ -0,0 +1,37 @@
package net.shyshkin.study.fullstack.supportportal.backend.domain.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import net.shyshkin.study.fullstack.supportportal.backend.domain.Role;
import net.shyshkin.study.fullstack.supportportal.backend.domain.WorkingStatus;
import org.springframework.web.multipart.MultipartFile;
import java.time.LocalDateTime;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class ProfessorDto {
@NotEmpty(message = "Should not be empty")
private String firstName;
private String lastName;
private String email;
private String department;
private String position;
private String officeLocation;
private WorkingStatus status;
private LocalDateTime joinDate;
private MultipartFile profileImage; // Optional field for profile image URL
}

View File

@ -0,0 +1,8 @@
package net.shyshkin.study.fullstack.supportportal.backend.exception.domain;
public class ProfessorNotFoundException extends RuntimeException {
public ProfessorNotFoundException(String message) {
super(message);
}
}

View File

@ -0,0 +1,32 @@
package net.shyshkin.study.fullstack.supportportal.backend.mapper;
import net.shyshkin.study.fullstack.supportportal.backend.domain.Professor;
import net.shyshkin.study.fullstack.supportportal.backend.domain.dto.ProfessorDto;
import net.shyshkin.study.fullstack.supportportal.backend.domain.WorkingStatus;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Named;
@Mapper
public interface ProfessorMapper {
// @Mapping(target = "professorId", ignore = true) // Auto-generated
@Mapping(target = "joinDate", expression = "java(java.time.LocalDateTime.now())") // Default value
@Mapping(target = "status", source = "status", qualifiedByName = "stringToWorkingStatus")
Professor toEntity(ProfessorDto professorDto);
@Mapping(target = "profileImage", ignore = true) // Ignore profileImage mapping
@Mapping(target = "status", source = "status", qualifiedByName = "workingStatusToString")
ProfessorDto toDto(Professor professor);
@Named("stringToWorkingStatus")
default WorkingStatus stringToWorkingStatus(String status) {
return status == null ? null : WorkingStatus.valueOf(status);
}
@Named("workingStatusToString")
default String workingStatusToString(WorkingStatus status) {
return status == null ? null : status.name();
}
}

View File

@ -17,4 +17,4 @@ public interface UserMapper {
@Mapping(target = "authorities", source = "role.authorities")
User toEntity(UserDto userDto);
}
}

View File

@ -0,0 +1,49 @@
package net.shyshkin.study.fullstack.supportportal.backend.mapper;
// import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "YourSoapRequest")
public class YourSoapRequest {
private String conferencecode;
private String conferenceyear;
private String bankname;
private String remoteip;
private String regno;
private String candidatename;
private String nameinreceipt;
private String address1;
private String address2;
private String city;
private String state;
private String country;
private String pincode;
private String phone;
private String mobile;
private String email;
private String foodtype;
private String participanttype;
private String practicetype;
private String accompanymembers;
private String paymentamount;
private String ToWards;
private String Allow80G;
private String PanCardNo;
private String hasgst;
private String GSTReg;
private String gstnumber;
private String gstmobileno;
private String gstemailid;
private String inputcaption1;
private String inputvalue1;
private String inputcaption2;
private String inputvalue2;
private String inputcaption3;
private String inputvalue3;
private String inputcaption4;
private String inputvalue4;
private String inputcaption5;
private String inputvalue5;
// Add getters and setters for each property
}

View File

@ -0,0 +1,15 @@
package net.shyshkin.study.fullstack.supportportal.backend.repository;
import java.util.Optional;
import org.springframework.data.jpa.repository.JpaRepository;
import net.shyshkin.study.fullstack.supportportal.backend.domain.ConferenceData;
// import org.springframework.data.rest.core.annotation.RepositoryRestResource;
// @RepositoryRestResource(path = "conferences")
public interface ConferenceDataRepository extends JpaRepository<ConferenceData, Long> {
Optional<ConferenceData> findByPhone(String phone); // Change 'phone' to your actual field name
}

View File

@ -0,0 +1,11 @@
package net.shyshkin.study.fullstack.supportportal.backend.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import net.shyshkin.study.fullstack.supportportal.backend.domain.Event;
@Repository
public interface EventRepository extends JpaRepository<Event, Long> {
// Custom query methods can be added here if needed
}

View File

@ -0,0 +1,28 @@
package net.shyshkin.study.fullstack.supportportal.backend.repository;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import net.shyshkin.study.fullstack.supportportal.backend.domain.Post;
@Repository
public interface PostRepository extends JpaRepository<Post, Long> {
// Additional query methods can be defined here if needed
// 1. Find all posts where isPosted is true
List<Post> findAllByIsPostedTrue();
// 3. Find all posts associated with a specific tag where isPosted is true
@Query("SELECT p FROM Post p JOIN p.tags t WHERE t = :tag AND p.isPosted = true")
List<Post> findAllByTagAndIsPostedTrue(@Param("tag") String tag);
// Custom query to count unique tags
@Query("SELECT t, COUNT(t) FROM Post p JOIN p.tags t GROUP BY t")
List<Object[]> findTagsWithCount();
}

View File

@ -0,0 +1,27 @@
package net.shyshkin.study.fullstack.supportportal.backend.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
// import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import java.util.Optional;
import java.util.UUID;
import net.shyshkin.study.fullstack.supportportal.backend.domain.Professor;
// @RepositoryRestResource(collectionResourceRel = "professors", path = "professors")
public interface ProfessorRepository extends JpaRepository<Professor, Long> {
@Query("SELECT p FROM Professor p WHERE p.email = :email")
Optional<Professor> findByEmail(@Param("email") String email);
@Query("SELECT CASE WHEN COUNT(p) > 0 THEN TRUE ELSE FALSE END FROM Professor p WHERE p.email = :email")
Boolean existsByEmail(@Param("email") String email);
Boolean existsByProfessorId(UUID professorId);
@Query("SELECT p FROM Professor p WHERE p.professorId = :professorId")
Optional<Professor> findByProfessorId(@Param("professorId") UUID professorId);
}

View File

@ -18,7 +18,6 @@ public class EmailService {
private final Environment environment;
public void sendNewPasswordEmail(String firstName, String password, String email) {
// Create a Simple MailMessage.
SimpleMailMessage message = new SimpleMailMessage();
message.setTo(email);
@ -35,7 +34,20 @@ public class EmailService {
message.setSubject(EMAIL_SUBJECT);
message.setText("Hello " + firstName + "!\n\nYour new account password is: " + password + "\n\nThe Support Team");
// Send Message!
this.emailSender.send(message);
// Log the email details before sending
log.info("Preparing to send email:");
log.info("From: {}", message.getFrom());
log.info("To: {}", String.join(", ", message.getTo()));
log.info("Cc: {}", String.join(", ", message.getCc()));
log.info("Subject: {}", message.getSubject());
log.info("Text: {}", message.getText());
try {
// Send Message!
this.emailSender.send(message);
log.info("Email successfully sent to {}", email);
} catch (Exception e) {
log.error("Failed to send email to {}. Error: {}", email, e.getMessage());
}
}
}

View File

@ -0,0 +1,32 @@
package net.shyshkin.study.fullstack.supportportal.backend.service;
import net.shyshkin.study.fullstack.supportportal.backend.domain.Professor;
import net.shyshkin.study.fullstack.supportportal.backend.domain.dto.ProfessorDto;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.web.multipart.MultipartFile;
import java.util.UUID;
public interface ProfessorService {
Professor register(String firstName, String lastName, String email, String department, String position);
Page<Professor> findAll(Pageable pageable);
Professor findByEmail(String email);
Professor findByProfessorId(UUID professorId);
Professor addNewProfessor(ProfessorDto professorDto);
Professor updateProfessor(UUID professorId, ProfessorDto professorDto);
void deleteProfessor(UUID professorId);
Professor updateProfileImage(UUID professorId, MultipartFile profileImage);
byte[] getImageByProfessorId(UUID professorId, String filename);
byte[] getDefaultProfileImage(UUID professorId);
}

View File

@ -0,0 +1,237 @@
package net.shyshkin.study.fullstack.supportportal.backend.service;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.shyshkin.study.fullstack.supportportal.backend.domain.Professor;
import net.shyshkin.study.fullstack.supportportal.backend.domain.dto.ProfessorDto;
import net.shyshkin.study.fullstack.supportportal.backend.exception.domain.EmailExistsException;
import net.shyshkin.study.fullstack.supportportal.backend.exception.domain.NotAnImageFileException;
import net.shyshkin.study.fullstack.supportportal.backend.exception.domain.ProfessorNotFoundException;
import net.shyshkin.study.fullstack.supportportal.backend.mapper.ProfessorMapper;
import net.shyshkin.study.fullstack.supportportal.backend.repository.ProfessorRepository;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.RequestEntity;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
import org.springframework.boot.web.client.RestTemplateBuilder;
import javax.annotation.PostConstruct;
import javax.transaction.Transactional;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
import static net.shyshkin.study.fullstack.supportportal.backend.constant.FileConstant.*;
import static org.springframework.http.MediaType.*;
@Slf4j
@Service
@RequiredArgsConstructor
public class ProfessorServiceImpl implements ProfessorService {
public static final String EMAIL_NOT_FOUND_MSG = "Professor with email `%s` not found";
public static final String EMAIL_EXISTS_MSG = "Professor with email `%s` is already registered";
public static final String PROFESSOR_NOT_FOUND_MSG = "Professor not found";
private final ProfessorRepository professorRepository;
private final PasswordEncoder passwordEncoder;
private final EmailService emailService;
private final ProfessorMapper professorMapper;
private final ProfileImageService profileImageService;
private final RestTemplateBuilder restTemplateBuilder;
private RestTemplate restTemplate;
@PostConstruct
void init() {
restTemplate = restTemplateBuilder
.rootUri(TEMP_PROFILE_IMAGE_BASE_URL)
.build();
}
@Override
@Transactional
public Professor register(String firstName, String lastName, String email, String department, String position) {
ProfessorDto professorDto = ProfessorDto.builder()
.firstName(firstName)
.lastName(lastName)
.email(email)
.department(department)
.position(position)
.build();
return addNewProfessor(professorDto);
}
private String generateDefaultProfileImageUrl(UUID professorId) {
return ServletUriComponentsBuilder.fromCurrentContextPath()
.path(String.format(DEFAULT_USER_IMAGE_URI_PATTERN, professorId))
.toUriString();
}
private String generateProfileImageUrl(UUID professorId) {
return ServletUriComponentsBuilder.fromCurrentContextPath()
.path(String.format(DEFAULT_USER_IMAGE_URI_PATTERN, professorId))
.pathSegment(USER_IMAGE_FILENAME)
.toUriString();
}
@Override
public Page<Professor> findAll(Pageable pageable) {
return professorRepository.findAll(pageable);
}
@Override
public Professor findByEmail(String email) {
return professorRepository
.findByEmail(email)
.orElseThrow(() -> new EmailExistsException(String.format(EMAIL_NOT_FOUND_MSG, email)));
}
@Override
public Professor findByProfessorId(UUID professorId) {
return professorRepository
.findByProfessorId(professorId)
.orElseThrow(() -> new ProfessorNotFoundException(PROFESSOR_NOT_FOUND_MSG));
}
private void saveProfileImage(Professor professor, MultipartFile profileImage) {
if (profileImage == null) return;
if (!List.of(IMAGE_JPEG_VALUE, IMAGE_GIF_VALUE, IMAGE_PNG_VALUE).contains(profileImage.getContentType())) {
throw new NotAnImageFileException(profileImage.getOriginalFilename() + " is not an image file. Please upload an image");
}
String imageUrl = profileImageService.persistProfileImage(professor.getProfessorId(), profileImage, USER_IMAGE_FILENAME);
if (imageUrl == null)
imageUrl = generateProfileImageUrl(professor.getProfessorId());
professor.setProfileImageUrl(imageUrl);
professorRepository.save(professor);
}
private void clearProfessorStorage(Professor professor) {
profileImageService.clearUserStorage(professor.getProfessorId());
}
private UUID generateUuid() {
return UUID.randomUUID();
}
@Override
public Professor addNewProfessor(ProfessorDto professorDto) {
validateNewEmail(professorDto.getEmail());
Professor professor = professorMapper.toEntity(professorDto);
// Set a unique identifier for the professor
professor.setProfessorId(generateUuid());
// professor.setProfessorId(UUID.randomUUID()); // Set a unique identifier for the professor
professor.setJoinDate(LocalDateTime.now()); // Set join date if not provided
professor.setProfileImageUrl(generateDefaultProfileImageUrl(professor.getProfessorId()));
professorRepository.save(professor);
// saveProfileImage(professor, professorDto.getProfileImage());
return professor;
}
@Override
public Professor updateProfessor(UUID professorId, ProfessorDto professorDto) {
Professor professor = professorRepository.findByProfessorId(professorId)
.orElseThrow(() -> new RuntimeException("Professor not found with id: " + professorId));
validateUpdateEmail(professorId,professorDto.getEmail());
professor.setFirstName(professorDto.getFirstName());
professor.setLastName(professorDto.getLastName());
professor.setEmail(professorDto.getEmail());
professor.setDepartment(professorDto.getDepartment());
professor.setPosition(professorDto.getPosition());
professor.setOfficeLocation(professorDto.getOfficeLocation());
professor.setStatus(professorDto.getStatus());
professor.setJoinDate(professorDto.getJoinDate()); // Update join date if provided
professorRepository.save(professor);
saveProfileImage(professor, professorDto.getProfileImage());
return professor;
}
@Override
public void deleteProfessor(UUID professorId) {
Professor professorToBeDeleted = professorRepository
.findByProfessorId(professorId)
.orElseThrow(() -> new ProfessorNotFoundException(PROFESSOR_NOT_FOUND_MSG));
clearProfessorStorage(professorToBeDeleted);
professorRepository.delete(professorToBeDeleted);
}
@Override
public Professor updateProfileImage(UUID professorId, MultipartFile profileImage) {
Professor professor = findByProfessorId(professorId);
saveProfileImage(professor, profileImage);
return professor;
}
@Override
public byte[] getImageByProfessorId(UUID professorId, String filename) {
if (!professorRepository.existsByProfessorId(professorId)) {
throw new ProfessorNotFoundException(PROFESSOR_NOT_FOUND_MSG);
}
return profileImageService.retrieveProfileImage(professorId, filename);
}
@Override
public byte[] getDefaultProfileImage(UUID professorId) {
if (!professorRepository.existsByProfessorId(professorId)) {
throw new ProfessorNotFoundException(PROFESSOR_NOT_FOUND_MSG);
}
RequestEntity<Void> requestEntity = RequestEntity
.get("/{professorId}", professorId)
.accept(IMAGE_JPEG)
.build();
var responseEntity = restTemplate.exchange(requestEntity, new ParameterizedTypeReference<byte[]>() {});
return responseEntity.getBody();
}
private void validateNewEmail(String email) {
if (professorRepository.existsByEmail(email)) {
throw new EmailExistsException(String.format(EMAIL_EXISTS_MSG, email));
}
}
private Professor validateUpdateEmail(UUID professorId, String email) {
Objects.requireNonNull(professorId);
Professor currentProfessor = findByProfessorId(professorId);
if (!Objects.equals(currentProfessor.getEmail(), email) && professorRepository.existsByEmail(email)) {
throw new EmailExistsException(String.format(EMAIL_EXISTS_MSG, email));
}
return currentProfessor;
}
}

View File

@ -1,4 +1,4 @@
package net.shyshkin.study.fullstack.supportportal.backend.service;
package net.shyshkin.study.fullstack.supportportal.backend.service;
import com.amazonaws.AmazonServiceException;
import com.amazonaws.SdkClientException;

View File

@ -35,3 +35,5 @@ public interface UserService extends UserDetailsService {
byte[] getDefaultProfileImage(UUID userId);
}

View File

@ -8,6 +8,7 @@ import net.shyshkin.study.fullstack.supportportal.backend.domain.UserPrincipal;
import net.shyshkin.study.fullstack.supportportal.backend.domain.dto.UserDto;
import net.shyshkin.study.fullstack.supportportal.backend.exception.domain.*;
import net.shyshkin.study.fullstack.supportportal.backend.mapper.UserMapper;
import net.shyshkin.study.fullstack.supportportal.backend.repository.ProfessorRepository;
import net.shyshkin.study.fullstack.supportportal.backend.repository.UserRepository;
import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.boot.web.client.RestTemplateBuilder;
@ -45,6 +46,7 @@ public class UserServiceImpl implements UserService {
public static final String EMAIL_EXISTS_MSG = "User with email `%s` is already registered";
private final UserRepository userRepository;
private final ProfessorRepository professorRepository;
private final PasswordEncoder passwordEncoder;
private final LoginAttemptService loginAttemptService;
private final EmailService emailService;
@ -264,10 +266,14 @@ public class UserServiceImpl implements UserService {
@Override
public byte[] getDefaultProfileImage(UUID userId) {
if (!userRepository.existsByUserId(userId)) {
if (!userRepository.existsByUserId(userId) && !professorRepository.existsByProfessorId(userId)) {
throw new UserNotFoundException(USER_NOT_FOUND_MSG);
}
// if (!professorRepository.existsByProfessorId(userId)) {
// throw new UserNotFoundException(USER_NOT_FOUND_MSG);
// }
// "https://robohash.org/11951691-d373-4126-bef2-84d157a6546b"
RequestEntity<Void> requestEntity = RequestEntity
.get("/{userId}", userId)

View File

@ -4,25 +4,29 @@ server:
# whitelabel:
# enabled: false
spring:
mail:
host: smtp.gmail.com
host: mail.techzoos.in
port: 587
username: ${PORTAL_MAIL_USERNAME:fake.user@gmail.com}
password: ${PORTAL_MAIL_PASSWORD:fake_password}
username: ${PORTAL_MAIL_USERNAME:govardhan@techzoos.in}
password: ${PORTAL_MAIL_PASSWORD:123456}
properties:
mail:
transport:
protocol: smtp
smtp:
auth: true
auth: false
starttls:
enable: true
ssl:
enable: false
datasource:
url: jdbc:mysql://210.18.189.94:8098/demo
username: youruser
password: youruserpassword
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://mysql:3306/support-portal
username: ENC(criE3etnc/EVZbizNgNdmj+8F0BYC3bSVBK1VT/xJ7WMoNvSfdEGsqWfCpaX5lEWvXLOO8pzgjdB5zIOBcTikw==)
password: ENC(OTG4nZfio2dHHxV0Ey/Nmb4XeEfaD1YMsRVQxOwF59Q1JSBZPUKLWXORJXPz2RysKRngcdk2SgioAMw166DoqA==)
jpa:
hibernate:
ddl-auto: update
@ -39,87 +43,100 @@ spring:
web:
resources:
add-mappings: false
app:
public-urls: /user/login,/user/register,/user/*/profile-image/**
public-urls: /user/login,/user/register,/user/*/profile-image/**,/professors,/professors/**
cors:
allowed-origins: http://localhost:4200,https://localhost:4200,http://art-support-portal.s3-website.eu-north-1.amazonaws.com,http://portal.shyshkin.net
allowed-origins: http://localhost:4200,https://localhost:4200,http://art-support-portal.s3-website.eu-north-1.amazonaws.com,http://portal.shyshkin.net,*
jwt:
secret: ENC(EfWSJqncgjSJ0g/tMzLoO9PlrjmpQf8Eb+q51SUXlh3AzwMHJyTF1gV0VpuNEQkNb9Lsw62xOBnxDNe73BsPDQ==)
secret: custom_text
# secret: ${random.value} #Does not work - every time generates new value
jasypt:
encryptor:
password: ${JASYPT_PASSWORD}
algorithm: PBEWITHHMACSHA512ANDAES_256
iv-generator-classname: org.jasypt.iv.RandomIvGenerator
# jasypt:
# encryptor:
# # password: ${JASYPT_PASSWORD}
# password: custom_text
# algorithm: PBEWITHHMACSHA512ANDAES_256
# iv-generator-classname: org.jasypt.iv.RandomIvGenerator
---
spring:
config:
activate:
on-profile: local
datasource:
url: jdbc:mysql://localhost:23306/support-portal
jpa:
show-sql: true
logging:
level:
net.shyshkin: debug
# spring:
# config:
# activate:
# on-profile: local
# datasource:
# url: jdbc:mysql://210.18.189.94:8098/demo
# username: youruser
# password: youruserpassword
# jpa:
# show-sql: true
# logging:
# level:
# net.shyshkin: debug
---
spring:
config:
activate:
on-profile: aws-local
datasource:
url: jdbc:mysql://localhost:3306/support_portal
username: support_portal_user
password: Supp0rt_Porta!_P@ssword
mail:
host: email-smtp.eu-north-1.amazonaws.com
port: 587
username: AKIAVW7XGDOWFHHCELIH
password: BJyWOWS1xWYR35MRCFn3BuuQ6vY+k7DRsdAvOfqDs/Fk
# spring:
# config:
# activate:
# on-profile: aws-local
# datasource:
# url: jdbc:mysql://210.18.189.94:8098/demo
# username: youruser
# password: youruserpassword
# mail:
# host: email-smtp.eu-north-1.amazonaws.com
# port: 587
# username: AKIAVW7XGDOWFHHCELIH
# password: BJyWOWS1xWYR35MRCFn3BuuQ6vY+k7DRsdAvOfqDs/Fk
# we want to test (1) from localhost, (2) from S3 bucket Static Web Site, (3) from our EC2 instance
app:
email:
from: d.art.shishkin@gmail.com
carbon-copy: d.art.shishkin@gmail.com
cors:
allowed-origins: http://localhost:4200,http://art-support-portal.s3-website.eu-north-1.amazonaws.com,http://support-portal.shyshkin.net,http://portal.shyshkin.net
server:
port: 5000
logging:
level:
net.shyshkin: debug
# app:
# email:
# from: d.art.shishkin@gmail.com
# carbon-copy: d.art.shishkin@gmail.com
# cors:
# allowed-origins: http://localhost:4200,http://art-support-portal.s3-website.eu-north-1.amazonaws.com,http://support-portal.shyshkin.net,http://portal.shyshkin.net
# server:
# port: 5000
# logging:
# level:
# net.shyshkin: debug
---
spring:
config:
activate:
on-profile: aws-rds
datasource:
url: jdbc:mysql://portal-db.coaum9neetxc.eu-north-1.rds.amazonaws.com:3306/support_portal
username: ENC(MPap/iQmyyLSeulVzLLq4nQ5dcwMyJ1cbW+bW7MOU4pN7CHQULbaDn8/5VszOP9F)
password: ENC(nC0PV+0wPW+73o2uOh4Zg7EA34vdwZKpkPD4CIKvjDDXQ+dGXjykTuHUl3jlxkRC/00IpFurk/UJ9hTpZ6QqGA==)
mail:
host: email-smtp.eu-north-1.amazonaws.com
port: 587
username: ENC(CgaSXOMqTmswes1PgAYp3ICcoIVVXyKUlDR1Se963Vja02cBIor/2884e2OEFKW4XhBClTbuZCVdHK0vRRNqYg==)
password: ENC(GA8XsfU8vmat/7A8qEhrVz0Y47THxNT8jQ29wSg035fozwW7m+fKhJMQd4tgxL9dPfOzSXYzkffL0fG1AihWiHl99H9iBeXndDSvOhskvh4=)
# spring:
# config:
# activate:
# on-profile: aws-rds
# datasource:
# url: jdbc:mysql://210.18.189.94:8098/demo
# username: youruser
# password: youruserpassword
# mail:
# host: email-smtp.eu-north-1.amazonaws.com
# port: 587
# username: custom_text
# password: custom_text
# we want to test (1) from localhost, (2) from S3 bucket Static Web Site, (3) from our EC2 instance
app:
email:
from: d.art.shishkin@gmail.com
carbon-copy: d.art.shishkin@gmail.com
cors:
allowed-origins: http://localhost:4200,http://art-support-portal.s3-website.eu-north-1.amazonaws.com,http://support-portal.shyshkin.net,http://portal.shyshkin.net
server:
port: 5000
logging:
level:
net.shyshkin: debug
# app:
# email:
# from: d.art.shishkin@gmail.com
# carbon-copy: d.art.shishkin@gmail.com
# cors:
# allowed-origins: http://localhost:4200,http://art-support-portal.s3-website.eu-north-1.amazonaws.com,http://support-portal.shyshkin.net,http://portal.shyshkin.net
# server:
# port: 5000
# logging:
# level:
# net.shyshkin: debug
#####
#
@ -127,37 +144,37 @@ logging:
#
#####
server.ssl:
enabled: true # Enable HTTPS support (only accept HTTPS requests)
key-alias: securedPortal # Alias that identifies the key in the key store
key-store: classpath:securedPortal-keystore.p12 # Keystore location
key-store-password: ENC(nqDHyVFmySdbaCOZfj4EiQLRYyLSPLRLq/OzncqlsFIuWvh8caiOapAb+zrKR1+A) # Keystore password
key-store-type: PKCS12 # Keystore format
# server.ssl:
# enabled: true # Enable HTTPS support (only accept HTTPS requests)
# key-alias: securedPortal # Alias that identifies the key in the key store
# key-store: classpath:securedPortal-keystore.p12 # Keystore location
# key-store-password: custom_text
# key-store-type: PKCS12 # Keystore format
---
spring:
config:
activate:
on-profile: image-s3
app:
amazon-s3:
bucket-name: portal-user-profile-images
# ---
# spring:
# config:
# activate:
# on-profile: image-s3
# app:
# amazon-s3:
# bucket-name: portal-user-profile-images
---
spring:
config:
activate:
on-profile: image-s3-localstack
app:
amazon-s3:
bucket-name: portal-user-profile-images
config:
aws:
region: eu-north-1
s3:
url: http://127.0.0.1:4566
bucket-name: portal-user-profile-images
access-key: localstack
secret-key: localstack
# ---
# spring:
# config:
# activate:
# on-profile: image-s3-localstack
# app:
# amazon-s3:
# bucket-name: portal-user-profile-images
# config:
# aws:
# region: eu-north-1
# s3:
# url: http://127.0.0.1:4566
# bucket-name: portal-user-profile-images
# access-key: localstack
# secret-key: localstack

View File

@ -114,6 +114,9 @@ class UserResourceTest extends BaseUserTest {
//when
ResponseEntity<User> responseEntity = restTemplate.postForEntity("/user/register", fakeUser, User.class);
//then
log.debug("Response Entity: {}", responseEntity);
assertThat(responseEntity.getStatusCode()).isEqualTo(OK);
@ -131,6 +134,7 @@ class UserResourceTest extends BaseUserTest {
;
user = registeredUser;
}
@Test
@Order(40)