提交 d16a1f8d 编写于 作者: J johnniang

Remove resolved TODO tasks

上级 5271be57
......@@ -78,7 +78,6 @@ public class InstallController {
@ResponseBody
@CacheLock
public BaseResponse<String> installBlog(@RequestBody @Valid InstallParam installParam) {
// TODO Install blog.
// Check is installed
boolean isInstalled = optionService.getByPropertyOrDefault(PrimaryProperties.IS_INSTALLED, Boolean.class, false);
......
......@@ -59,7 +59,6 @@ public class QnYunFileHandler implements FileHandler {
String domain = optionService.getByPropertyOfNonNull(QnYunProperties.DOMAIN).toString();
String smallUrl = optionService.getByPropertyOrDefault(QnYunProperties.SMALL_URL, String.class, "");
// TODO Consider to cache the configuration
// Create configuration
Configuration configuration = new Configuration(zone);
......@@ -88,7 +87,6 @@ public class QnYunFileHandler implements FileHandler {
// Get upload manager
UploadManager uploadManager = new UploadManager(configuration, fileRecorder);
// Put the file
// TODO May need to set key manually
Response response = uploadManager.put(file.getInputStream(), null, uploadToken, null, null);
log.debug("QnYun response: [{}]", response.toString());
......@@ -136,7 +134,6 @@ public class QnYunFileHandler implements FileHandler {
String secretKey = optionService.getByPropertyOfNonNull(QnYunProperties.SECRET_KEY).toString();
String bucket = optionService.getByPropertyOfNonNull(QnYunProperties.BUCKET).toString();
// TODO Consider to cache the configuration
// Create configuration
Configuration configuration = new Configuration(zone);
......
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.NoArgsConstructor;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.*;
import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile;
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 java.io.IOException;
import java.util.Objects;
......@@ -89,7 +88,7 @@ public class SmmsFileHandler implements FileHandler {
// Check error
if (!isResponseSuccessfully(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
......@@ -149,10 +148,8 @@ public class SmmsFileHandler implements FileHandler {
* @param smmsResponse smms response must not be null
* @return true if response successfully; false otherwise
*/
private boolean isResponseSuccessfully(@NonNull SmmsResponse smmsResponse) {
Assert.notNull(smmsResponse, "Smms response must not be null");
return smmsResponse.getCode().equals(SUCCESS_CODE);
private boolean isResponseSuccessfully(@Nullable SmmsResponse smmsResponse) {
return smmsResponse != null && smmsResponse.getCode().equals(SUCCESS_CODE);
}
@Data
......
......@@ -51,7 +51,6 @@ public class UpYunFileHandler implements FileHandler {
UpYun upYun = new UpYun(ossBucket, ossOperator, ossPassword);
upYun.setDebug(log.isDebugEnabled());
upYun.setTimeout(60);
// TODO Provide a property for choosing
upYun.setApiDomain(UpYun.ED_AUTO);
try {
......
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);
}
}
......@@ -172,7 +172,6 @@ public class YamlThemeConfigResolverImpl implements ThemeConfigResolver {
// Build option
Option option = new Option();
// TODO Convert the value type
option.setValue(optionMap.get("value"));
option.setLabel(optionMap.get("label").toString());
......@@ -192,7 +191,6 @@ public class YamlThemeConfigResolverImpl implements ThemeConfigResolver {
Option option = new Option();
// TODO Convert the value type
option.setValue(key);
option.setLabel(optionMap.get("label").toString());
......
......@@ -58,7 +58,6 @@ public class StartedListener implements ApplicationListener<ApplicationStartedEv
String blogUrl = optionService.getBlogBaseUrl();
log.info("Halo started at {}", blogUrl);
// TODO admin may be changeable
log.info("Halo admin started at {}/admin", blogUrl);
if (!haloProperties.isDocDisabled()) {
log.debug("Halo doc was enable at {}/swagger-ui.html", blogUrl);
......
......@@ -12,6 +12,7 @@ import java.util.List;
* @date : 2018/12/31
*/
@Component
@Deprecated
public class RecentCommentsMethod implements TemplateMethodModelEx {
public RecentCommentsMethod(Configuration configuration) {
......
......@@ -12,6 +12,7 @@ import java.util.List;
* @date : 2018/12/31
*/
@Component
@Deprecated
public class RecentPostsMethod implements TemplateMethodModelEx {
public RecentPostsMethod(Configuration configuration) {
......
......@@ -69,20 +69,20 @@ public class OptionServiceImpl extends AbstractCrudService<Option, Integer> impl
return;
}
// TODO Consider cache options with map
Option option = optionRepository.findByKey(key).map(anOption -> {
log.debug("Updating option key: [{}], value: from [{}] to [{}]", key, anOption.getValue(), value);
// Exist
anOption.setValue(value);
return anOption;
}).orElseGet(() -> {
log.debug("Creating option key: [{}], value: [{}]", key, value);
// Not exist
Option anOption = new Option();
anOption.setKey(key);
anOption.setValue(value);
return anOption;
});
Option option = optionRepository.findByKey(key)
.map(anOption -> {
log.debug("Updating option key: [{}], value: from [{}] to [{}]", key, anOption.getValue(), value);
// Exist
anOption.setValue(value);
return anOption;
}).orElseGet(() -> {
log.debug("Creating option key: [{}], value: [{}]", key, value);
// Not exist
Option anOption = new Option();
anOption.setKey(key);
anOption.setValue(value);
return anOption;
});
// Save or update the options
Option savedOption = optionRepository.save(option);
......@@ -96,7 +96,6 @@ public class OptionServiceImpl extends AbstractCrudService<Option, Integer> impl
return;
}
// TODO Optimize the queries
options.forEach(this::save);
publishOptionUpdatedEvent();
......@@ -108,7 +107,6 @@ public class OptionServiceImpl extends AbstractCrudService<Option, Integer> impl
return;
}
// TODO Optimize the query
optionParams.forEach(optionParam -> save(optionParam.getKey(), optionParam.getValue()));
publishOptionUpdatedEvent();
......
......@@ -92,7 +92,6 @@ public class RecoveryServiceImpl implements RecoveryService {
@Override
@Async
public void migrateFromV0_4_3(MultipartFile file) {
// TODO Async execution
// Get migration content
try {
String migrationContent = FileCopyUtils.copyToString(new InputStreamReader(file.getInputStream()));
......@@ -192,10 +191,10 @@ public class RecoveryServiceImpl implements RecoveryService {
try {
if (postType.equalsIgnoreCase("post")) {
// TODO Handle post
// Handle post
result.add(handlePost(post, postMap));
} else {
// TODO Handle page
// Handle page
result.add(handleSheet(post, postMap));
}
} catch (Exception e) {
......@@ -244,7 +243,7 @@ public class RecoveryServiceImpl implements RecoveryService {
Sheet createdSheet = sheetService.createOrUpdateBy(sheet);
Object commentsObject = postMap.get("comments");
// TODO Handle comments
// Handle comments
List<BaseComment> baseComments = handleComment(commentsObject, createdSheet.getId());
List<SheetComment> sheetComments = baseComments.stream()
......
......@@ -47,6 +47,8 @@ import java.util.zip.ZipInputStream;
import static run.halo.app.model.support.HaloConst.DEFAULT_THEME_ID;
/**
* Theme service implementation.
*
* @author ryanwang
* @date : 2019/3/26
*/
......@@ -250,8 +252,6 @@ public class ThemeServiceImpl implements ThemeService {
public List<Group> fetchConfig(String themeId) {
Assert.hasText(themeId, "Theme id must not be blank");
// TODO Cache the config
// Get theme property
ThemeProperty themeProperty = getThemeOfNonNullBy(themeId);
......
......@@ -43,7 +43,6 @@ public class BeanUtils {
// Init the instance
try {
// New instance for the target class
// TODO Class.newInstance() is deprecated in Java 9
T targetInstance = targetClass.newInstance();
// Copy properties
org.springframework.beans.BeanUtils.copyProperties(source, targetInstance, getNullPropertyNames(source));
......
......@@ -118,7 +118,6 @@ public class HaloUtils {
if (!StringUtils.isBlank(url)) {
return url;
}
// TODO Consider to UUID
return String.valueOf(System.currentTimeMillis());
}
......
......@@ -40,7 +40,6 @@ public class HttpClientUtils {
*/
@NonNull
public static CloseableHttpClient createHttpsClient(int timeout) throws KeyStoreException, NoSuchAlgorithmException, KeyManagementException {
// TODO Set key store in production environment
SSLContext sslContext = new SSLContextBuilder()
.loadTrustMaterial(null, (certificate, authType) -> true)
.build();
......
package run.halo.app.handler.theme.config.impl;
package run.halo.app.handler.theme;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册