Browse Source
URL Changed Based on Domain and nginx
URL Changed Based on Domain and nginx
For domain access, we utilize Nginx, which functions as both a web server and a reverse proxy. It directs base URL requests to the localhost server URL and facilitates access to files outside the web server based on the specified path (such as for uploading files).main
38 changed files with 480 additions and 152 deletions
-
5src/main/java/in/gov/chennaicorporation/gccoffice/configuration/JacksonConfiguration.java
-
16src/main/java/in/gov/chennaicorporation/gccoffice/configuration/SecurityConfig.java
-
56src/main/java/in/gov/chennaicorporation/gccoffice/controller/APIController.java
-
73src/main/java/in/gov/chennaicorporation/gccoffice/controller/FileController.java
-
7src/main/java/in/gov/chennaicorporation/gccoffice/controller/MainController.java
-
35src/main/java/in/gov/chennaicorporation/gccoffice/interceptor/AppInterceptor.java
-
2src/main/java/in/gov/chennaicorporation/gccoffice/petregistration/controller/APIController.java
-
2src/main/java/in/gov/chennaicorporation/gccoffice/petregistration/controller/MainController.java
-
1src/main/java/in/gov/chennaicorporation/gccoffice/pgr/controller/MainController.java
-
1src/main/java/in/gov/chennaicorporation/gccoffice/pgr/service/PGRCommon.java
-
2src/main/java/in/gov/chennaicorporation/gccoffice/repository/AppUserRepository.java
-
38src/main/java/in/gov/chennaicorporation/gccoffice/service/Base64Util.java
-
1src/main/java/in/gov/chennaicorporation/gccoffice/service/CustomUserDetailsService.java
-
2src/main/java/in/gov/chennaicorporation/gccoffice/service/LoginUserInfo.java
-
BINsrc/main/resources/.DS_Store
-
18src/main/resources/application.properties
-
BINsrc/main/resources/static/.DS_Store
-
BINsrc/main/resources/static/assets/.DS_Store
-
BINsrc/main/resources/static/assets/dist/.DS_Store
-
4src/main/resources/static/assets/dist/css/theme.css
-
BINsrc/main/resources/static/assets/images/.DS_Store
-
BINsrc/main/resources/templates/.DS_Store
-
2src/main/resources/templates/fragments/modules/base/footer.html
-
28src/main/resources/templates/fragments/modules/base/header.html
-
2src/main/resources/templates/fragments/modules/base/menu.html
-
163src/main/resources/templates/index.html
-
2src/main/resources/templates/modules/admin/user-group-access.html
-
2src/main/resources/templates/modules/admin/user-list.html
-
6src/main/resources/templates/modules/mtm/index.html
-
6src/main/resources/templates/modules/mtm/officer/index.html
-
16src/main/resources/templates/modules/petregistration/accepted-list.html
-
2src/main/resources/templates/modules/petregistration/index.html
-
14src/main/resources/templates/modules/petregistration/license-issued.html
-
18src/main/resources/templates/modules/petregistration/rejected.html
-
18src/main/resources/templates/modules/petregistration/request-list.html
-
12src/main/resources/templates/modules/pgr/all-list.html
-
56src/main/resources/templates/modules/pgr/index.html
-
18src/main/resources/templates/modules/qrfeedback/index.html
@ -0,0 +1,73 @@ |
|||||
|
package in.gov.chennaicorporation.gccoffice.controller; |
||||
|
|
||||
|
import org.springframework.beans.factory.annotation.Value; |
||||
|
import org.springframework.core.io.Resource; |
||||
|
import org.springframework.core.io.UrlResource; |
||||
|
import org.springframework.http.HttpHeaders; |
||||
|
import org.springframework.http.MediaType; |
||||
|
import org.springframework.http.ResponseEntity; |
||||
|
import org.springframework.stereotype.Controller; |
||||
|
import org.springframework.web.bind.annotation.GetMapping; |
||||
|
import org.springframework.web.bind.annotation.PathVariable; |
||||
|
import org.springframework.web.servlet.HandlerMapping; |
||||
|
|
||||
|
import java.nio.file.Path; |
||||
|
import java.nio.file.Paths; |
||||
|
|
||||
|
import javax.servlet.http.HttpServletRequest; |
||||
|
|
||||
|
@Controller |
||||
|
public class FileController { |
||||
|
|
||||
|
@Value("${file.upload.directory}") |
||||
|
private String uploadDirectory; |
||||
|
|
||||
|
@GetMapping("/gcc/files/{directoryPath}/**") |
||||
|
public ResponseEntity<Resource> serveFile(@PathVariable String directoryPath, HttpServletRequest request) { |
||||
|
String fullPath = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE); |
||||
|
System.out.println(fullPath.toString()+"\n"+directoryPath.length()+"\n directoryPath:"+directoryPath); |
||||
|
//String relativePath = fullPath.substring(directoryPath.length() + 1); // Adding 1 for the trailing '/' |
||||
|
String relativePath = fullPath.replace("/gcc/files", ""); |
||||
|
String filePath = uploadDirectory + "/" + relativePath; |
||||
|
Path path = Paths.get(filePath).normalize(); |
||||
|
System.out.println(path.toString()); |
||||
|
Resource resource; |
||||
|
try { |
||||
|
resource = new UrlResource(path.toUri()); |
||||
|
if (resource.exists() || resource.isReadable()) { |
||||
|
MediaType mediaType = MediaType.APPLICATION_OCTET_STREAM; |
||||
|
// Determine content type based on file extension |
||||
|
String fileName = resource.getFilename(); |
||||
|
if (fileName != null) { |
||||
|
String fileExtension = fileName.substring(fileName.lastIndexOf(".") + 1); |
||||
|
switch (fileExtension.toLowerCase()) { |
||||
|
case "jpg": |
||||
|
case "jpeg": |
||||
|
mediaType = MediaType.IMAGE_JPEG; |
||||
|
break; |
||||
|
case "png": |
||||
|
mediaType = MediaType.IMAGE_PNG; |
||||
|
break; |
||||
|
case "gif": |
||||
|
mediaType = MediaType.IMAGE_GIF; |
||||
|
break; |
||||
|
case "pdf": |
||||
|
mediaType = MediaType.APPLICATION_PDF; |
||||
|
break; |
||||
|
// Add more cases for other file types if needed |
||||
|
} |
||||
|
} |
||||
|
return ResponseEntity.ok() |
||||
|
.contentType(mediaType) |
||||
|
.header(HttpHeaders.CONTENT_DISPOSITION, "inline; filename=\"" + resource.getFilename() + "\"") |
||||
|
//.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + resource.getFilename() + "\"") |
||||
|
.body(resource); |
||||
|
} else { |
||||
|
return ResponseEntity.notFound().build(); |
||||
|
} |
||||
|
} catch (Exception e) { |
||||
|
return ResponseEntity.notFound().build(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
@ -0,0 +1,38 @@ |
|||||
|
package in.gov.chennaicorporation.gccoffice.service; |
||||
|
|
||||
|
import java.util.Base64; |
||||
|
import java.util.List; |
||||
|
|
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
|
||||
|
@Service |
||||
|
public class Base64Util { |
||||
|
|
||||
|
// Encode to Base64 |
||||
|
public static String encodeBase64(String value) { |
||||
|
if (value != null && !value.isEmpty()) { |
||||
|
byte[] encodedBytes = Base64.getEncoder().encode(value.getBytes()); |
||||
|
return new String(encodedBytes); |
||||
|
} |
||||
|
else { |
||||
|
return ""; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// Decode from Base64 |
||||
|
public static String decodeBase64(String encodedValue) { |
||||
|
if (encodedValue != null && !encodedValue.isEmpty()) { |
||||
|
try { |
||||
|
byte[] decodedBytes = Base64.getDecoder().decode(encodedValue); |
||||
|
return new String(decodedBytes); |
||||
|
} catch (IllegalArgumentException e) { |
||||
|
// Handle the exception, e.g., log it or return an error message |
||||
|
System.err.println("Error decoding Base64 string: " + e.getMessage()); |
||||
|
return "error"; // Or return an error message string |
||||
|
} |
||||
|
} else { |
||||
|
return ""; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,5 +1,5 @@ |
|||||
<footer class="footer"> |
<footer class="footer"> |
||||
<form id="logout-form" th:action="@{/logout}" method="post" style="display: none;"></form> |
|
||||
|
<form id="logout-form" th:action="@{/gcc/logout}" method="post" style="display: none;"></form> |
||||
<div class="w-100 clearfix"> |
<div class="w-100 clearfix"> |
||||
<span class="text-center text-sm-left d-md-inline-block">Copyright © Greater Chennai Corporation | All rights reserved</span> |
<span class="text-center text-sm-left d-md-inline-block">Copyright © Greater Chennai Corporation | All rights reserved</span> |
||||
<span class="float-none float-sm-right mt-1 mt-sm-0 text-center">Coded By BonTon Softwares Pvt Ltd</span> |
<span class="float-none float-sm-right mt-1 mt-sm-0 text-center">Coded By BonTon Softwares Pvt Ltd</span> |
||||
|
|||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue