Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions src/main/java/org/sunbird/workflow/WorkflowApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.json.JsonMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
Expand All @@ -26,21 +27,21 @@ public static void main(String[] args) {
SpringApplication.run(WorkflowApplication.class, args);
}

@Bean
public ObjectMapper objectMapper() {
JavaTimeModule javaTimeModule = new JavaTimeModule();
@Bean
public ObjectMapper objectMapper() {
JavaTimeModule javaTimeModule = new JavaTimeModule();
javaTimeModule.addSerializer(Instant.class, new InstantToEpochMillisSerializer());

return JsonMapper.builder()
.addModule(javaTimeModule)
.enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES)
.enable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.build();
}

// This will force Jackson to write epoch milliseconds as long for Instant
javaTimeModule.addSerializer(Instant.class, new InstantToEpochMillisSerializer());
ObjectMapper objectMapper = new ObjectMapper()
.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true);
objectMapper.registerModule(javaTimeModule);
objectMapper.enable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
return objectMapper;
}

@Bean
public RestTemplate restTemplate() throws Exception {
public RestTemplate restTemplate() {
return new RestTemplate(getClientHttpRequestFactory());
}

Expand Down
12 changes: 9 additions & 3 deletions src/main/java/org/sunbird/workflow/config/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ private Constants() {
public static final String ENROLMENT_END_DATE = "enrollment_enddate";
public static final String CORE_CONNECTIONS_PER_HOST_FOR_LOCAL = "coreConnectionsPerHostForLocal";
public static final String CORE_CONNECTIONS_PER_HOST_FOR_REMOTE = "coreConnectionsPerHostForRemote";
public static final String MAX_CONNECTIONS_PER_HOST_FOR_LOCAl = "maxConnectionsPerHostForLocal";
public static final String MAX_CONNECTIONS_PER_HOST_FOR_REMOTE = "maxConnectionsPerHostForRemote";
public static final String MAX_REQUEST_PER_CONNECTION = "maxRequestsPerConnection";
public static final String HEARTBEAT_INTERVAL = "heartbeatIntervalSeconds";
Expand Down Expand Up @@ -292,7 +291,7 @@ private Constants() {
public static final String X_AUTH_TOKEN = "x-authenticated-user-token";
public static final String DOT_SEPARATOR = ".";
public static final String SHA_256_WITH_RSA = "SHA256withRSA";
public static final String _UNAUTHORIZED = "Unauthorized";
public static final String CAP_UNAUTHORIZED = "Unauthorized";
public static final String SUB = "sub";
public static final String SSO_URL = "sso.url";
public static final String SSO_REALM = "sso.realm";
Expand Down Expand Up @@ -394,7 +393,7 @@ private Constants() {
public static final String NOTIFICATIONS = "notifications";
public static final String MODERATOR_TRANSFER_SUBJECT_TEMPLATE = "Urgent: Moderator Transfer Request for \"%s\"";
public static final String ORG_TRANSFER_STATE = "orgTransferState";
public static final String inWorkflow = "inWorkflow";
public static final String IN_WORKFLOW = "inWorkflow";
public static final String GROUP_DESGINATION_ENTITIES = "groupDesignationEntities";
public static final String API_WORKFLOW_LOAD_CSV_BULK_APPROVAL = "api.workflow.load.csv.bulk.approval";
public static final String ACTION_APPROVE_REJECT = "action(approve/reject)";
Expand All @@ -418,5 +417,12 @@ private Constants() {
public static final String PROFILE_UPDATE = "PROFILE_UPDATE";
public static final String TRANSFER_UPDATE = "TRANSFER_UPDATE";
public static final String UPDATE = "UPDATE";
public static final String DEFAULT_UPDATED_FILE_NAME = "updated_file.csv";
public static final String REMOVE_QUOTES_REGEX = "^\"|\"$";
public static final String EMAIL_REGEX = "^[a-zA-Z0-9_+&*-]+(?>\\.[a-zA-Z0-9_+&*-]+)*@" + "(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,7}$";
public static final String FULL_NAME_REGEX = "^(?!.*\\n)[a-zA-Z]+(?:['\\s][a-zA-Z]+)*(?<!\\.|\\s)$";
public static final String EXTERNAL_SYSTEM_ID_REGEX = "^(?=.{1,30}$)[a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)*$";



}
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
package org.sunbird.workflow.controller;

import java.io.IOException;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.sunbird.workflow.config.Constants;
import org.sunbird.workflow.models.*;
import org.sunbird.workflow.models.Response;
import org.sunbird.workflow.models.SearchCriteria;
import org.sunbird.workflow.models.SearchCriteriaV2;
import org.sunbird.workflow.models.WfRequest;
import org.sunbird.workflow.service.BPWorkFlowService;

import org.sunbird.workflow.service.DomainWhiteListWorkFlowService;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/v1/blendedprogram/workflow")
Expand Down Expand Up @@ -148,7 +150,7 @@ public ResponseEntity<Response> blendedProgramWfStatusCount( @RequestBody Search
}

@PostMapping(path = "/getUserApprovalDataInCsv", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getUserApprovalDataInCsv(@RequestBody SearchCriteria searchCriteria) {
public ResponseEntity<ByteArrayResource> getUserApprovalDataInCsv(@RequestBody SearchCriteria searchCriteria) {
return bPWorkFlowService.generateUserApprovalCsv(searchCriteria);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.InputStreamResource;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
Expand Down Expand Up @@ -118,7 +119,7 @@ public ResponseEntity<SBApiResponse> getBulkUpdateStatus(@RequestHeader(Constant
}

@GetMapping(path = "/admin/bulkbuplodfile/download/{fileName}")
public ResponseEntity<?> downloadBulkuplodFile(@PathVariable("fileName") String fileName) {
public ResponseEntity<InputStreamResource> downloadBulkuplodFile(@PathVariable("fileName") String fileName) {
return workflowService.downloadBulkUploadFile(fileName);
}

Expand All @@ -131,7 +132,7 @@ public ResponseEntity<SBApiResponse> wfBulkUpdateTransitionV1(@RequestHeader(Con


@GetMapping(path = "/admin/pendingRequest/download")
public ResponseEntity<?> downloadPendingRequestFile(@RequestHeader(Constants.X_AUTH_TOKEN) String userAuthToken) {
public ResponseEntity<?> downloadPendingRequestFile(@RequestHeader(Constants.X_AUTH_TOKEN) String userAuthToken) { //NOSONAR
return workflowService.downloadPendingRequestFile(userAuthToken);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package org.sunbird.workflow.exception;

import lombok.Getter;
import lombok.Setter;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;

@ResponseStatus(value = HttpStatus.BAD_REQUEST)
@ResponseBody
@Getter
@Setter
public class InvalidDataInputException extends RuntimeException {

private static final long serialVersionUID = 1L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
* @author Manzarul
*/
public enum ResponseCode {
unAuthorized(ResponseMessage.Key.UNAUTHORIZED_USER, ResponseMessage.Message.UNAUTHORIZED_USER),
internalError(ResponseMessage.Key.INTERNAL_ERROR, ResponseMessage.Message.INTERNAL_ERROR),
UNAUTHORIZED(ResponseMessage.Key.UNAUTHORIZED_USER, ResponseMessage.Message.UNAUTHORIZED_USER),
INTERNAL_ERROR(ResponseMessage.Key.INTERNAL_ERROR, ResponseMessage.Message.INTERNAL_ERROR),

OK(200),
CLIENT_ERROR(400),
Expand Down Expand Up @@ -46,7 +46,7 @@ public static ResponseCode getResponse(String errorCode) {
if (StringUtils.isBlank(errorCode)) {
return null;
} else if (Constants.UNAUTHORIZED.equals(errorCode)) {
return ResponseCode.unAuthorized;
return ResponseCode.UNAUTHORIZED;
} else {
ResponseCode value = null;
ResponseCode[] responseCodes = ResponseCode.values();
Expand Down
Loading