Fixed typos

pull/11/head
Jens Pelzetter 2022-01-04 19:52:59 +01:00
parent 0c0e1135c0
commit c78f233c72
1 changed files with 43 additions and 50 deletions

View File

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