[ADD] SE AGREGO UN NUEVO SERVICIO PARA SUBIDA DE ARCHIVOS AL DRIVE Y REPARACIÓN DE BUGS

parent 637f7fd7
......@@ -165,26 +165,26 @@
<artifactId>html2pdf</artifactId>
<version>5.0.2</version>
</dependency>
<!-- Google API client -->
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId>
<version>2.0.0</version>
</dependency>
<!-- Google OAuth client (Jetty) -->
<dependency>
<groupId>com.google.oauth-client</groupId>
<artifactId>google-oauth-client-jetty</artifactId>
<version>1.34.1</version>
</dependency>
<!-- Google Drive API -->
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-drive</artifactId>
<version>v3-rev20220815-2.0.0</version>
</dependency>
<dependency>
<groupId>com.google.auth</groupId>
<artifactId>google-auth-library-oauth2-http</artifactId>
<version>1.3.0</version>
</dependency>
</dependencies>
<build>
<finalName>trismegisto-services</finalName>
......
//package web.multitask.trismegistoservices.api;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.MediaType;
//import org.springframework.http.ResponseEntity;
//import org.springframework.web.bind.annotation.*;
//
//import web.multitask.trismegistoservices.model.DriveRequest;
//import web.multitask.trismegistoservices.service.DriveService;
//
//@RestController
//@CrossOrigin(origins = "*")
//@RequestMapping("drive")
//public class DriveApi {
//
//
// @Autowired
// private DriveService driveService;
//
// @PostMapping(path = "/public/upload", consumes = {
// MediaType.MULTIPART_FORM_DATA_VALUE })
// public ResponseEntity<?> uploadFile(@ModelAttribute DriveRequest request) {
//
// String folder_id = request.getFolder_id();
// String file_name = request.getFile_name();
// String base64_name = request.getBase64_name();
// String base64_file = request.getBase64_file();
//
// System.out.println(request.getFile().getOriginalFilename());
//
// return null;
// }
//
//}
\ No newline at end of file
package web.multitask.trismegistoservices.api;
import org.json.JSONObject;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import web.multitask.trismegistoservices.model.DriveRequest;
import web.multitask.trismegistoservices.services.DriveService;
@RestController
@CrossOrigin(origins = "*")
@RequestMapping("drive")
public class DriveApi {
DriveService driveService;
public DriveApi(DriveService driveService) {
this.driveService = driveService;
}
@PostMapping(path = "/public/upload", consumes = { MediaType.MULTIPART_FORM_DATA_VALUE })
public ResponseEntity<?> uploadFile(@ModelAttribute DriveRequest request) {
String folder_id = request.getFolder_id();
String file_name = request.getFile_name();
// String base64_name = request.getBase64_name();
// String base64_file = request.getBase64_file();
MultipartFile file = request.getFile();
String responseDrive = driveService.uploadFile(folder_id, file_name, file, new JSONObject());
JSONObject response = new JSONObject();
if(responseDrive == null){
response.put("status", "error");
response.put("message", "Error al subir el archivo");
return ResponseEntity.badRequest().body(response.toMap());
}else{
response.put("status", "success");
response.put("message", "Archivo subido correctamente");
response.put("file_id", responseDrive);
return ResponseEntity.ok(response.toMap());
}
}
}
\ No newline at end of file
package web.multitask.trismegistoservices.api;
import java.io.File;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.FileUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import web.multitask.trismegistoservices.services.ExcelService;
@RestController
@CrossOrigin(origins = "*")
@RequestMapping("excel")
public class ExcelApi {
@Autowired
ExcelService excelService;
@PostMapping("/public/generate")
public ResponseEntity<Resource> generateExcel() {
return null;
public ResponseEntity<?> generateExcel(HttpServletResponse response,@RequestBody String json) {
JSONObject jsonObject = new JSONObject(json);
byte[] excelByte = excelService.generateExcel(jsonObject);
// excelByte to InputStreamResource
File file = new File(System.getProperty("java.io.tmpdir") + "/excel.xlsx");
try {
FileUtils.writeByteArrayToFile(file, excelByte);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Resource resource = excelService.convertByteToResource(excelByte, jsonObject.optString("file_name", "no_name.xlsx"));
return ResponseEntity.ok().body(resource);
}
}
\ No newline at end of file
......@@ -6,7 +6,8 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import web.multitask.trismegistoservices.service.PDFService;
import web.multitask.trismegistoservices.services.PDFService;
@RestController
@CrossOrigin(origins = "*")
......
package web.multitask.trismegistoservices.config;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.security.GeneralSecurityException;
import java.util.Collections;
import java.util.List;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.gson.GsonFactory;
import com.google.api.services.drive.Drive;
import com.google.api.services.drive.DriveScopes;
import com.google.auth.http.HttpCredentialsAdapter;
import com.google.auth.oauth2.GoogleCredentials;
@Configuration
public class GoogleConfig {
private static final List<String> SCOPES = Collections.singletonList(DriveScopes.DRIVE);
private static final String CREDENTIALS_FILE_PATH = "/trimegistro-mongo-3e687dba9acb.json";
private static final String CREDENTIALS_FOLDER_PATH = "/tokens";
@Bean
public Drive getDrive() {
try {
String APPLICATION_NAME = "FullService Application";
JsonFactory JSON_FACTORY = GsonFactory.getDefaultInstance();
final NetHttpTransport HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport();
Drive service = new Drive.Builder(HTTP_TRANSPORT, JSON_FACTORY,
new HttpCredentialsAdapter(getCredentials(HTTP_TRANSPORT)))
.setApplicationName(APPLICATION_NAME)
.build();
return service;
} catch (GeneralSecurityException | IOException e) {
System.out.println("Error: " + e);
return null;
}
}
GoogleCredentials getCredentials(final NetHttpTransport HTTP_TRANSPORT)
throws IOException {
InputStream in = GoogleConfig.class.getResourceAsStream(CREDENTIALS_FOLDER_PATH+CREDENTIALS_FILE_PATH);
if (in == null) throw new FileNotFoundException("Resource not found: " + CREDENTIALS_FOLDER_PATH+CREDENTIALS_FILE_PATH);
GoogleCredentials clientSecrets = GoogleCredentials.fromStream(in).createScoped(SCOPES);
return clientSecrets;
}
}
......@@ -47,13 +47,13 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.cors(AbstractHttpConfigurer::disable).csrf(AbstractHttpConfigurer::disable)
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
.sessionManagement(management -> management.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
.authorizeHttpRequests(
authorizeRequests -> authorizeRequests
.antMatchers("/security/**").hasAnyAuthority("ADMIN")
.regexMatchers(".*/private/.*").hasAnyAuthority("ADMIN","USER")
.regexMatchers(".*/private/.*").hasAnyAuthority("ADMIN", "USER")
.regexMatchers(".*/public/.*").permitAll()
.regexMatchers(".*/service/.*").hasAnyAuthority("ADMIN","SERVICE")
.regexMatchers(".*/service/.*").hasAnyAuthority("ADMIN", "SERVICE")
.antMatchers(HttpMethod.GET, "/**").permitAll()
// .antMatchers(HttpMethod.POST, "/**").permitAll()
.antMatchers("/token/**").permitAll());
......
package web.multitask.trismegistoservices.controller;
import org.springframework.messaging.handler.annotation.DestinationVariable;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import web.multitask.trismegistoservices.model.Message;
import web.multitask.trismegistoservices.model.Response;
......@@ -15,9 +17,11 @@ public class MessageController {
@MessageMapping("/{project}/{topic}")
@SendTo("/topic/message/{project}/{topic}")
public Response envio(@PathVariable("project") String project, @PathVariable("topic") String topic,
Message message) {
return new Response(message.getUser(), project, topic, message.getContent(), new Date().toString());
public Response envio(@DestinationVariable String project, @DestinationVariable String topic, Message message) {
try {
return new Response(message.getUser(), project, topic, message.getContent(), new Date().toString());
} catch (Exception e) {
return new Response("Error", project, topic, "Error", new Date().toString());
}
}
}
\ No newline at end of file
package web.multitask.trismegistoservices.interfaces;
import org.json.JSONObject;
import org.springframework.web.multipart.MultipartFile;
public interface IDriveService {
String uploadFile(String folder_id, String file_name, MultipartFile file, JSONObject base64);
String createFolder(String folder_id, String folder_name);
String deleteFile(String file_id);
String deleteFolder(String folder_id);
String getFile(String file_id);
String getFolder(String folder_id);
}
//package web.multitask.trismegistoservices.service;
//
//import java.io.ByteArrayInputStream;
//import java.io.FileNotFoundException;
//import java.io.IOException;
//import java.io.InputStream;
//import java.io.InputStreamReader;
//import java.security.GeneralSecurityException;
//import java.util.Collections;
//import java.util.List;
//
//import org.json.JSONObject;
//import org.springframework.stereotype.Component;
//import org.springframework.web.multipart.MultipartFile;
//
//import com.google.api.client.auth.oauth2.Credential;
//import com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp;
//import com.google.api.client.extensions.jetty.auth.oauth2.LocalServerReceiver;
//import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow;
//import com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets;
//import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport;
//import com.google.api.client.http.InputStreamContent;
//import com.google.api.client.http.javanet.NetHttpTransport;
//import com.google.api.client.json.JsonFactory;
//import com.google.api.client.json.gson.GsonFactory;
//import com.google.api.client.util.store.FileDataStoreFactory;
//import com.google.api.services.drive.Drive;
//import com.google.api.services.drive.DriveScopes;
//import com.google.api.services.drive.model.File;
//
//@Component
//public class DriveService {
//
// private static final String APPLICATION_NAME = "FullService Application";
// private static final JsonFactory JSON_FACTORY = GsonFactory.getDefaultInstance();
// private static final String TOKENS_DIRECTORY_PATH = "tokens";
// private static final List<String> SCOPES = Collections.singletonList(DriveScopes.DRIVE_FILE);
// private static final String CREDENTIALS_FILE_PATH = "./credentials.json";
//
// private static Credential getCredentials(final NetHttpTransport HTTP_TRANSPORT)
// throws IOException {
//
// InputStream in = DriveService.class.getResourceAsStream(CREDENTIALS_FILE_PATH);
// if (in == null) {
// throw new FileNotFoundException("Resource not found: " + CREDENTIALS_FILE_PATH);
// }
// GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(in));
// GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
// HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, SCOPES)
// .setDataStoreFactory(new FileDataStoreFactory(new java.io.File(TOKENS_DIRECTORY_PATH)))
// .setAccessType("offline")
// .build();
// LocalServerReceiver receiver = new LocalServerReceiver.Builder().setPort(8888).build();
// Credential credential = new AuthorizationCodeInstalledApp(flow, receiver).authorize("user");
// return credential;
// }
//
// public Drive getInstance() throws GeneralSecurityException, IOException {
// // Build a new authorized API client service.
// final NetHttpTransport HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport();
// Drive service = new Drive.Builder(HTTP_TRANSPORT, JSON_FACTORY, getCredentials(HTTP_TRANSPORT))
// .setApplicationName(APPLICATION_NAME)
// .build();
// return service;
// }
//
//
// public String uploadFile(String folder_id, String file_name, MultipartFile file, JSONObject base64) {
// try {
// System.out.println(file.getOriginalFilename());
//
// String folderId = folder_id;
// if (null != file) {
// File fileMetadata = new File();
// fileMetadata.setParents(Collections.singletonList(folderId));
// fileMetadata.setName(file.getOriginalFilename());
// File uploadFile = getInstance()
// .files()
// .create(fileMetadata, new InputStreamContent(
// file.getContentType(),
// new ByteArrayInputStream(file.getBytes()))
// )
// .setFields("id").execute();
// System.out.println(uploadFile);
// return uploadFile.getId();
// }
// } catch (Exception e) {
// System.out.printf("Error: "+ e);
// }
// return null;
// }
//}
\ No newline at end of file
package web.multitask.trismegistoservices.service;
import org.springframework.stereotype.Service;
@Service
public class ExcelService {
// public byte[] generateExcel (JSONObject json){
// XSSFWorkbook workbook = new XSSFWorkbook();
//
// }
//
// private void createSheet(XSSFWorkbook workbook, JSONObject json){
// if(!json.optJSONArray("data", new JSONArray()).isEmpty()){
// XSSFSheet sheet = workbook.createSheet(json.optString("sheet_name", "no_name"));
// buildSheet(sheet, json);
// }
// }
//
// private void buildSheet (XSSFSheet sheet, JSONObject json){
//
// int row_index = 0;
// String title = json.optString("title", "");
// String title_style = json.optString("title_style", "");
// String responsible = json.optString("responsible", "");
// JSONArray headers = json.optJSONArray("headers", new JSONArray());
// JSONArray style_headers = json.optJSONArray("style_headers", new JSONArray());
// JSONArray identifiers = json.optJSONArray("identifiers", new JSONArray());
// JSONArray data = json.optJSONArray("data", new JSONArray());
// int total_rows = data.length();
// String currentDate = LocalDateTime.now().toString();
//
// XSSFRow row_title = sheet.createRow(row_index);
// row_title.createCell(0).setCellValue(title);
// CellRangeAddress cellRangeAddress = new CellRangeAddress(row_index, row_index, 0, headers.length() - 1);
// sheet.addMergedRegion(cellRangeAddress);
// row_index++;
// sheet.createRow(row_index);
// XSSFRow row_responsible = sheet.createRow(row_index);
// row_responsible.createCell(0).setCellValue(responsible);
// CellRangeAddress cellRangeAddress2 = new CellRangeAddress(row_index, row_index, 0, headers.length() - 1);
// sheet.addMergedRegion(cellRangeAddress2);
// row_index++;geAddress2);
// row_index++;
// XSSFRow row_date = sheet.createRow(row_index);
// row_date.createCell(0).setCellValue("Fecha: " + currentDate);
// CellRangeAddress cellRangeAddress3 = new CellRangeAddress(row_index, row_index, 0, headers.length() - 1);
// sheet.addMergedRegion(cellRangeAddress3);
// row_index++;
// XSSFRow row_header = sheet.createRow(row_index);
// IntStream.range(0, headers.length()).forEach(i -> {
// row_header.createCell(0).setCellValue(headers.optString(i, "").toUpperCase());
// });
//
// for(int i = 0; i < data.length(); i++){
// row_index++;
// XSSFRow row_data = sheet.createRow(row_index);
// int finalI = i;
// IntStream.range(0, identifiers.length()).forEach(j -> {
// row_data.createCell(j).setCellValue(data.optJSONObject(finalI).optString(identifiers.optString(j, ""), ""));
// });
// }
// }
// XSSFRow row_date = sheet.createRow(row_index);
// row_date.createCell(0).setCellValue("Fecha: " + currentDate);
// CellRangeAddress cellRangeAddress3 = new CellRangeAddress(row_index, row_index, 0, headers.length() - 1);
// sheet.addMergedRegion(cellRangeAddress3);
// row_index++;
// XSSFRow row_header = sheet.createRow(row_index);
// IntStream.range(0, headers.length()).forEach(i -> {
// row_header.createCell(0).setCellValue(headers.optString(i, "").toUpperCase());
// });
//
// for(int i = 0; i < data.length(); i++){
// row_index++;
// XSSFRow row_data = sheet.createRow(row_index);
// int finalI = i;
// IntStream.range(0, identifiers.length()).forEach(j -> {
// row_data.createCell(j).setCellValue(data.optJSONObject(finalI).optString(identifiers.optString(j, ""), ""));
// });
// }
// }
}
\ No newline at end of file
package web.multitask.trismegistoservices.services;
import java.io.ByteArrayInputStream;
import java.util.Collections;
import org.json.JSONObject;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import com.google.api.client.http.InputStreamContent;
import com.google.api.services.drive.model.File;
import web.multitask.trismegistoservices.config.GoogleConfig;
import web.multitask.trismegistoservices.interfaces.IDriveService;
@Service
public class DriveService implements IDriveService {
private final GoogleConfig googleConfig;
public DriveService(GoogleConfig googleConfig) {
this.googleConfig = googleConfig;
}
@Override
public String uploadFile(String folder_id, String file_name, MultipartFile file, JSONObject base64) {
try {
if (null != file) {
File fileMetadata = new File();
fileMetadata.setParents(Collections.singletonList(folder_id));
fileMetadata.setName(file.getOriginalFilename());
File uploadFile = googleConfig.getDrive()
.files()
.create(fileMetadata, new InputStreamContent(
file.getContentType(),
new ByteArrayInputStream(file.getBytes())))
.setFields("id").execute();
return uploadFile.getId();
}
} catch (Exception e) {
System.out.printf("Error: " + e);
}
return null;
}
@Override
public String createFolder(String folder_id, String folder_name) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'createFolder'");
}
@Override
public String deleteFile(String file_id) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'deleteFile'");
}
@Override
public String deleteFolder(String folder_id) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'deleteFolder'");
}
@Override
public String getFile(String file_id) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'getFile'");
}
@Override
public String getFolder(String folder_id) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'getFolder'");
}
}
\ No newline at end of file
package web.multitask.trismegistoservices.services;
// package web.multitask.app.service;
// import java.io.ByteArrayInputStream;
......
package web.multitask.trismegistoservices.services;
import java.io.ByteArrayOutputStream;
import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.FillPatternType;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFColor;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder.BorderSide;
import org.json.JSONArray;
import org.json.JSONObject;
import java.awt.Color;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Service;
@Service
public class ExcelService {
public byte[] generateExcel(JSONObject json) {
ByteArrayOutputStream outByteStream = new ByteArrayOutputStream();
XSSFWorkbook workbook = new XSSFWorkbook();
createSheet(workbook, json);
try {
workbook.write(outByteStream);
workbook.close();
return outByteStream.toByteArray();
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
private void createSheet(XSSFWorkbook workbook, JSONObject json) {
if (json.optJSONArray("sheetArray", new JSONArray()).isEmpty()) {
XSSFSheet sheet = workbook.createSheet(json.optString("sheet_name", "no_name"));
buildSheet(workbook, sheet, json);
}else{
JSONArray sheetArray = json.optJSONArray("sheetArray", new JSONArray());
for(int i = 0; i < sheetArray.length(); i++){
JSONObject sheetObject = sheetArray.optJSONObject(i);
XSSFSheet sheet = workbook.createSheet(sheetObject.optString("sheet_name", "no_name"));
buildSheet(workbook, sheet, sheetObject);
}
}
}
private void buildSheet(XSSFWorkbook workbook, XSSFSheet sheet, JSONObject json) {
JSONArray identifiers = json.optJSONArray("identifiers", new JSONArray());
JSONArray data = json.optJSONArray("data", new JSONArray());
JSONArray styles = json.optJSONArray("styles", new JSONArray());
for (int i = 0; i < data.length(); i++) {
XSSFRow row = sheet.createRow(i);
JSONObject row_data = data.optJSONObject(i);
for (int j = 0; j < identifiers.length(); j++) {
sheet.autoSizeColumn(j);
String value = row_data.optString(identifiers.getString(j), "");
XSSFCell cell = row.createCell(j);
JSONArray styleArray = styles.optJSONArray(i, new JSONArray());
JSONObject style = styleArray.optJSONObject(j, new JSONObject());
XSSFCellStyle cellStyle = createCellStyle(workbook,
getXSSFColor(style.optString("background", "#ffffff")),
getXSSFColor(style.optString("foreground", "#333333")),
style.optBoolean("bold", false),
style.optBoolean("border", true));
cell.setCellStyle(cellStyle);
cell.setCellValue(value);
}
}
}
private XSSFCellStyle createCellStyle(XSSFWorkbook workbook, XSSFColor background, XSSFColor foreground,
boolean bold, boolean border) {
XSSFCellStyle style = workbook.createCellStyle();
Font font = workbook.createFont();
style.setAlignment(HorizontalAlignment.CENTER);
style.setWrapText(true);
style.setVerticalAlignment(VerticalAlignment.CENTER);
style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
if (border) {
style.setBorderBottom(BorderStyle.THIN);
style.setBorderTop(BorderStyle.THIN);
style.setBorderLeft(BorderStyle.THIN);
style.setBorderRight(BorderStyle.THIN);
style.setBorderColor(BorderSide.BOTTOM, getXSSFColor("#333333"));
style.setBorderColor(BorderSide.TOP, getXSSFColor("#333333"));
style.setBorderColor(BorderSide.LEFT, getXSSFColor("#333333"));
style.setBorderColor(BorderSide.RIGHT, getXSSFColor("#333333"));
}
// font.setFontHeightInPoints((short) 15);
font.setBold(bold);
style.setFont(font);
if (background != null) {
style.setFillForegroundColor(background);
}
if (foreground != null) {
style.getFont().setColor(foreground);
}
return style;
}
public XSSFColor getXSSFColor(String rgb) {
int red = Integer.parseInt(rgb.substring(1, 3), 16);
int green = Integer.parseInt(rgb.substring(3, 5), 16);
int blue = Integer.parseInt(rgb.substring(5, 7), 16);
Color awtColor = new Color(red, green, blue);
XSSFColor xssfColor = new XSSFColor();
xssfColor
.setRGB(new byte[] { (byte) awtColor.getRed(), (byte) awtColor.getGreen(), (byte) awtColor.getBlue() });
return xssfColor;
}
public Resource convertByteToResource(byte[] data, String filename) {
return new ByteArrayResource(data) {
@Override
public String getFilename() {
return filename;
}
};
}
}
\ No newline at end of file
package web.multitask.trismegistoservices.service;
package web.multitask.trismegistoservices.services;
import com.itextpdf.html2pdf.ConverterProperties;
......
{
"type": "service_account",
"project_id": "trimegistro-mongo",
"private_key_id": "3e687dba9acbe6cfdf2b0ea5dbdac21de0f1c040",
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDQfiCmdlpaJd7f\nNohbvnun3CbfVOy+dUuUOTYWGOAnyAh/ARQ6XC3+Ceplg7uc3XiKQYMPl+dKAv2G\nbIcpwb4BIz6rpknd1AM5I1ObJcwmxHblsKLUq55Ixkjke5IQYWvBkwdNENORZMgP\nWTuj1x9HGhCynWZCimFXsKvsJnWwlTkFAZJWwXtJDt6m0TqCH/aGKrH2C5pZvQyd\nlZHlQF3dlQ1PlOVB4stD0tKSXtU6dxrZzTv8os+uwfZel6lF+90TkE2DfOT0bWxD\n+7GVqWPTtrY6TvCOaucGSR08cnncqA030/X7MORuyXp4tmmWNK4iFdacPOdA/X1k\nCVe4Pv7TAgMBAAECggEAL1yPfzEAilzy+YLSTAED5xhgLjiFBSjxD81FR5TECtVq\ndKtilHVPL1fCSug3bMV0tfd21cp8jHgMboZl1+r+hhSjDmwaeI1KZCbtvZ9C9oWH\nutq6ypPnw4Fjmp+liRoQV+tV68BIR019EtuC7E+Yd9bodyLBUZlMzpZAH8eG0aNT\nUYYvxbJvHKGr7/YSM+k5Uhngw9rDoVFHJsBywQ0NmU4/VJxEB5M5V4jmnUn4OXaY\nnt+NhmEa7NJCsB6ASnYdxxojJBFzCwt3YqHQk9kBhB2SnoUyx4YZXXYphJnFpI/0\natzChjWSbdQKX3pwKiVQ9nXgIWTgPZtW98E5FQ6eVQKBgQDr9Z8WTYawWvpNnx3L\nYRGAyQVqa7mvxonHaxiRWCt6DzMRn/gzt0fup8NnW+82EobHuwpmq4GegVHQ8a/Y\ntCMD98bnlF/ZQADIMEisjES2OJrliOAZok2h+xAAIZ/NjJQSAanY6ylJPus7TDjq\nolRc6yisE4EJjk8KMC440yaPhQKBgQDiM05pgEwad5+TKPltFUmOrO9xNb4lWShy\nOTXHGbpeld83c6zP4JQoKauy4XrDpXPpr4czWAOnQtxS4lcA1HS47od94k9MTN9C\ndtiLqJSWaCpBaKw7POJimiKzFKCllWRYbqhf2dpsG2fnKFls9LpN7xyU4Dmh71IK\nFYLOhIeodwKBgCk1zsEgbSOj4A9qeNOqclohwbZidh3C+RFBHRtVYNKCkRLE855k\npkWCO1hz8AVrmuqLOjfQQGUkhNuPOn0IiQ0KW0za1xqkWP6doDOyk9WXcUYhb7JK\nbHCb3qGHPdeyc7HpZHakK6PFP2Qt3crs6vsHfyT+iwzWM+u9mnUGO7fZAoGBAKJ4\n2ax7w64LGCpadvW8IY6CdqXpRT+MT7njj9YHi87edWteAdV6aNCERdiBjm0yzRQf\nyMu/PziHlLtP6dAlygT/B4EK6YxTdtVFifqeRsPV4+wBZBxUegL61Uut2Em3CVFf\ngj7+up2F/daSK9FP4vWRdwUUHTFMNbAajU8K8Gm3AoGAN39pkgWds/2n8QWNG6xg\n7fgvNdKlOChYzEwfKYSsBWSJYVbycxZwYf2Z56DFs8k5Gkq1TmUP5wZJEXgQEgQL\nSyBZpYeidMJTZeBAdoQP/YcD/BbbrZERBEB7AOFkqio4tZvsQ+P+05D8EZFaxfWL\n+n6qKIWmY/pmTz1UMq38Z44=\n-----END PRIVATE KEY-----\n",
"client_email": "drive-full-service@trimegistro-mongo.iam.gserviceaccount.com",
"client_id": "112792567782824987338",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/drive-full-service%40trimegistro-mongo.iam.gserviceaccount.com",
"universe_domain": "googleapis.com"
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment