com.xpn.xwiki.plugin.zipexplorer.ZipExplorerPlugin类的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(11.4k)|赞(0)|评价(0)|浏览(81)

本文整理了Java中com.xpn.xwiki.plugin.zipexplorer.ZipExplorerPlugin类的一些代码示例,展示了ZipExplorerPlugin类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipExplorerPlugin类的具体详情如下:
包路径:com.xpn.xwiki.plugin.zipexplorer.ZipExplorerPlugin
类名称:ZipExplorerPlugin

ZipExplorerPlugin介绍

[英]See com.xpn.xwiki.plugin.zipexplorer.ZipExplorerPluginAPI for documentation.
[中]请看com。xpn。xwiki。插件。zipexplorer。ZipExplorerPluginAPI的文档。

代码示例

代码示例来源:origin: org.xwiki.platform/xwiki-platform-zipexplorer

  1. /**
  2. * @param url the ZIP URL to check
  3. * @param action the XWiki requested action (for example "download", "edit", "view", etc).
  4. * @return true if the ZIP URL points to a file inside the ZIP or false otherwise
  5. */
  6. protected boolean isValidZipURL(String url, String action)
  7. {
  8. boolean isValidZipURL = false;
  9. try {
  10. // TODO: There shouldn't be the need to do a trim() on an Action. Actually actions
  11. // should be enumerated types. See https://jira.xwiki.org/browse/XWIKI-436
  12. String filenameInZip = getFileLocationFromZipURL(url, action);
  13. // TODO: Ideally we should also check to see if the URL points to a file and not to
  14. // a directory.
  15. if (filenameInZip.length() > 0) {
  16. isValidZipURL = true;
  17. }
  18. } catch (Exception e) {
  19. // TODO: This exception block should be removed and possible errors should be
  20. // handled in getFileLocationFromZipURL.
  21. }
  22. return isValidZipURL;
  23. }
  24. }

代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core

  1. /**
  2. * @param name the plugin name
  3. * @param className the plugin classname (used in logs for example)
  4. * @param context the XWiki Context
  5. *
  6. * @see XWikiDefaultPlugin#XWikiDefaultPlugin(String,String,com.xpn.xwiki.XWikiContext)
  7. */
  8. public ZipExplorerPlugin(String name, String className, XWikiContext context)
  9. {
  10. super(name, className, context);
  11. init(context);
  12. }

代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core

  1. if (!isValidZipURL(url, context.getAction().trim())) {
  2. return attachment;
  3. String filename = getFileLocationFromZipURL(url, context.getAction().trim());
  4. if (!isZipFile(attachment.getContentInputStream(context))) {
  5. return attachment;

代码示例来源:origin: org.xwiki.platform/xwiki-platform-zipexplorer

  1. /**
  2. * @param document the document containing the ZIP file as an attachment
  3. * @param attachmentName the name under which the ZIP file is attached in the document
  4. * @return the list of file entries in the ZIP file attached under the passed attachment name inside the passed
  5. * document
  6. */
  7. public List<String> getFileList(Document document, String attachmentName)
  8. {
  9. return getProtectedPlugin().getFileList(document, attachmentName, getXWikiContext());
  10. }

代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core

  1. /**
  2. * @param document the document containing the ZIP file as an attachment
  3. * @param attachmentName the name under which the ZIP file is attached in the document
  4. * @param fileName the filename to concatenate at the end of the attachment URL
  5. * @return the attachment URL of the passed attachment located in the passed document to which the passed filename
  6. * has been suffixed.
  7. */
  8. public String getFileLink(Document document, String attachmentName, String fileName)
  9. {
  10. return getProtectedPlugin().getFileLink(document, attachmentName, fileName, getXWikiContext());
  11. }
  12. }

代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core

  1. /**
  2. * For ZIP URLs of the format <code>http://[...]/zipfile.zip/SomeDirectory/SomeFile.txt</code> return a new
  3. * attachment containing the file pointed to inside the ZIP. If the original attachment does not point to a ZIP file
  4. * or if it doesn't specify a location inside the ZIP then do nothing and return the original attachment.
  5. *
  6. * @param attachment the original attachment
  7. * @return a new attachment pointing to the file pointed to by the URL inside the ZIP or the original attachment if
  8. * the requested URL doesn't specify a file inside a ZIP
  9. * @see com.xpn.xwiki.plugin.XWikiDefaultPlugin#downloadAttachment
  10. */
  11. public XWikiAttachment downloadAttachment(XWikiAttachment attachment)
  12. {
  13. return getProtectedPlugin().downloadAttachment(attachment, getXWikiContext());
  14. }

代码示例来源:origin: org.xwiki.platform/xwiki-platform-zipexplorer

  1. /**
  2. * Finds the ZIP attachment with passed name from the passed document matching and parse the ZIP to generate a list
  3. * of {@link com.xpn.xwiki.objects.classes.ListItem} elements representing a tree view of all directories and files
  4. * in the ZIP. For example the following zip:
  5. *
  6. * <pre>
  7. * zipfile.zip:
  8. * Directory/File.txt
  9. * File2.txt
  10. * </pre>
  11. *
  12. * generates the following ListItem list:
  13. *
  14. * <pre>
  15. *
  16. * { id = &quot;Directory/&quot;, value = &quot;Directory&quot;, parent = &quot;&quot;}
  17. * { id = &quot;Directory/File.txt&quot;, value = &quot;File.txt&quot;, parent = &quot;Directory/&quot;}
  18. * { id = &quot;File2.txt&quot;, value = &quot;File2.txt&quot;, parent = &quot;&quot;}
  19. *
  20. * </pre>
  21. *
  22. * @param document the document containing the ZIP file as an attachment
  23. * @param attachmentName the name under which the ZIP file is attached in the document
  24. * @return a tree view list of {@link com.xpn.xwiki.objects.classes.ListItem} elements representing the content of
  25. * the ZIP file
  26. */
  27. public List<ListItem> getFileTreeList(Document document, String attachmentName)
  28. {
  29. return getProtectedPlugin().getFileTreeList(document, attachmentName, getXWikiContext());
  30. }

代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core

  1. /**
  2. * @param document the document containing the ZIP file as an attachment
  3. * @param attachmentName the name under which the ZIP file is attached in the document
  4. * @param context not used
  5. * @return the list of file entries in the ZIP file attached under the passed attachment name inside the passed
  6. * document
  7. * @see com.xpn.xwiki.plugin.zipexplorer.ZipExplorerPluginAPI#getFileList
  8. */
  9. public List<String> getFileList(Document document, String attachmentName, XWikiContext context)
  10. {
  11. List<String> zipList = new ArrayList<String>();
  12. Attachment attachment = document.getAttachment(attachmentName);
  13. try {
  14. byte[] stream = attachment.getContent();
  15. ByteArrayInputStream bais = new ByteArrayInputStream(stream);
  16. if (isZipFile(bais)) {
  17. ZipInputStream zis = new ZipInputStream(bais);
  18. ZipEntry entry;
  19. while ((entry = zis.getNextEntry()) != null) {
  20. zipList.add(entry.getName());
  21. }
  22. }
  23. } catch (XWikiException e) {
  24. e.printStackTrace();
  25. } catch (IOException e) {
  26. e.printStackTrace();
  27. }
  28. return zipList;
  29. }

代码示例来源:origin: org.xwiki.platform/xwiki-platform-zipexplorer

  1. || !isValidZipURL(url, context.getAction().trim()))
  2. String filename = getFileLocationFromZipURL(url, context.getAction().trim());
  3. stream = new BufferedInputStream(attachment.getContentInputStream(context));
  4. if (!isZipFile(stream)) {
  5. return attachment;

代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core

  1. /**
  2. * @param document the document containing the ZIP file as an attachment
  3. * @param attachmentName the name under which the ZIP file is attached in the document
  4. * @return the list of file entries in the ZIP file attached under the passed attachment name inside the passed
  5. * document
  6. */
  7. public List<String> getFileList(Document document, String attachmentName)
  8. {
  9. return getProtectedPlugin().getFileList(document, attachmentName, getXWikiContext());
  10. }

代码示例来源:origin: org.xwiki.platform/xwiki-platform-zipexplorer

  1. /**
  2. * @param document the document containing the ZIP file as an attachment
  3. * @param attachmentName the name under which the ZIP file is attached in the document
  4. * @param fileName the filename to concatenate at the end of the attachment URL
  5. * @return the attachment URL of the passed attachment located in the passed document to which the passed filename
  6. * has been suffixed.
  7. */
  8. public String getFileLink(Document document, String attachmentName, String fileName)
  9. {
  10. return getProtectedPlugin().getFileLink(document, attachmentName, fileName, getXWikiContext());
  11. }
  12. }

代码示例来源:origin: org.xwiki.platform/xwiki-platform-zipexplorer

  1. /**
  2. * For ZIP URLs of the format <code>http://[...]/zipfile.zip/SomeDirectory/SomeFile.txt</code> return a new
  3. * attachment containing the file pointed to inside the ZIP. If the original attachment does not point to a ZIP file
  4. * or if it doesn't specify a location inside the ZIP then do nothing and return the original attachment.
  5. *
  6. * @param attachment the original attachment
  7. * @return a new attachment pointing to the file pointed to by the URL inside the ZIP or the original attachment if
  8. * the requested URL doesn't specify a file inside a ZIP
  9. * @see com.xpn.xwiki.plugin.XWikiDefaultPlugin#downloadAttachment
  10. */
  11. public XWikiAttachment downloadAttachment(XWikiAttachment attachment)
  12. {
  13. return getProtectedPlugin().downloadAttachment(attachment, getXWikiContext());
  14. }

代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core

  1. /**
  2. * Finds the ZIP attachment with passed name from the passed document matching and parse the ZIP to generate a list
  3. * of {@link com.xpn.xwiki.objects.classes.ListItem} elements representing a tree view of all directories and files
  4. * in the ZIP. For example the following zip:
  5. *
  6. * <pre>
  7. * zipfile.zip:
  8. * Directory/File.txt
  9. * File2.txt
  10. * </pre>
  11. *
  12. * generates the following ListItem list:
  13. *
  14. * <pre>
  15. *
  16. * { id = &quot;Directory/&quot;, value = &quot;Directory&quot;, parent = &quot;&quot;}
  17. * { id = &quot;Directory/File.txt&quot;, value = &quot;File.txt&quot;, parent = &quot;Directory/&quot;}
  18. * { id = &quot;File2.txt&quot;, value = &quot;File2.txt&quot;, parent = &quot;&quot;}
  19. *
  20. * </pre>
  21. *
  22. * @param document the document containing the ZIP file as an attachment
  23. * @param attachmentName the name under which the ZIP file is attached in the document
  24. * @return a tree view list of {@link com.xpn.xwiki.objects.classes.ListItem} elements representing the content of
  25. * the ZIP file
  26. */
  27. public List<ListItem> getFileTreeList(Document document, String attachmentName)
  28. {
  29. return getProtectedPlugin().getFileTreeList(document, attachmentName, getXWikiContext());
  30. }

代码示例来源:origin: org.xwiki.platform/xwiki-platform-zipexplorer

  1. /**
  2. * @param document the document containing the ZIP file as an attachment
  3. * @param attachmentName the name under which the ZIP file is attached in the document
  4. * @param context not used
  5. * @return the list of file entries in the ZIP file attached under the passed attachment name inside the passed
  6. * document
  7. * @see com.xpn.xwiki.plugin.zipexplorer.ZipExplorerPluginAPI#getFileList
  8. */
  9. public List<String> getFileList(Document document, String attachmentName, XWikiContext context)
  10. {
  11. List<String> zipList = new ArrayList<String>();
  12. Attachment attachment = document.getAttachment(attachmentName);
  13. InputStream stream = null;
  14. try {
  15. stream = new ByteArrayInputStream(attachment.getContent());
  16. if (isZipFile(stream)) {
  17. ZipInputStream zis = new ZipInputStream(stream);
  18. ZipEntry entry;
  19. while ((entry = zis.getNextEntry()) != null) {
  20. zipList.add(entry.getName());
  21. }
  22. }
  23. } catch (XWikiException e) {
  24. e.printStackTrace();
  25. } catch (IOException e) {
  26. e.printStackTrace();
  27. }
  28. return zipList;
  29. }

代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core

  1. List<String> flatList = getFileList(document, attachmentName, context);
  2. Map<String, ListItem> fileTree = new HashMap<String, ListItem>();
  3. List<ListItem> res = new ArrayList<ListItem>();

代码示例来源:origin: org.xwiki.platform/xwiki-platform-zipexplorer

  1. /**
  2. * @param name the plugin name
  3. * @param className the plugin classname (used in logs for example)
  4. * @param context the XWiki Context
  5. *
  6. * @see XWikiDefaultPlugin#XWikiDefaultPlugin(String,String,com.xpn.xwiki.XWikiContext)
  7. */
  8. public ZipExplorerPlugin(String name, String className, XWikiContext context)
  9. {
  10. super(name, className, context);
  11. init(context);
  12. }

代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core

  1. /**
  2. * @param url the ZIP URL to check
  3. * @param action the XWiki requested action (for example "download", "edit", "view", etc).
  4. * @return true if the ZIP URL points to a file inside the ZIP or false otherwise
  5. */
  6. protected boolean isValidZipURL(String url, String action)
  7. {
  8. boolean isValidZipURL = false;
  9. try {
  10. // TODO: There shouldn't be the need to do a trim() on an Action. Actually actions
  11. // should be enumerated types. See http://jira.xwiki.org/jira/browse/XWIKI-436
  12. String filenameInZip = getFileLocationFromZipURL(url, action);
  13. // TODO: Ideally we should also check to see if the URL points to a file and not to
  14. // a directory.
  15. if (filenameInZip.length() > 0) {
  16. isValidZipURL = true;
  17. }
  18. } catch (Exception e) {
  19. // TODO: This exception block should be removed and possible errors should be
  20. // handled in getFileLocationFromZipURL.
  21. }
  22. return isValidZipURL;
  23. }
  24. }

代码示例来源:origin: org.xwiki.platform/xwiki-platform-zipexplorer

  1. List<String> flatList = getFileList(document, attachmentName, context);
  2. Map<String, ListItem> fileTree = new HashMap<String, ListItem>();
  3. List<ListItem> res = new ArrayList<ListItem>();

相关文章