Remove resolved TODO tasks

pull/146/head
johnniang 2019-05-06 22:47:42 +08:00
parent 5271be57c1
commit d16a1f8de6
16 changed files with 30 additions and 117 deletions

View File

@ -78,7 +78,6 @@ public class InstallController {
@ResponseBody @ResponseBody
@CacheLock @CacheLock
public BaseResponse<String> installBlog(@RequestBody @Valid InstallParam installParam) { public BaseResponse<String> installBlog(@RequestBody @Valid InstallParam installParam) {
// TODO Install blog.
// Check is installed // Check is installed
boolean isInstalled = optionService.getByPropertyOrDefault(PrimaryProperties.IS_INSTALLED, Boolean.class, false); boolean isInstalled = optionService.getByPropertyOrDefault(PrimaryProperties.IS_INSTALLED, Boolean.class, false);

View File

@ -59,7 +59,6 @@ public class QnYunFileHandler implements FileHandler {
String domain = optionService.getByPropertyOfNonNull(QnYunProperties.DOMAIN).toString(); String domain = optionService.getByPropertyOfNonNull(QnYunProperties.DOMAIN).toString();
String smallUrl = optionService.getByPropertyOrDefault(QnYunProperties.SMALL_URL, String.class, ""); String smallUrl = optionService.getByPropertyOrDefault(QnYunProperties.SMALL_URL, String.class, "");
// TODO Consider to cache the configuration
// Create configuration // Create configuration
Configuration configuration = new Configuration(zone); Configuration configuration = new Configuration(zone);
@ -88,7 +87,6 @@ public class QnYunFileHandler implements FileHandler {
// Get upload manager // Get upload manager
UploadManager uploadManager = new UploadManager(configuration, fileRecorder); UploadManager uploadManager = new UploadManager(configuration, fileRecorder);
// Put the file // Put the file
// TODO May need to set key manually
Response response = uploadManager.put(file.getInputStream(), null, uploadToken, null, null); Response response = uploadManager.put(file.getInputStream(), null, uploadToken, null, null);
log.debug("QnYun response: [{}]", response.toString()); log.debug("QnYun response: [{}]", response.toString());
@ -136,7 +134,6 @@ public class QnYunFileHandler implements FileHandler {
String secretKey = optionService.getByPropertyOfNonNull(QnYunProperties.SECRET_KEY).toString(); String secretKey = optionService.getByPropertyOfNonNull(QnYunProperties.SECRET_KEY).toString();
String bucket = optionService.getByPropertyOfNonNull(QnYunProperties.BUCKET).toString(); String bucket = optionService.getByPropertyOfNonNull(QnYunProperties.BUCKET).toString();
// TODO Consider to cache the configuration
// Create configuration // Create configuration
Configuration configuration = new Configuration(zone); Configuration configuration = new Configuration(zone);

View File

@ -1,22 +1,21 @@
package run.halo.app.handler.file; package run.halo.app.handler.file;
import run.halo.app.exception.FileOperationException;
import run.halo.app.model.enums.AttachmentType;
import run.halo.app.model.support.UploadResult;
import run.halo.app.utils.FilenameUtils;
import run.halo.app.utils.HttpClientUtils;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.ToString; import lombok.ToString;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.http.*; import org.springframework.http.*;
import org.springframework.lang.NonNull; import org.springframework.lang.Nullable;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.LinkedMultiValueMap;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import run.halo.app.exception.FileOperationException;
import run.halo.app.model.enums.AttachmentType; import run.halo.app.model.enums.AttachmentType;
import run.halo.app.model.support.UploadResult;
import run.halo.app.utils.FilenameUtils;
import run.halo.app.utils.HttpClientUtils;
import java.io.IOException; import java.io.IOException;
import java.util.Objects; import java.util.Objects;
@ -89,7 +88,7 @@ public class SmmsFileHandler implements FileHandler {
// Check error // Check error
if (!isResponseSuccessfully(smmsResponse)) { if (!isResponseSuccessfully(smmsResponse)) {
log.error("Smms response detail: [{}]", smmsResponse); log.error("Smms response detail: [{}]", smmsResponse);
throw new FileOperationException(smmsResponse.getMsg()).setErrorData(smmsResponse); throw new FileOperationException(smmsResponse == null ? "Smms response is null" : smmsResponse.getMsg()).setErrorData(smmsResponse);
} }
// Get response data // Get response data
@ -149,10 +148,8 @@ public class SmmsFileHandler implements FileHandler {
* @param smmsResponse smms response must not be null * @param smmsResponse smms response must not be null
* @return true if response successfully; false otherwise * @return true if response successfully; false otherwise
*/ */
private boolean isResponseSuccessfully(@NonNull SmmsResponse smmsResponse) { private boolean isResponseSuccessfully(@Nullable SmmsResponse smmsResponse) {
Assert.notNull(smmsResponse, "Smms response must not be null"); return smmsResponse != null && smmsResponse.getCode().equals(SUCCESS_CODE);
return smmsResponse.getCode().equals(SUCCESS_CODE);
} }
@Data @Data

View File

@ -51,7 +51,6 @@ public class UpYunFileHandler implements FileHandler {
UpYun upYun = new UpYun(ossBucket, ossOperator, ossPassword); UpYun upYun = new UpYun(ossBucket, ossOperator, ossPassword);
upYun.setDebug(log.isDebugEnabled()); upYun.setDebug(log.isDebugEnabled());
upYun.setTimeout(60); upYun.setTimeout(60);
// TODO Provide a property for choosing
upYun.setApiDomain(UpYun.ED_AUTO); upYun.setApiDomain(UpYun.ED_AUTO);
try { try {

View File

@ -1,72 +0,0 @@
package run.halo.app.handler.theme.config;
import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Component;
import run.halo.app.handler.theme.config.impl.YamlThemeConfigResolverImpl;
import run.halo.app.handler.theme.config.support.Group;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* Theme configuration resolver manager.
*
* @author johnniang
* @date 4/10/19
*/
@Component
public class ThemeConfigResolvers {
private final Map<ConfigType, ThemeConfigResolver> resolverMap = new ConcurrentHashMap<>(2);
public ThemeConfigResolvers() {
resolverMap.put(ConfigType.YAML, new YamlThemeConfigResolverImpl());
// TODO Add another theme config resolver
}
/**
* Config type enum.
*/
public enum ConfigType {
YAML,
PROPERTY
}
/**
* Resolves the content.
*
* @param content content must not be blank
* @param type config type
* @return a list of group
* @throws IOException throws when content conversion fails
*/
public List<Group> resolve(@NonNull String content, @Nullable ConfigType type) throws IOException {
ThemeConfigResolver resolver = getResolver(type);
if (resolver == null) {
throw new UnsupportedOperationException("Unsupported theme config type: " + type);
}
return resolver.resolve(content);
}
/**
* Resolves the content.
*
* @param content content must not be blank
* @return a list of group
* @throws IOException throws when content conversion fails
*/
public List<Group> resolve(String content) throws IOException {
return resolve(content, ConfigType.YAML);
}
private ThemeConfigResolver getResolver(@Nullable ConfigType type) {
return type == null ? null : resolverMap.get(type);
}
}

View File

@ -172,7 +172,6 @@ public class YamlThemeConfigResolverImpl implements ThemeConfigResolver {
// Build option // Build option
Option option = new Option(); Option option = new Option();
// TODO Convert the value type
option.setValue(optionMap.get("value")); option.setValue(optionMap.get("value"));
option.setLabel(optionMap.get("label").toString()); option.setLabel(optionMap.get("label").toString());
@ -192,7 +191,6 @@ public class YamlThemeConfigResolverImpl implements ThemeConfigResolver {
Option option = new Option(); Option option = new Option();
// TODO Convert the value type
option.setValue(key); option.setValue(key);
option.setLabel(optionMap.get("label").toString()); option.setLabel(optionMap.get("label").toString());

View File

@ -58,7 +58,6 @@ public class StartedListener implements ApplicationListener<ApplicationStartedEv
String blogUrl = optionService.getBlogBaseUrl(); String blogUrl = optionService.getBlogBaseUrl();
log.info("Halo started at {}", blogUrl); log.info("Halo started at {}", blogUrl);
// TODO admin may be changeable
log.info("Halo admin started at {}/admin", blogUrl); log.info("Halo admin started at {}/admin", blogUrl);
if (!haloProperties.isDocDisabled()) { if (!haloProperties.isDocDisabled()) {
log.debug("Halo doc was enable at {}/swagger-ui.html", blogUrl); log.debug("Halo doc was enable at {}/swagger-ui.html", blogUrl);

View File

@ -12,6 +12,7 @@ import java.util.List;
* @date : 2018/12/31 * @date : 2018/12/31
*/ */
@Component @Component
@Deprecated
public class RecentCommentsMethod implements TemplateMethodModelEx { public class RecentCommentsMethod implements TemplateMethodModelEx {
public RecentCommentsMethod(Configuration configuration) { public RecentCommentsMethod(Configuration configuration) {

View File

@ -12,6 +12,7 @@ import java.util.List;
* @date : 2018/12/31 * @date : 2018/12/31
*/ */
@Component @Component
@Deprecated
public class RecentPostsMethod implements TemplateMethodModelEx { public class RecentPostsMethod implements TemplateMethodModelEx {
public RecentPostsMethod(Configuration configuration) { public RecentPostsMethod(Configuration configuration) {

View File

@ -69,20 +69,20 @@ public class OptionServiceImpl extends AbstractCrudService<Option, Integer> impl
return; return;
} }
// TODO Consider cache options with map Option option = optionRepository.findByKey(key)
Option option = optionRepository.findByKey(key).map(anOption -> { .map(anOption -> {
log.debug("Updating option key: [{}], value: from [{}] to [{}]", key, anOption.getValue(), value); log.debug("Updating option key: [{}], value: from [{}] to [{}]", key, anOption.getValue(), value);
// Exist // Exist
anOption.setValue(value); anOption.setValue(value);
return anOption; return anOption;
}).orElseGet(() -> { }).orElseGet(() -> {
log.debug("Creating option key: [{}], value: [{}]", key, value); log.debug("Creating option key: [{}], value: [{}]", key, value);
// Not exist // Not exist
Option anOption = new Option(); Option anOption = new Option();
anOption.setKey(key); anOption.setKey(key);
anOption.setValue(value); anOption.setValue(value);
return anOption; return anOption;
}); });
// Save or update the options // Save or update the options
Option savedOption = optionRepository.save(option); Option savedOption = optionRepository.save(option);
@ -96,7 +96,6 @@ public class OptionServiceImpl extends AbstractCrudService<Option, Integer> impl
return; return;
} }
// TODO Optimize the queries
options.forEach(this::save); options.forEach(this::save);
publishOptionUpdatedEvent(); publishOptionUpdatedEvent();
@ -108,7 +107,6 @@ public class OptionServiceImpl extends AbstractCrudService<Option, Integer> impl
return; return;
} }
// TODO Optimize the query
optionParams.forEach(optionParam -> save(optionParam.getKey(), optionParam.getValue())); optionParams.forEach(optionParam -> save(optionParam.getKey(), optionParam.getValue()));
publishOptionUpdatedEvent(); publishOptionUpdatedEvent();

View File

@ -92,7 +92,6 @@ public class RecoveryServiceImpl implements RecoveryService {
@Override @Override
@Async @Async
public void migrateFromV0_4_3(MultipartFile file) { public void migrateFromV0_4_3(MultipartFile file) {
// TODO Async execution
// Get migration content // Get migration content
try { try {
String migrationContent = FileCopyUtils.copyToString(new InputStreamReader(file.getInputStream())); String migrationContent = FileCopyUtils.copyToString(new InputStreamReader(file.getInputStream()));
@ -192,10 +191,10 @@ public class RecoveryServiceImpl implements RecoveryService {
try { try {
if (postType.equalsIgnoreCase("post")) { if (postType.equalsIgnoreCase("post")) {
// TODO Handle post // Handle post
result.add(handlePost(post, postMap)); result.add(handlePost(post, postMap));
} else { } else {
// TODO Handle page // Handle page
result.add(handleSheet(post, postMap)); result.add(handleSheet(post, postMap));
} }
} catch (Exception e) { } catch (Exception e) {
@ -244,7 +243,7 @@ public class RecoveryServiceImpl implements RecoveryService {
Sheet createdSheet = sheetService.createOrUpdateBy(sheet); Sheet createdSheet = sheetService.createOrUpdateBy(sheet);
Object commentsObject = postMap.get("comments"); Object commentsObject = postMap.get("comments");
// TODO Handle comments // Handle comments
List<BaseComment> baseComments = handleComment(commentsObject, createdSheet.getId()); List<BaseComment> baseComments = handleComment(commentsObject, createdSheet.getId());
List<SheetComment> sheetComments = baseComments.stream() List<SheetComment> sheetComments = baseComments.stream()

View File

@ -47,6 +47,8 @@ import java.util.zip.ZipInputStream;
import static run.halo.app.model.support.HaloConst.DEFAULT_THEME_ID; import static run.halo.app.model.support.HaloConst.DEFAULT_THEME_ID;
/** /**
* Theme service implementation.
*
* @author ryanwang * @author ryanwang
* @date : 2019/3/26 * @date : 2019/3/26
*/ */
@ -250,8 +252,6 @@ public class ThemeServiceImpl implements ThemeService {
public List<Group> fetchConfig(String themeId) { public List<Group> fetchConfig(String themeId) {
Assert.hasText(themeId, "Theme id must not be blank"); Assert.hasText(themeId, "Theme id must not be blank");
// TODO Cache the config
// Get theme property // Get theme property
ThemeProperty themeProperty = getThemeOfNonNullBy(themeId); ThemeProperty themeProperty = getThemeOfNonNullBy(themeId);

View File

@ -43,7 +43,6 @@ public class BeanUtils {
// Init the instance // Init the instance
try { try {
// New instance for the target class // New instance for the target class
// TODO Class.newInstance() is deprecated in Java 9
T targetInstance = targetClass.newInstance(); T targetInstance = targetClass.newInstance();
// Copy properties // Copy properties
org.springframework.beans.BeanUtils.copyProperties(source, targetInstance, getNullPropertyNames(source)); org.springframework.beans.BeanUtils.copyProperties(source, targetInstance, getNullPropertyNames(source));

View File

@ -118,7 +118,6 @@ public class HaloUtils {
if (!StringUtils.isBlank(url)) { if (!StringUtils.isBlank(url)) {
return url; return url;
} }
// TODO Consider to UUID
return String.valueOf(System.currentTimeMillis()); return String.valueOf(System.currentTimeMillis());
} }

View File

@ -40,7 +40,6 @@ public class HttpClientUtils {
*/ */
@NonNull @NonNull
public static CloseableHttpClient createHttpsClient(int timeout) throws KeyStoreException, NoSuchAlgorithmException, KeyManagementException { public static CloseableHttpClient createHttpsClient(int timeout) throws KeyStoreException, NoSuchAlgorithmException, KeyManagementException {
// TODO Set key store in production environment
SSLContext sslContext = new SSLContextBuilder() SSLContext sslContext = new SSLContextBuilder()
.loadTrustMaterial(null, (certificate, authType) -> true) .loadTrustMaterial(null, (certificate, authType) -> true)
.build(); .build();

View File

@ -1,4 +1,4 @@
package run.halo.app.handler.theme.config.impl; package run.halo.app.handler.theme;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;