ferdinalcandra / BFIPOC

0 stars 1 forks source link

Dirty code on DctmUploadService #18

Closed timpamungkas closed 3 years ago

timpamungkas commented 3 years ago

Too many repetitive code in DctmUploadService.java. E.g. in this section :

            Properties prop = configProperties.getConfigProperties("dctm-rest_config");
        String repositoryName = prop.getProperty("repository_name");
        String user = prop.getProperty("user");
        String pass = prop.getProperty("pass");
        String url = prop.getProperty("url");
        int socketTimeout = Integer.parseInt(prop.getProperty("socket_timeout"));
        int connectTimeout = Integer.parseInt(prop.getProperty("connect_timeout"));
        int connectionRequestTimeout = Integer.parseInt(prop.getProperty("connection_request_timeout"));
        byte[] decodedBytes = Base64.getDecoder().decode(pass);
        String decodedPass = new String(decodedBytes);
        DefaultHttpClient defaultHttpClient = new DefaultHttpClient();

Reduce (e.g. using openfeign or create @Bean with RestTemplate / WebClient)

Also, if you need to get property from config file, you can use @Value on class level.

@Component
public class SomeClass {

    private static final Logger LOG = LoggerFactory.getLogger(SomeClass.class);

    @Value("${my.configuration.key}")
    private String myConfigurationValue;

    @Value("${my.configuration.key.two}")
    private String myConfigurationValueTwo;

}

Refer to issue #8

Stick on DRY principles

timpamungkas commented 3 years ago

unused