Merge pull request 'Fixed typos' (#11) from theme-bugfixes into master
Reviewed-on: #11pull/12/head
commit
a859aec500
|
|
@ -95,7 +95,6 @@ public class FileSystemThemeProvider implements ThemeProvider {
|
|||
try {
|
||||
if (!ccmFiles.isDirectory(BASE_PATH)
|
||||
|| !ccmFiles.isDirectory(DRAFT_THEMES_PATH)) {
|
||||
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
|
|
@ -106,7 +105,6 @@ public class FileSystemThemeProvider implements ThemeProvider {
|
|||
.filter(info -> info.isPresent())
|
||||
.map(info -> info.get())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
} catch (FileAccessException
|
||||
| FileDoesNotExistException
|
||||
| InsufficientPermissionsException ex) {
|
||||
|
|
@ -119,7 +117,6 @@ public class FileSystemThemeProvider implements ThemeProvider {
|
|||
|
||||
@Override
|
||||
public List<ThemeInfo> getLiveThemes() {
|
||||
|
||||
try {
|
||||
if (!ccmFiles.isDirectory(BASE_PATH)
|
||||
|| !ccmFiles.isDirectory(LIVE_THEMES_PATH)) {
|
||||
|
|
@ -146,16 +143,16 @@ public class FileSystemThemeProvider implements ThemeProvider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Optional<ThemeInfo> getThemeInfo(final String theme,
|
||||
final ThemeVersion version) {
|
||||
|
||||
public Optional<ThemeInfo> getThemeInfo(
|
||||
final String theme, final ThemeVersion version
|
||||
) {
|
||||
return readInfo(theme);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean providesTheme(final String theme,
|
||||
final ThemeVersion version) {
|
||||
|
||||
public boolean providesTheme(
|
||||
final String theme, final ThemeVersion version
|
||||
) {
|
||||
final String themePath = createThemePath(theme, version);
|
||||
|
||||
try {
|
||||
|
|
@ -167,7 +164,6 @@ public class FileSystemThemeProvider implements ThemeProvider {
|
|||
|
||||
@Override
|
||||
public ThemeInfo createTheme(final String themeName) {
|
||||
|
||||
Objects.requireNonNull(themeName);
|
||||
|
||||
if (themeName.isEmpty() || themeName.matches("\\s*")) {
|
||||
|
|
@ -234,9 +230,10 @@ public class FileSystemThemeProvider implements ThemeProvider {
|
|||
}
|
||||
|
||||
try {
|
||||
ccmFiles.deleteFile(String.format(DRAFT_THEMES_PATH + "/%s",
|
||||
themeName),
|
||||
true);
|
||||
ccmFiles.deleteFile(
|
||||
String.format(DRAFT_THEMES_PATH + "/%s", themeName),
|
||||
true
|
||||
);
|
||||
} catch (FileAccessException
|
||||
| FileDoesNotExistException
|
||||
| DirectoryNotEmptyException
|
||||
|
|
@ -246,10 +243,9 @@ public class FileSystemThemeProvider implements ThemeProvider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<ThemeFileInfo> listThemeFiles(final String theme,
|
||||
final ThemeVersion version,
|
||||
final String path) {
|
||||
|
||||
public List<ThemeFileInfo> listThemeFiles(
|
||||
final String theme, final ThemeVersion version, final String path
|
||||
) {
|
||||
final String themePath = createThemePath(theme, version);
|
||||
final String filePath;
|
||||
if ("/".equals(path)) {
|
||||
|
|
@ -263,9 +259,12 @@ public class FileSystemThemeProvider implements ThemeProvider {
|
|||
return ccmFiles
|
||||
.listFiles(filePath)
|
||||
.stream()
|
||||
.map(currentPath -> buildThemeFileInfo(
|
||||
.map(
|
||||
currentPath -> buildThemeFileInfo(
|
||||
themePath,
|
||||
String.join("/", path, currentPath)))
|
||||
String.join("/", path, currentPath)
|
||||
)
|
||||
)
|
||||
.collect(Collectors.toList());
|
||||
} else {
|
||||
final List<ThemeFileInfo> result = new ArrayList<>();
|
||||
|
|
@ -279,7 +278,6 @@ public class FileSystemThemeProvider implements ThemeProvider {
|
|||
} catch (FileAccessException
|
||||
| FileDoesNotExistException
|
||||
| InsufficientPermissionsException ex) {
|
||||
|
||||
throw new UnexpectedErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
|
@ -293,9 +291,7 @@ public class FileSystemThemeProvider implements ThemeProvider {
|
|||
|
||||
try {
|
||||
if (ccmFiles.existsFile(filePath)) {
|
||||
|
||||
return Optional.of(buildThemeFileInfo(themePath, path));
|
||||
|
||||
} else {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
|
@ -326,16 +322,14 @@ public class FileSystemThemeProvider implements ThemeProvider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public OutputStream getOutputStreamForThemeFile(final String theme,
|
||||
final String path) {
|
||||
|
||||
public OutputStream getOutputStreamForThemeFile(
|
||||
final String theme, final String path
|
||||
) {
|
||||
final String themePath = createThemePath(theme, ThemeVersion.DRAFT);
|
||||
final String filePath = String.join("/", themePath, path);
|
||||
|
||||
try {
|
||||
|
||||
return ccmFiles.createOutputStream(filePath);
|
||||
|
||||
} catch (FileAccessException
|
||||
| InsufficientPermissionsException ex) {
|
||||
|
||||
|
|
@ -345,7 +339,6 @@ public class FileSystemThemeProvider implements ThemeProvider {
|
|||
|
||||
@Override
|
||||
public void deleteThemeFile(final String theme, final String path) {
|
||||
|
||||
final String themePath = createThemePath(theme, ThemeVersion.DRAFT);
|
||||
final String filePath = String.join("/", themePath, path);
|
||||
|
||||
|
|
@ -373,7 +366,6 @@ public class FileSystemThemeProvider implements ThemeProvider {
|
|||
|
||||
@Override
|
||||
public void publishTheme(final String theme) {
|
||||
|
||||
final String draftThemePath = createThemePath(theme,
|
||||
ThemeVersion.DRAFT);
|
||||
final String liveThemePath = createThemePath(theme,
|
||||
|
|
@ -391,7 +383,6 @@ public class FileSystemThemeProvider implements ThemeProvider {
|
|||
}
|
||||
|
||||
try {
|
||||
|
||||
ccmFiles.createDirectory(liveThemePathTmp);
|
||||
|
||||
ccmFiles.copyFile(draftThemePath, liveThemePathTmp, true);
|
||||
|
|
@ -412,9 +403,9 @@ public class FileSystemThemeProvider implements ThemeProvider {
|
|||
|
||||
@Override
|
||||
public void unpublishTheme(final String theme) {
|
||||
|
||||
final String liveThemePath = createThemePath(theme,
|
||||
ThemeVersion.LIVE);
|
||||
final String liveThemePath = createThemePath(
|
||||
theme, ThemeVersion.LIVE
|
||||
);
|
||||
try {
|
||||
ccmFiles.deleteFile(liveThemePath, true);
|
||||
} catch (DirectoryNotEmptyException
|
||||
|
|
@ -425,9 +416,9 @@ public class FileSystemThemeProvider implements ThemeProvider {
|
|||
}
|
||||
}
|
||||
|
||||
private String createThemePath(final String theme,
|
||||
final ThemeVersion version) {
|
||||
|
||||
private String createThemePath(
|
||||
final String theme, final ThemeVersion version
|
||||
) {
|
||||
switch (version) {
|
||||
|
||||
case DRAFT:
|
||||
|
|
@ -435,14 +426,16 @@ public class FileSystemThemeProvider implements ThemeProvider {
|
|||
case LIVE:
|
||||
return String.format(LIVE_THEMES_PATH + "/%s", theme);
|
||||
default:
|
||||
throw new IllegalArgumentException(String
|
||||
.format("Illegal argument for ThemeVersion \"%s\".",
|
||||
version));
|
||||
throw new IllegalArgumentException(
|
||||
String.format(
|
||||
"Illegal argument for ThemeVersion \"%s\".",
|
||||
version
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private Optional<ThemeInfo> readInfo(final String themeName) {
|
||||
|
||||
final ThemeManifest manifest;
|
||||
final ThemeVersion themeVersion;
|
||||
try {
|
||||
|
|
@ -455,12 +448,14 @@ public class FileSystemThemeProvider implements ThemeProvider {
|
|||
);
|
||||
|
||||
if (ccmFiles.existsFile(jsonPath)) {
|
||||
final InputStream inputStream = ccmFiles
|
||||
.createInputStream(jsonPath);
|
||||
final InputStream inputStream = ccmFiles.createInputStream(
|
||||
jsonPath
|
||||
);
|
||||
manifest = manifestUtil.loadManifest(inputStream, "theme.json");
|
||||
} else if (ccmFiles.existsFile(xmlPath)) {
|
||||
final InputStream inputStream = ccmFiles
|
||||
.createInputStream(xmlPath);
|
||||
final InputStream inputStream = ccmFiles.createInputStream(
|
||||
xmlPath
|
||||
);
|
||||
manifest = manifestUtil.loadManifest(inputStream, "theme.xml");
|
||||
} else {
|
||||
return Optional.empty();
|
||||
|
|
@ -483,7 +478,6 @@ public class FileSystemThemeProvider implements ThemeProvider {
|
|||
} catch (FileAccessException
|
||||
| FileDoesNotExistException
|
||||
| InsufficientPermissionsException ex) {
|
||||
|
||||
throw new UnexpectedErrorException(ex);
|
||||
}
|
||||
|
||||
|
|
@ -495,9 +489,9 @@ public class FileSystemThemeProvider implements ThemeProvider {
|
|||
return Optional.of(themeInfo);
|
||||
}
|
||||
|
||||
private ThemeFileInfo buildThemeFileInfo(final String themePath,
|
||||
final String filePath) {
|
||||
|
||||
private ThemeFileInfo buildThemeFileInfo(
|
||||
final String themePath, final String filePath
|
||||
) {
|
||||
final String path;
|
||||
if (themePath.endsWith("/")
|
||||
|| filePath.startsWith("/")) {
|
||||
|
|
@ -525,7 +519,6 @@ public class FileSystemThemeProvider implements ThemeProvider {
|
|||
} catch (FileAccessException
|
||||
| FileDoesNotExistException
|
||||
| InsufficientPermissionsException ex) {
|
||||
|
||||
throw new UnexpectedErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue