Package com.xpn.xwiki.web
Class SkinAction
- java.lang.Object
-
- com.xpn.xwiki.web.XWikiAction
-
- com.xpn.xwiki.web.SkinAction
-
- All Implemented Interfaces:
com.xpn.xwiki.internal.web.LegacyAction
@Component @Named("skin") @Singleton public class SkinAction extends XWikiAction
Action for serving skin files. It allows skins to be defined using XDocuments as skins, by letting files be placed as text fields in an XWiki.XWikiSkins object, or as attachments to the document, or as a file in the filesystem. If the file is not found in the current skin, then it is searched in its base skin, and eventually in the default base skins,
This action indicates that the results should be publicly cacheable for 30 days.
- Since:
- 1.0
- Version:
- $Id: dd694284bd294a59f4ff3e4da72473840cb7ccf5 $
-
-
Field Summary
-
Fields inherited from class com.xpn.xwiki.web.XWikiAction
ACTION_PROGRESS, componentDescriptor, container, execution, observation, waitForXWikiInitialization
-
-
Constructor Summary
Constructors Constructor Description SkinAction()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
action(XWikiContext context)
String
getResourceFilePath(String filename)
Get the path for the given file in resources.String
getSkinFilePath(String filename, String skin)
Get the path for the given skin file in the given skin.boolean
isCssMimeType(String mimetype)
Checks if a mimetype indicates a CSS file.boolean
isJavascriptMimeType(String mimetype)
Checks if a mimetype indicates a javascript file.String
render(XWikiContext context)
String
render(String path, XWikiContext context)
boolean
renderFileFromAttachment(String filename, XWikiDocument doc, XWikiContext context)
Tries to serve the content of an attachment as a skin file.boolean
renderFileFromObjectField(String filename, XWikiDocument doc, XWikiContext context)
Tries to serve the content of an XWikiSkins object field as a skin file.protected void
setupHeaders(XWikiResponse response, String mimetype, Date lastChanged, int length)
Deprecated.since 11.10RC1, usesetupHeaders(XWikiResponse, String, Date, long)
insteadprotected void
setupHeaders(XWikiResponse response, String mimetype, Date lastChanged, long length)
Sets several headers to properly identify the response.-
Methods inherited from class com.xpn.xwiki.web.XWikiAction
answerJSON, cleanupComponents, csrfTokenCheck, csrfTokenCheck, execute, execute, getContextualAuthorizationManager, getCurrentMixedDocumentReferenceResolver, getCurrentScriptContext, getEntityNameValidationConfiguration, getEntityNameValidationManager, getFormClass, getLocalization, getLocalSerializer, getName, getProgress, getRealPath, getTranslatedDocument, handleRevision, initializeContainerComponent, initializeXWikiContext, initializeXWikiContext, isEntityReferenceNameValid, localizePlainOrKey, readFromTemplate, resolveTemplate, sendGlobalRedirect, sendRedirect, setContentLength, supportRedirections, writeAjaxErrorResponse
-
-
-
-
Method Detail
-
action
public boolean action(XWikiContext context) throws XWikiException
- Overrides:
action
in classXWikiAction
- Throws:
XWikiException
-
render
public String render(XWikiContext context) throws XWikiException
- Overrides:
render
in classXWikiAction
- Throws:
XWikiException
-
render
public String render(String path, XWikiContext context) throws XWikiException, IOException
- Throws:
XWikiException
IOException
-
getSkinFilePath
public String getSkinFilePath(String filename, String skin) throws IOException
Get the path for the given skin file in the given skin.- Parameters:
filename
- Name of the file.skin
- Name of the skin to search in.- Throws:
IOException
- if filename is invalid
-
getResourceFilePath
public String getResourceFilePath(String filename) throws IOException
Get the path for the given file in resources.- Parameters:
filename
- Name of the file.- Throws:
IOException
- if filename is invalid
-
renderFileFromObjectField
public boolean renderFileFromObjectField(String filename, XWikiDocument doc, XWikiContext context) throws IOException
Tries to serve the content of an XWikiSkins object field as a skin file.- Parameters:
filename
- The name of the skin file that should be rendered.doc
- The skindocument
.context
- The currentrequest context
.- Returns:
true
if the object exists, and the field is set to a non-empty value, and its content was successfully sent.- Throws:
IOException
- If the response cannot be sent.
-
renderFileFromAttachment
public boolean renderFileFromAttachment(String filename, XWikiDocument doc, XWikiContext context) throws IOException, XWikiException
Tries to serve the content of an attachment as a skin file.- Parameters:
filename
- The name of the skin file that should be rendered.doc
- The skindocument
.context
- The currentrequest context
.- Returns:
true
if the attachment was found and its content was successfully sent.- Throws:
IOException
- If the response cannot be sent.XWikiException
- If the attachment cannot be loaded.
-
isJavascriptMimeType
public boolean isJavascriptMimeType(String mimetype)
Checks if a mimetype indicates a javascript file.- Parameters:
mimetype
- The mime type to check.- Returns:
true
if the mime type represents a javascript file.
-
isCssMimeType
public boolean isCssMimeType(String mimetype)
Checks if a mimetype indicates a CSS file.- Parameters:
mimetype
- The mime type to check.- Returns:
true
if the mime type represents a css file.
-
setupHeaders
@Deprecated protected void setupHeaders(XWikiResponse response, String mimetype, Date lastChanged, int length)
Deprecated.since 11.10RC1, usesetupHeaders(XWikiResponse, String, Date, long)
insteadSets several headers to properly identify the response.- Parameters:
response
- The servlet response object, where the headers should be set.mimetype
- The mimetype of the file. Used in the "Content-Type" header.lastChanged
- The date of the last change of the file. Used in the "Last-Modified" header.length
- The length of the content (in bytes). Used in the "Content-Length" header.
-
setupHeaders
protected void setupHeaders(XWikiResponse response, String mimetype, Date lastChanged, long length)
Sets several headers to properly identify the response.- Parameters:
response
- The servlet response object, where the headers should be set.mimetype
- The mimetype of the file. Used in the "Content-Type" header.lastChanged
- The date of the last change of the file. Used in the "Last-Modified" header.length
- The length of the content (in bytes). Used in the "Content-Length" header.- Since:
- 11.10, 11.3.6, 10.11.10
-
-