site builder
This commit is contained in:
parent
cae91284c5
commit
0ced644864
@ -10,9 +10,6 @@ import org.apache.commons.io.FileUtils;
|
|||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
|
|
||||||
import com.realnet.fnd.response.EntityResponse;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class FileHelper {
|
public class FileHelper {
|
||||||
|
|||||||
@ -114,20 +114,7 @@ public class SureOpsController {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/run")
|
@PostMapping("/SiteTree/createFile")
|
||||||
public ResponseEntity<?> runWorkflow(@RequestParam Integer projId, @RequestParam String workflowId)
|
|
||||||
throws IOException, InterruptedException {
|
|
||||||
|
|
||||||
int status_code = 500;
|
|
||||||
|
|
||||||
long Deployment_profile = 2l;
|
|
||||||
// NOW MAKE SHELLSCRIPT THAT CLONE FROM REPOSITORY
|
|
||||||
ResponseEntity<?> get = script_serviceMaking.CreateFiles(projId, workflowId, Deployment_profile);
|
|
||||||
return new ResponseEntity<>(new EntityResponse(get.getBody().toString()), HttpStatus.BAD_REQUEST);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/createFile")
|
|
||||||
public void createHtmlFiles(@RequestParam Integer projId, @RequestBody Map<String, String> pageHtmlMap)
|
public void createHtmlFiles(@RequestParam Integer projId, @RequestBody Map<String, String> pageHtmlMap)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
|
||||||
@ -158,4 +145,17 @@ public class SureOpsController {
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/run")
|
||||||
|
public ResponseEntity<?> runWorkflow(@RequestParam Integer projId, @RequestParam String workflowId)
|
||||||
|
throws IOException, InterruptedException {
|
||||||
|
|
||||||
|
int status_code = 500;
|
||||||
|
|
||||||
|
long Deployment_profile = 2l;
|
||||||
|
// NOW MAKE SHELLSCRIPT THAT CLONE FROM REPOSITORY
|
||||||
|
ResponseEntity<?> get = script_serviceMaking.CreateFiles(projId, workflowId, Deployment_profile);
|
||||||
|
return new ResponseEntity<>(new EntityResponse(get.getBody().toString()), HttpStatus.BAD_REQUEST);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -46,6 +46,7 @@ public class Design_lbrary extends Extension {
|
|||||||
|
|
||||||
private String uitype;
|
private String uitype;
|
||||||
|
|
||||||
|
private String tag;
|
||||||
private String typerender;
|
private String typerender;
|
||||||
|
|
||||||
private Integer hedaer_id;
|
private Integer hedaer_id;
|
||||||
|
|||||||
@ -38,4 +38,8 @@ public interface Design_lbraryRepository extends JpaRepository<Design_lbrary, In
|
|||||||
|
|
||||||
@Query(value = "select * from design_lbrary WHERE id BETWEEN :startId AND :endId", nativeQuery = true)
|
@Query(value = "select * from design_lbrary WHERE id BETWEEN :startId AND :endId", nativeQuery = true)
|
||||||
List<Design_lbrary> deleteByIdRange(@Param("startId") Long startId, @Param("endId") Long endId);
|
List<Design_lbrary> deleteByIdRange(@Param("startId") Long startId, @Param("endId") Long endId);
|
||||||
|
|
||||||
|
@Query(value = "SELECT * FROM design_lbrary d WHERE active=:active && templatetype = :operation_type AND CONCAT(',', REPLACE(REPLACE(d.tag, '{', ''), '}', ''), ',') LIKE CONCAT('%,', :tag, ',%')", nativeQuery = true)
|
||||||
|
List<Design_lbrary> searchByTag(@Param("active") boolean active, @Param("operation_type") String operationType,
|
||||||
|
@Param("tag") String tag);
|
||||||
}
|
}
|
||||||
@ -92,6 +92,7 @@ public class Design_lbraryService {
|
|||||||
old.setTyperender(data.getTyperender());
|
old.setTyperender(data.getTyperender());
|
||||||
|
|
||||||
old.setHtml(data.getHtml());
|
old.setHtml(data.getHtml());
|
||||||
|
old.setTag(data.getTag());
|
||||||
|
|
||||||
final Design_lbrary test = designLibraryRepository.save(old);
|
final Design_lbrary test = designLibraryRepository.save(old);
|
||||||
data.setUpdatedBy(getUser().getUserId());
|
data.setUpdatedBy(getUser().getUserId());
|
||||||
@ -137,7 +138,14 @@ public class Design_lbraryService {
|
|||||||
fieldType.toLowerCase().trim());
|
fieldType.toLowerCase().trim());
|
||||||
|
|
||||||
if (flf == null || flf.isEmpty()) {
|
if (flf == null || flf.isEmpty()) {
|
||||||
return null; // ya throw new RuntimeException("No data found");
|
|
||||||
|
flf = designLibraryRepository.searchByTag(true, operationType.toLowerCase().trim(),
|
||||||
|
fieldType.toLowerCase().trim());
|
||||||
|
|
||||||
|
if (flf == null || flf.isEmpty()) {
|
||||||
|
return null; // ya throw new RuntimeException("No data found");
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Random index pick
|
// Random index pick
|
||||||
|
|||||||
@ -26,6 +26,7 @@ import com.realnet.fnd.entity1.MenuDet;
|
|||||||
import com.realnet.fnd.entity1.MixMenuNew;
|
import com.realnet.fnd.entity1.MixMenuNew;
|
||||||
import com.realnet.fnd.repository1.GrpMenuAccessRepository;
|
import com.realnet.fnd.repository1.GrpMenuAccessRepository;
|
||||||
import com.realnet.fnd.repository1.MenuDetRepository;
|
import com.realnet.fnd.repository1.MenuDetRepository;
|
||||||
|
import com.realnet.fnd.response.EntityResponse;
|
||||||
import com.realnet.users.entity1.AppUserRole;
|
import com.realnet.users.entity1.AppUserRole;
|
||||||
import com.realnet.users.repository1.AppUserRoleRepository;
|
import com.realnet.users.repository1.AppUserRoleRepository;
|
||||||
|
|
||||||
@ -180,9 +181,9 @@ public class MenuController {
|
|||||||
if (!cmenu.isPresent()) {
|
if (!cmenu.isPresent()) {
|
||||||
|
|
||||||
System.out.println(" Main Menu deleted ..");
|
System.out.println(" Main Menu deleted ..");
|
||||||
return new ResponseEntity<>("menu deleted", HttpStatus.CREATED);
|
return new ResponseEntity<>(new EntityResponse("menu deleted"), HttpStatus.CREATED);
|
||||||
} else {
|
} else {
|
||||||
return new ResponseEntity<>("menu not deleted", HttpStatus.BAD_REQUEST);
|
return new ResponseEntity<>(new EntityResponse("menu not deleted"), HttpStatus.BAD_REQUEST);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,99 @@
|
|||||||
|
package com.realnet.tagdata.Controllers;
|
||||||
|
import java.util.List;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||||
|
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||||
|
import com.realnet.config.EmailService;
|
||||||
|
import com.realnet.users.entity1.AppUser;
|
||||||
|
import com.realnet.users.service1.AppUserServiceImpl;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import org.springframework.data.domain.*;
|
||||||
|
import com.realnet.fnd.response.EntityResponse;
|
||||||
|
import org.springframework.http.*;
|
||||||
|
import org.springframework.beans.factory.annotation.*;
|
||||||
|
import com.realnet.tagdata.Entity.Tag;
|
||||||
|
import com.realnet.tagdata.Services.TagService ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value = "/Tag")
|
||||||
|
@CrossOrigin("*")
|
||||||
|
@RestController
|
||||||
|
public class TagController {
|
||||||
|
@Autowired
|
||||||
|
private TagService Service;
|
||||||
|
|
||||||
|
@Value("${projectPath}")
|
||||||
|
private String projectPath;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/Tag")
|
||||||
|
public Tag Savedata(@RequestBody Tag data) {
|
||||||
|
Tag save = Service.Savedata(data) ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println("data saved..." + save);
|
||||||
|
|
||||||
|
return save;
|
||||||
|
}
|
||||||
|
@PutMapping("/Tag/{id}")
|
||||||
|
public Tag update(@RequestBody Tag data,@PathVariable Integer id ) {
|
||||||
|
Tag update = Service.update(data,id);
|
||||||
|
System.out.println("data update..." + update);
|
||||||
|
return update;
|
||||||
|
}
|
||||||
|
// get all with pagination
|
||||||
|
@GetMapping("/Tag/getall/page")
|
||||||
|
public Page<Tag> getall(@RequestParam(value = "page", required = false) Integer page,
|
||||||
|
@RequestParam(value = "size", required = false) Integer size) {
|
||||||
|
Pageable paging = PageRequest.of(page, size);
|
||||||
|
Page<Tag> get = Service.getAllWithPagination(paging);
|
||||||
|
|
||||||
|
return get;
|
||||||
|
|
||||||
|
}
|
||||||
|
@GetMapping("/Tag")
|
||||||
|
public List<Tag> getdetails() {
|
||||||
|
List<Tag> get = Service.getdetails();
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
// get all without authentication
|
||||||
|
|
||||||
|
@GetMapping("/token/Tag")
|
||||||
|
public List<Tag> getallwioutsec() {
|
||||||
|
List<Tag> get = Service.getdetails();
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
@GetMapping("/Tag/{id}")
|
||||||
|
public Tag getdetailsbyId(@PathVariable Integer id ) {
|
||||||
|
Tag get = Service.getdetailsbyId(id);
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
@DeleteMapping("/Tag/{id}")
|
||||||
|
public ResponseEntity<?> delete_by_id(@PathVariable Integer id ) {
|
||||||
|
Service.delete_by_id(id);
|
||||||
|
return new ResponseEntity<>(new EntityResponse("Deleted"), HttpStatus.OK);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,99 @@
|
|||||||
|
package com.realnet.tagdata.Controllers;
|
||||||
|
import java.util.List;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||||
|
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||||
|
import com.realnet.config.EmailService;
|
||||||
|
import com.realnet.users.entity1.AppUser;
|
||||||
|
import com.realnet.users.service1.AppUserServiceImpl;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import org.springframework.data.domain.*;
|
||||||
|
import com.realnet.fnd.response.EntityResponse;
|
||||||
|
import org.springframework.http.*;
|
||||||
|
import org.springframework.beans.factory.annotation.*;
|
||||||
|
import com.realnet.tagdata.Entity.Tag;
|
||||||
|
import com.realnet.tagdata.Services.TagService ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value = "/token/Tag")
|
||||||
|
@CrossOrigin("*")
|
||||||
|
@RestController
|
||||||
|
public class tokenFree_TagController {
|
||||||
|
@Autowired
|
||||||
|
private TagService Service;
|
||||||
|
|
||||||
|
@Value("${projectPath}")
|
||||||
|
private String projectPath;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/Tag")
|
||||||
|
public Tag Savedata(@RequestBody Tag data) {
|
||||||
|
Tag save = Service.Savedata(data) ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println("data saved..." + save);
|
||||||
|
|
||||||
|
return save;
|
||||||
|
}
|
||||||
|
@PutMapping("/Tag/{id}")
|
||||||
|
public Tag update(@RequestBody Tag data,@PathVariable Integer id ) {
|
||||||
|
Tag update = Service.update(data,id);
|
||||||
|
System.out.println("data update..." + update);
|
||||||
|
return update;
|
||||||
|
}
|
||||||
|
// get all with pagination
|
||||||
|
@GetMapping("/Tag/getall/page")
|
||||||
|
public Page<Tag> getall(@RequestParam(value = "page", required = false) Integer page,
|
||||||
|
@RequestParam(value = "size", required = false) Integer size) {
|
||||||
|
Pageable paging = PageRequest.of(page, size);
|
||||||
|
Page<Tag> get = Service.getAllWithPagination(paging);
|
||||||
|
|
||||||
|
return get;
|
||||||
|
|
||||||
|
}
|
||||||
|
@GetMapping("/Tag")
|
||||||
|
public List<Tag> getdetails() {
|
||||||
|
List<Tag> get = Service.getdetails();
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
// get all without authentication
|
||||||
|
|
||||||
|
@GetMapping("/token/Tag")
|
||||||
|
public List<Tag> getallwioutsec() {
|
||||||
|
List<Tag> get = Service.getdetails();
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
@GetMapping("/Tag/{id}")
|
||||||
|
public Tag getdetailsbyId(@PathVariable Integer id ) {
|
||||||
|
Tag get = Service.getdetailsbyId(id);
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
@DeleteMapping("/Tag/{id}")
|
||||||
|
public ResponseEntity<?> delete_by_id(@PathVariable Integer id ) {
|
||||||
|
Service.delete_by_id(id);
|
||||||
|
return new ResponseEntity<>(new EntityResponse("Deleted"), HttpStatus.OK);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,33 @@
|
|||||||
|
package com.realnet.tagdata.Entity;
|
||||||
|
import lombok.*;
|
||||||
|
import com.realnet.WhoColumn.Entity.Extension;
|
||||||
|
import javax.persistence.*;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Data
|
||||||
|
public class Tag extends Extension {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Column(length = 2000)
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
private boolean active;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,30 @@
|
|||||||
|
package com.realnet.tagdata.Repository;
|
||||||
|
|
||||||
|
|
||||||
|
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.stereotype.Repository;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import com.realnet.tagdata.Entity.Tag;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface TagRepository extends JpaRepository<Tag, Integer> {
|
||||||
|
|
||||||
|
@Query(value = "select * from tag where created_by=?1", nativeQuery = true)
|
||||||
|
List<Tag> findAll(Long creayedBy);
|
||||||
|
|
||||||
|
@Query(value = "select * from tag where created_by=?1", nativeQuery = true)
|
||||||
|
Page<Tag> findAll(Pageable page, Long creayedBy);
|
||||||
|
}
|
||||||
@ -0,0 +1,93 @@
|
|||||||
|
package com.realnet.tagdata.Services;
|
||||||
|
import com.realnet.tagdata.Repository.TagRepository;
|
||||||
|
import com.realnet.tagdata.Entity.Tag
|
||||||
|
;import java.util.*;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import com.realnet.SequenceGenerator.Service.SequenceService;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import com.realnet.realm.Entity.Realm;
|
||||||
|
import com.realnet.realm.Services.RealmService;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.http.*;
|
||||||
|
import com.realnet.users.service1.AppUserServiceImpl;
|
||||||
|
import com.realnet.users.entity1.AppUser;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class TagService {
|
||||||
|
@Autowired
|
||||||
|
private TagRepository Repository;
|
||||||
|
@Autowired
|
||||||
|
private AppUserServiceImpl userService;
|
||||||
|
@Autowired
|
||||||
|
private RealmService realmService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public Tag Savedata(Tag data) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
data.setUpdatedBy(getUser().getUserId());
|
||||||
|
data.setCreatedBy(getUser().getUserId());
|
||||||
|
data.setAccountId(getUser().getAccount().getAccount_id());
|
||||||
|
Tag save = Repository.save(data);
|
||||||
|
return save;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// get all with pagination
|
||||||
|
public Page<Tag> getAllWithPagination(Pageable page) {
|
||||||
|
return Repository.findAll(page, getUser().getUserId());
|
||||||
|
}
|
||||||
|
public List<Tag> getdetails() {
|
||||||
|
List<Realm> realm = realmService.findByUserId(getUser().getUserId());
|
||||||
|
List<Tag> all = Repository.findAll(getUser().getUserId());
|
||||||
|
|
||||||
|
return all ; }
|
||||||
|
|
||||||
|
|
||||||
|
public Tag getdetailsbyId(Integer id) {
|
||||||
|
return Repository.findById(id).get();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void delete_by_id(Integer id) {
|
||||||
|
Repository.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Tag update(Tag data,Integer id) {
|
||||||
|
Tag old = Repository.findById(id).get();
|
||||||
|
old.setName(data.getName());
|
||||||
|
|
||||||
|
old.setDescription(data.getDescription());
|
||||||
|
|
||||||
|
old.setActive (data.isActive());
|
||||||
|
|
||||||
|
final Tag test = Repository.save(old);
|
||||||
|
data.setUpdatedBy(getUser().getUserId());
|
||||||
|
return test;}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public AppUser getUser() {
|
||||||
|
AppUser user = userService.getLoggedInUser();
|
||||||
|
return user;
|
||||||
|
|
||||||
|
}}
|
||||||
@ -15,6 +15,8 @@ public class PortConstant {
|
|||||||
public final static String GITEA_PORT = "io";
|
public final static String GITEA_PORT = "io";
|
||||||
public final static String SUREVAULT_DEPLOYMENT_TYPE = "32";
|
public final static String SUREVAULT_DEPLOYMENT_TYPE = "32";
|
||||||
|
|
||||||
|
public static String DOMAIN;
|
||||||
|
|
||||||
public static String BACKEND_PORTAL_DOMAIN;
|
public static String BACKEND_PORTAL_DOMAIN;
|
||||||
public static String FRONTEND_PORTAL_DOMAIN;
|
public static String FRONTEND_PORTAL_DOMAIN;
|
||||||
public static String SUREOPS_DOMAIN;
|
public static String SUREOPS_DOMAIN;
|
||||||
@ -82,6 +84,8 @@ public class PortConstant {
|
|||||||
SITE_BUILDER = getUrlFromApi(backendPortalDomain, "SITE_BUILDER");
|
SITE_BUILDER = getUrlFromApi(backendPortalDomain, "SITE_BUILDER");
|
||||||
SUREOPS_NEW_DOMAIN = getUrlFromApi(backendPortalDomain, "SUREOPS_NEW_DOMAIN");
|
SUREOPS_NEW_DOMAIN = getUrlFromApi(backendPortalDomain, "SUREOPS_NEW_DOMAIN");
|
||||||
|
|
||||||
|
DOMAIN = getUrlFromApi(backendPortalDomain, "DOMAIN");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
System.out.println("Error: BACKEND_PORTAL_DOMAIN could not be fetched.");
|
System.out.println("Error: BACKEND_PORTAL_DOMAIN could not be fetched.");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,14 +24,17 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import com.realnet.Heplers.FileHelper;
|
import com.realnet.Heplers.FileHelper;
|
||||||
|
import com.realnet.OpenAi.Services.SureopsService;
|
||||||
import com.realnet.fnd.response.EntityResponse;
|
import com.realnet.fnd.response.EntityResponse;
|
||||||
import com.realnet.vpspack.Entity.SiteBuilder;
|
import com.realnet.vpspack.Entity.SiteBuilder;
|
||||||
|
import com.realnet.vpspack.Entity.SiteBuilderDto;
|
||||||
import com.realnet.vpspack.Services.SiteBuilderService;
|
import com.realnet.vpspack.Services.SiteBuilderService;
|
||||||
|
|
||||||
@RequestMapping(value = "/SiteTree")
|
@RequestMapping(value = "/SiteTree")
|
||||||
@CrossOrigin("*")
|
@CrossOrigin("*")
|
||||||
@RestController
|
@RestController
|
||||||
public class SiteBuilderController {
|
public class SiteBuilderController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SiteBuilderService Service;
|
private SiteBuilderService Service;
|
||||||
|
|
||||||
@ -41,6 +44,9 @@ public class SiteBuilderController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private FileHelper fileHelper;
|
private FileHelper fileHelper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SureopsService sureopsService;
|
||||||
|
|
||||||
@PostMapping("/SiteTree")
|
@PostMapping("/SiteTree")
|
||||||
public SiteBuilder Savedata(@RequestBody SiteBuilder data) {
|
public SiteBuilder Savedata(@RequestBody SiteBuilder data) {
|
||||||
SiteBuilder save = Service.Savedata(data);
|
SiteBuilder save = Service.Savedata(data);
|
||||||
@ -94,15 +100,25 @@ public class SiteBuilderController {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/SiteTree/createFile")
|
@PostMapping("/SiteTree/deploy")
|
||||||
public ResponseEntity<?> createHtmlFiles(@RequestParam String siteBuilderName, @RequestBody Map<String, String> pageHtmlMap)
|
public ResponseEntity<?> createAndDeploy(@RequestParam Integer siteId, @RequestParam String siteBuilderName,
|
||||||
throws IOException {
|
@RequestBody SiteBuilderDto dto) throws IOException {
|
||||||
|
|
||||||
ResponseEntity<?> htmlFile = Service.createHtmlFile(siteBuilderName, pageHtmlMap);
|
ResponseEntity<?> htmlFile = Service.create(siteId, siteBuilderName, dto);
|
||||||
|
|
||||||
|
Service.deploy(siteId, siteBuilderName);
|
||||||
return htmlFile;
|
return htmlFile;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// it created all file of pages
|
||||||
|
@PostMapping("/SiteTree/createFile")
|
||||||
|
public ResponseEntity<?> createHtmlFiles(@RequestParam Integer siteId, @RequestParam String siteBuilderName,
|
||||||
|
@RequestBody SiteBuilderDto dto) throws IOException {
|
||||||
|
ResponseEntity<?> htmlFile = Service.create(siteId, siteBuilderName, dto);
|
||||||
|
return htmlFile;
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/SiteTree/read")
|
@GetMapping("/SiteTree/read")
|
||||||
public ResponseEntity<?> readFile(@RequestParam String siteBuilderName, @RequestParam String filename) {
|
public ResponseEntity<?> readFile(@RequestParam String siteBuilderName, @RequestParam String filename) {
|
||||||
|
|
||||||
@ -111,6 +127,5 @@ public class SiteBuilderController {
|
|||||||
ResponseEntity<?> file = fileHelper.readFile(filepath, filename);
|
ResponseEntity<?> file = fileHelper.readFile(filepath, filename);
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -24,6 +24,8 @@ public class SiteBuilder extends Extension {
|
|||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
private String deployedUrl;
|
||||||
|
|
||||||
@Column(length = 2000)
|
@Column(length = 2000)
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,13 @@
|
|||||||
|
package com.realnet.vpspack.Entity;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class SiteBuilderDto {
|
||||||
|
|
||||||
|
private String css;
|
||||||
|
private Map<String, String> pageHtmlMap;
|
||||||
|
|
||||||
|
}
|
||||||
@ -2,14 +2,15 @@ package com.realnet.vpspack.Services;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.bcel.generic.NEW;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.http.HttpEntity;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
@ -17,8 +18,8 @@ import org.springframework.http.ResponseEntity;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
import com.itextpdf.text.pdf.PdfStructTreeController.returnType;
|
|
||||||
import com.realnet.Heplers.FileHelper;
|
import com.realnet.Heplers.FileHelper;
|
||||||
|
import com.realnet.OpenAi.Services.SureopsService;
|
||||||
import com.realnet.fnd.response.EntityResponse;
|
import com.realnet.fnd.response.EntityResponse;
|
||||||
import com.realnet.realm.Entity.Realm;
|
import com.realnet.realm.Entity.Realm;
|
||||||
import com.realnet.realm.Services.RealmService;
|
import com.realnet.realm.Services.RealmService;
|
||||||
@ -27,17 +28,24 @@ import com.realnet.users.service1.AppUserServiceImpl;
|
|||||||
import com.realnet.utils.PortConstant;
|
import com.realnet.utils.PortConstant;
|
||||||
import com.realnet.utils.RealNetUtils;
|
import com.realnet.utils.RealNetUtils;
|
||||||
import com.realnet.vpspack.Entity.SiteBuilder;
|
import com.realnet.vpspack.Entity.SiteBuilder;
|
||||||
|
import com.realnet.vpspack.Entity.SiteBuilderDto;
|
||||||
import com.realnet.vpspack.Repository.SiteBuilderRepository;
|
import com.realnet.vpspack.Repository.SiteBuilderRepository;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class SiteBuilderService {
|
public class SiteBuilderService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SiteBuilderRepository Repository;
|
private SiteBuilderRepository Repository;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private AppUserServiceImpl userService;
|
private AppUserServiceImpl userService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RealmService realmService;
|
private RealmService realmService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SureopsService sureopsService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private FileHelper fileHelper;
|
private FileHelper fileHelper;
|
||||||
|
|
||||||
@ -103,15 +111,20 @@ public class SiteBuilderService {
|
|||||||
return test;
|
return test;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResponseEntity<?> createHtmlFile(String siteBuilderName, Map<String, String> pageHtmlMap)
|
public ResponseEntity<?> create(Integer siteId, String siteBuilderName, SiteBuilderDto dto) throws IOException {
|
||||||
throws IOException {
|
|
||||||
|
Map<String, String> pageHtmlMap = dto.getPageHtmlMap();
|
||||||
|
|
||||||
siteBuilderName = RealNetUtils.formatStringtoSql(siteBuilderName).toLowerCase();
|
siteBuilderName = RealNetUtils.formatStringtoSql(siteBuilderName).toLowerCase();
|
||||||
String folderPath = projectPath + File.separator + "Files" + File.separator + siteBuilderName;
|
String folderPath = projectPath + File.separator + "Files" + File.separator + siteBuilderName;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
String startindex = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + " <title>Welcome</title>\n" + "</head>\n"
|
String cssFileName = "style.css";
|
||||||
+ "<body>\n";
|
|
||||||
|
fileHelper.createFile(folderPath, cssFileName.toLowerCase(), dto.getCss());
|
||||||
|
|
||||||
|
String startindex = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + " <title>Welcome</title>\n" + ""
|
||||||
|
+ "<!-- CSS file link -->\r\n" + " </head>\n" + "<body>\n";
|
||||||
|
|
||||||
String endindex = "</body>\n" + "</html>";
|
String endindex = "</body>\n" + "</html>";
|
||||||
|
|
||||||
@ -120,11 +133,14 @@ public class SiteBuilderService {
|
|||||||
String pageName = entry.getKey().trim().replaceAll("\\s+", "_") + ".html"; // remove spaces from name
|
String pageName = entry.getKey().trim().replaceAll("\\s+", "_") + ".html"; // remove spaces from name
|
||||||
String htmlContent = entry.getValue();
|
String htmlContent = entry.getValue();
|
||||||
|
|
||||||
|
htmlContent = htmlContent.replaceAll("(?is)<style[^>]*>.*?</style>",
|
||||||
|
"<link rel=\"stylesheet\" href=\"style.css\" />");
|
||||||
|
|
||||||
if (pageName.equalsIgnoreCase("home.html")) {
|
if (pageName.equalsIgnoreCase("home.html")) {
|
||||||
|
|
||||||
pageName = "index.html";
|
pageName = "index.html";
|
||||||
|
|
||||||
htmlContent = startindex + " \n" + htmlContent + endindex;
|
// htmlContent = startindex + " \n" + htmlContent + endindex;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,18 +149,32 @@ public class SiteBuilderService {
|
|||||||
System.out.println(i + " file created ");
|
System.out.println(i + " file created ");
|
||||||
}
|
}
|
||||||
|
|
||||||
String url = PortConstant.SUREOPS_NEW_DOMAIN + "/token/startContainer/182?folderName=" + siteBuilderName;
|
return new ResponseEntity<>(new EntityResponse(i + " files created "), HttpStatus.CREATED);
|
||||||
|
}
|
||||||
|
|
||||||
ResponseEntity<Object> get = GET(url);
|
public void deploy(Integer siteId, String siteBuilderName) {
|
||||||
|
|
||||||
|
Long serverPortNo = sureopsService.getUpdatedPort(1L);
|
||||||
|
String url = PortConstant.SUREOPS_NEW_DOMAIN + "/token/startContainer/182?folderName=" + siteBuilderName
|
||||||
|
+ "&serverPortNo=" + serverPortNo;
|
||||||
|
|
||||||
|
ResponseEntity<Object> get = POST(url);
|
||||||
if (get.getStatusCodeValue() < 209) {
|
if (get.getStatusCodeValue() < 209) {
|
||||||
System.out.println(" deplpoyed also");
|
System.out.println(" deplpoyed also...");
|
||||||
|
|
||||||
|
String deployedUrl = PortConstant.DOMAIN + "/" + serverPortNo;
|
||||||
|
SiteBuilder siteBuilder = getdetailsbyId(siteId);
|
||||||
|
siteBuilder.setDeployedUrl(deployedUrl);
|
||||||
|
|
||||||
|
SiteBuilder savedata = Savedata(siteBuilder);
|
||||||
|
|
||||||
|
System.out.println(" deployed url updated...");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
System.out.println("not deplpoyed ");
|
System.out.println("not deplpoyed ");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ResponseEntity<>(new EntityResponse(i + " files created "), HttpStatus.CREATED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public AppUser getUser() {
|
public AppUser getUser() {
|
||||||
@ -162,6 +192,18 @@ public class SiteBuilderService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ResponseEntity<Object> POST(String jobinfo) {
|
||||||
|
HashMap<Object, Object> user = new HashMap<>();
|
||||||
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
|
String resourceUrl = jobinfo;
|
||||||
|
HttpHeaders headers = getHeaders();
|
||||||
|
HttpEntity<Object> request = new HttpEntity<Object>(user, headers);
|
||||||
|
ResponseEntity<Object> res = restTemplate.postForEntity(resourceUrl, request, Object.class);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private HttpHeaders getHeaders() {
|
private HttpHeaders getHeaders() {
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.set("Content-Type", MediaType.APPLICATION_JSON_VALUE);
|
headers.set("Content-Type", MediaType.APPLICATION_JSON_VALUE);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user