本文整理了Java中com.xpn.xwiki.plugin.zipexplorer.ZipExplorerPlugin
类的一些代码示例,展示了ZipExplorerPlugin
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipExplorerPlugin
类的具体详情如下:
包路径:com.xpn.xwiki.plugin.zipexplorer.ZipExplorerPlugin
类名称:ZipExplorerPlugin
[英]See com.xpn.xwiki.plugin.zipexplorer.ZipExplorerPluginAPI for documentation.
[中]请看com。xpn。xwiki。插件。zipexplorer。ZipExplorerPluginAPI的文档。
代码示例来源:origin: org.xwiki.platform/xwiki-platform-zipexplorer
/**
* @param url the ZIP URL to check
* @param action the XWiki requested action (for example "download", "edit", "view", etc).
* @return true if the ZIP URL points to a file inside the ZIP or false otherwise
*/
protected boolean isValidZipURL(String url, String action)
{
boolean isValidZipURL = false;
try {
// TODO: There shouldn't be the need to do a trim() on an Action. Actually actions
// should be enumerated types. See https://jira.xwiki.org/browse/XWIKI-436
String filenameInZip = getFileLocationFromZipURL(url, action);
// TODO: Ideally we should also check to see if the URL points to a file and not to
// a directory.
if (filenameInZip.length() > 0) {
isValidZipURL = true;
}
} catch (Exception e) {
// TODO: This exception block should be removed and possible errors should be
// handled in getFileLocationFromZipURL.
}
return isValidZipURL;
}
}
代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core
/**
* @param name the plugin name
* @param className the plugin classname (used in logs for example)
* @param context the XWiki Context
*
* @see XWikiDefaultPlugin#XWikiDefaultPlugin(String,String,com.xpn.xwiki.XWikiContext)
*/
public ZipExplorerPlugin(String name, String className, XWikiContext context)
{
super(name, className, context);
init(context);
}
代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core
if (!isValidZipURL(url, context.getAction().trim())) {
return attachment;
String filename = getFileLocationFromZipURL(url, context.getAction().trim());
if (!isZipFile(attachment.getContentInputStream(context))) {
return attachment;
代码示例来源:origin: org.xwiki.platform/xwiki-platform-zipexplorer
/**
* @param document the document containing the ZIP file as an attachment
* @param attachmentName the name under which the ZIP file is attached in the document
* @return the list of file entries in the ZIP file attached under the passed attachment name inside the passed
* document
*/
public List<String> getFileList(Document document, String attachmentName)
{
return getProtectedPlugin().getFileList(document, attachmentName, getXWikiContext());
}
代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core
/**
* @param document the document containing the ZIP file as an attachment
* @param attachmentName the name under which the ZIP file is attached in the document
* @param fileName the filename to concatenate at the end of the attachment URL
* @return the attachment URL of the passed attachment located in the passed document to which the passed filename
* has been suffixed.
*/
public String getFileLink(Document document, String attachmentName, String fileName)
{
return getProtectedPlugin().getFileLink(document, attachmentName, fileName, getXWikiContext());
}
}
代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core
/**
* For ZIP URLs of the format <code>http://[...]/zipfile.zip/SomeDirectory/SomeFile.txt</code> return a new
* attachment containing the file pointed to inside the ZIP. If the original attachment does not point to a ZIP file
* or if it doesn't specify a location inside the ZIP then do nothing and return the original attachment.
*
* @param attachment the original attachment
* @return a new attachment pointing to the file pointed to by the URL inside the ZIP or the original attachment if
* the requested URL doesn't specify a file inside a ZIP
* @see com.xpn.xwiki.plugin.XWikiDefaultPlugin#downloadAttachment
*/
public XWikiAttachment downloadAttachment(XWikiAttachment attachment)
{
return getProtectedPlugin().downloadAttachment(attachment, getXWikiContext());
}
代码示例来源:origin: org.xwiki.platform/xwiki-platform-zipexplorer
/**
* Finds the ZIP attachment with passed name from the passed document matching and parse the ZIP to generate a list
* of {@link com.xpn.xwiki.objects.classes.ListItem} elements representing a tree view of all directories and files
* in the ZIP. For example the following zip:
*
* <pre>
* zipfile.zip:
* Directory/File.txt
* File2.txt
* </pre>
*
* generates the following ListItem list:
*
* <pre>
*
* { id = "Directory/", value = "Directory", parent = ""}
* { id = "Directory/File.txt", value = "File.txt", parent = "Directory/"}
* { id = "File2.txt", value = "File2.txt", parent = ""}
*
* </pre>
*
* @param document the document containing the ZIP file as an attachment
* @param attachmentName the name under which the ZIP file is attached in the document
* @return a tree view list of {@link com.xpn.xwiki.objects.classes.ListItem} elements representing the content of
* the ZIP file
*/
public List<ListItem> getFileTreeList(Document document, String attachmentName)
{
return getProtectedPlugin().getFileTreeList(document, attachmentName, getXWikiContext());
}
代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core
/**
* @param document the document containing the ZIP file as an attachment
* @param attachmentName the name under which the ZIP file is attached in the document
* @param context not used
* @return the list of file entries in the ZIP file attached under the passed attachment name inside the passed
* document
* @see com.xpn.xwiki.plugin.zipexplorer.ZipExplorerPluginAPI#getFileList
*/
public List<String> getFileList(Document document, String attachmentName, XWikiContext context)
{
List<String> zipList = new ArrayList<String>();
Attachment attachment = document.getAttachment(attachmentName);
try {
byte[] stream = attachment.getContent();
ByteArrayInputStream bais = new ByteArrayInputStream(stream);
if (isZipFile(bais)) {
ZipInputStream zis = new ZipInputStream(bais);
ZipEntry entry;
while ((entry = zis.getNextEntry()) != null) {
zipList.add(entry.getName());
}
}
} catch (XWikiException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return zipList;
}
代码示例来源:origin: org.xwiki.platform/xwiki-platform-zipexplorer
|| !isValidZipURL(url, context.getAction().trim()))
String filename = getFileLocationFromZipURL(url, context.getAction().trim());
stream = new BufferedInputStream(attachment.getContentInputStream(context));
if (!isZipFile(stream)) {
return attachment;
代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core
/**
* @param document the document containing the ZIP file as an attachment
* @param attachmentName the name under which the ZIP file is attached in the document
* @return the list of file entries in the ZIP file attached under the passed attachment name inside the passed
* document
*/
public List<String> getFileList(Document document, String attachmentName)
{
return getProtectedPlugin().getFileList(document, attachmentName, getXWikiContext());
}
代码示例来源:origin: org.xwiki.platform/xwiki-platform-zipexplorer
/**
* @param document the document containing the ZIP file as an attachment
* @param attachmentName the name under which the ZIP file is attached in the document
* @param fileName the filename to concatenate at the end of the attachment URL
* @return the attachment URL of the passed attachment located in the passed document to which the passed filename
* has been suffixed.
*/
public String getFileLink(Document document, String attachmentName, String fileName)
{
return getProtectedPlugin().getFileLink(document, attachmentName, fileName, getXWikiContext());
}
}
代码示例来源:origin: org.xwiki.platform/xwiki-platform-zipexplorer
/**
* For ZIP URLs of the format <code>http://[...]/zipfile.zip/SomeDirectory/SomeFile.txt</code> return a new
* attachment containing the file pointed to inside the ZIP. If the original attachment does not point to a ZIP file
* or if it doesn't specify a location inside the ZIP then do nothing and return the original attachment.
*
* @param attachment the original attachment
* @return a new attachment pointing to the file pointed to by the URL inside the ZIP or the original attachment if
* the requested URL doesn't specify a file inside a ZIP
* @see com.xpn.xwiki.plugin.XWikiDefaultPlugin#downloadAttachment
*/
public XWikiAttachment downloadAttachment(XWikiAttachment attachment)
{
return getProtectedPlugin().downloadAttachment(attachment, getXWikiContext());
}
代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core
/**
* Finds the ZIP attachment with passed name from the passed document matching and parse the ZIP to generate a list
* of {@link com.xpn.xwiki.objects.classes.ListItem} elements representing a tree view of all directories and files
* in the ZIP. For example the following zip:
*
* <pre>
* zipfile.zip:
* Directory/File.txt
* File2.txt
* </pre>
*
* generates the following ListItem list:
*
* <pre>
*
* { id = "Directory/", value = "Directory", parent = ""}
* { id = "Directory/File.txt", value = "File.txt", parent = "Directory/"}
* { id = "File2.txt", value = "File2.txt", parent = ""}
*
* </pre>
*
* @param document the document containing the ZIP file as an attachment
* @param attachmentName the name under which the ZIP file is attached in the document
* @return a tree view list of {@link com.xpn.xwiki.objects.classes.ListItem} elements representing the content of
* the ZIP file
*/
public List<ListItem> getFileTreeList(Document document, String attachmentName)
{
return getProtectedPlugin().getFileTreeList(document, attachmentName, getXWikiContext());
}
代码示例来源:origin: org.xwiki.platform/xwiki-platform-zipexplorer
/**
* @param document the document containing the ZIP file as an attachment
* @param attachmentName the name under which the ZIP file is attached in the document
* @param context not used
* @return the list of file entries in the ZIP file attached under the passed attachment name inside the passed
* document
* @see com.xpn.xwiki.plugin.zipexplorer.ZipExplorerPluginAPI#getFileList
*/
public List<String> getFileList(Document document, String attachmentName, XWikiContext context)
{
List<String> zipList = new ArrayList<String>();
Attachment attachment = document.getAttachment(attachmentName);
InputStream stream = null;
try {
stream = new ByteArrayInputStream(attachment.getContent());
if (isZipFile(stream)) {
ZipInputStream zis = new ZipInputStream(stream);
ZipEntry entry;
while ((entry = zis.getNextEntry()) != null) {
zipList.add(entry.getName());
}
}
} catch (XWikiException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return zipList;
}
代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core
List<String> flatList = getFileList(document, attachmentName, context);
Map<String, ListItem> fileTree = new HashMap<String, ListItem>();
List<ListItem> res = new ArrayList<ListItem>();
代码示例来源:origin: org.xwiki.platform/xwiki-platform-zipexplorer
/**
* @param name the plugin name
* @param className the plugin classname (used in logs for example)
* @param context the XWiki Context
*
* @see XWikiDefaultPlugin#XWikiDefaultPlugin(String,String,com.xpn.xwiki.XWikiContext)
*/
public ZipExplorerPlugin(String name, String className, XWikiContext context)
{
super(name, className, context);
init(context);
}
代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core
/**
* @param url the ZIP URL to check
* @param action the XWiki requested action (for example "download", "edit", "view", etc).
* @return true if the ZIP URL points to a file inside the ZIP or false otherwise
*/
protected boolean isValidZipURL(String url, String action)
{
boolean isValidZipURL = false;
try {
// TODO: There shouldn't be the need to do a trim() on an Action. Actually actions
// should be enumerated types. See http://jira.xwiki.org/jira/browse/XWIKI-436
String filenameInZip = getFileLocationFromZipURL(url, action);
// TODO: Ideally we should also check to see if the URL points to a file and not to
// a directory.
if (filenameInZip.length() > 0) {
isValidZipURL = true;
}
} catch (Exception e) {
// TODO: This exception block should be removed and possible errors should be
// handled in getFileLocationFromZipURL.
}
return isValidZipURL;
}
}
代码示例来源:origin: org.xwiki.platform/xwiki-platform-zipexplorer
List<String> flatList = getFileList(document, attachmentName, context);
Map<String, ListItem> fileTree = new HashMap<String, ListItem>();
List<ListItem> res = new ArrayList<ListItem>();
内容来源于网络,如有侵权,请联系作者删除!