Additional endpoint for themes API for getting file info about a file in a theme

Former-commit-id: 09f020329e
restapi
Jens Pelzetter 2020-08-11 15:42:39 +02:00
parent cdf82f4d06
commit 910b61cd81
1 changed files with 38 additions and 0 deletions

View File

@ -412,6 +412,44 @@ public class Themes implements Serializable {
} }
} }
/**
* Gets the {@link ThemeFileInfo} for a file from the theme.
*
* @param themeName The name of the theme.
* @param path The path of the file to retrieve.
*
* @return The content of the requsted file.
*/
@GET
@Path("/themes/{theme}/files/{path:.+}/@info")
@AuthorizationRequired
@RequiresPrivilege(ThemingPrivileges.EDIT_THEME)
public ThemeFileInfo getThemeFileInfo(
@PathParam("theme") final String themeName,
@PathParam("path") final String path
) {
final ThemeProvider provider = findProvider(themeName)
.orElseThrow(
() -> new NotFoundException(
String.format(
"Theme \"%s\" does not exist.", themeName
)
)
);
return provider
.getThemeFileInfo(themeName, ThemeVersion.DRAFT, path)
.orElseThrow(
() -> new NotFoundException(
String.format(
"File \"%s\" does not exist in theme %s.",
path,
themeName
)
)
);
}
/** /**
* Creates or updates a file in a theme. * Creates or updates a file in a theme.
* *