本文整理汇总了Java中org.guvnor.common.services.shared.file.upload.FileManagerFields类的典型用法代码示例。如果您正苦于以下问题:Java FileManagerFields类的具体用法?Java FileManagerFields怎么用?Java FileManagerFields使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FileManagerFields类属于org.guvnor.common.services.shared.file.upload包,在下文中一共展示了FileManagerFields类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doGet
import org.guvnor.common.services.shared.file.upload.FileManagerFields; //导入依赖的package包/类
/**
* doGet acting like a dispatcher.
*/
protected void doGet(final HttpServletRequest request,
final HttpServletResponse response) throws ServletException, IOException {
final String path = request.getParameter(FileManagerFields.FORM_FIELD_PATH);
if (path != null) {
processAttachmentDownload(path,
request,
response);
} else {
response.sendError(HttpServletResponse.SC_BAD_REQUEST);
}
}
示例2: createUploadWidget
import org.guvnor.common.services.shared.file.upload.FileManagerFields; //导入依赖的package包/类
FileUpload createUploadWidget(boolean addFileUpload) {
FileUpload up = new FileUpload(new org.uberfire.mvp.Command() {
@Override
public void execute() {
uploadButtonClickHanlder.onClick(null);
}
},
addFileUpload);
up.setName(FileManagerFields.UPLOAD_FIELD_NAME_ATTACH);
return up;
}
示例3: doGet
import org.guvnor.common.services.shared.file.upload.FileManagerFields; //导入依赖的package包/类
protected void doGet(final HttpServletRequest request,
final HttpServletResponse response) throws ServletException, IOException {
final String uri = request.getParameter(FileManagerFields.FORM_FIELD_PATH);
try {
if (uri != null) {
if (!validateAccess(new URI(uri),
response)) {
return;
}
// Try to extract a meaningful name for the zip-file from the URI.
int index = uri.lastIndexOf("@") + 1;
if (index < 0) {
index = 0;
}
String downLoadFileName = uri.substring(index);
if (downLoadFileName.startsWith("/")) {
downLoadFileName = downLoadFileName.substring(1);
}
if (downLoadFileName.endsWith("/")) {
downLoadFileName = downLoadFileName.substring(0,
downLoadFileName.length() - 1);
}
downLoadFileName = downLoadFileName.replaceAll("/",
"_");
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
archiver.archive(outputStream,
uri);
response.setContentType("application/zip");
response.setHeader("Content-Disposition",
"attachment; filename=" + downLoadFileName + ".zip");
response.setContentLength(outputStream.size());
response.getOutputStream().write(outputStream.toByteArray());
response.getOutputStream().flush();
} else {
response.sendError(HttpServletResponse.SC_BAD_REQUEST);
}
} catch (URISyntaxException e) {
response.sendError(HttpServletResponse.SC_BAD_REQUEST);
}
}
示例4: getFormData
import org.guvnor.common.services.shared.file.upload.FileManagerFields; //导入依赖的package包/类
/**
* Get the form data from the inbound request.
*/
@SuppressWarnings("rawtypes")
private FormData getFormData(final HttpServletRequest request) throws IOException {
final FileItemFactory factory = new DiskFileItemFactory();
final ServletFileUpload upload = new ServletFileUpload(factory);
upload.setHeaderEncoding("UTF-8");
//See https://code.google.com/p/google-web-toolkit/issues/detail?id=4682
request.setCharacterEncoding("UTF-8");
final FormData data = new FormData();
try {
final List items = upload.parseRequest(request);
final Iterator it = items.iterator();
FileOperation operation = null;
String fileName = null;
String contextPath = null;
String fullPath = null;
while (it.hasNext()) {
final FileItem item = (FileItem) it.next();
if (!item.isFormField()) {
data.setFile(item);
} else if (item.getFieldName().equals(FileManagerFields.FORM_FIELD_PATH)) {
contextPath = item.getString("UTF-8");
log.debug("path:" + contextPath);
} else if (item.getFieldName().equals(FileManagerFields.FORM_FIELD_NAME)) {
fileName = item.getString("UTF-8");
log.debug("name:" + fileName);
} else if (item.getFieldName().equals(FileManagerFields.FORM_FIELD_FULL_PATH)) {
fullPath = item.getString("UTF-8");
log.debug("full path:" + fullPath);
} else if (item.getFieldName().equals(FileManagerFields.FORM_FIELD_OPERATION)) {
operation = FileOperation.valueOf(item.getString("UTF-8"));
log.debug("operation:" + operation);
}
}
if (operation == null) {
throw new IllegalArgumentException("FORM_FIELD_OPERATION is null. Cannot process upload.");
}
org.uberfire.java.nio.file.Path path;
switch (operation) {
case CREATE:
if (fileName == null) {
throw new IllegalArgumentException("FORM_FIELD_NAME is null. Cannot process upload.");
}
if (contextPath == null) {
throw new IllegalArgumentException("FORM_FIELD_PATH is null. Cannot process upload.");
}
data.setOperation(operation);
data.setTargetPath(convertPath(fileName,
contextPath));
break;
case UPDATE:
if (fullPath == null) {
throw new IllegalArgumentException("FORM_FIELD_FULL_PATH is null. Cannot process upload.");
}
data.setOperation(operation);
data.setTargetPath(convertPath(fullPath));
}
return data;
} catch (Exception e) {
throw new org.uberfire.java.nio.IOException(e.getMessage());
}
}
示例5: getDownloadUrl
import org.guvnor.common.services.shared.file.upload.FileManagerFields; //导入依赖的package包/类
public static String getDownloadUrl( final Path path,
final String clientId ) {
return URLHelper.getServletUrl( clientId ) + "&" + FileManagerFields.FORM_FIELD_PATH + "=" + URL.encode( path.toURI() );
}
示例6: getDownloadUrl
import org.guvnor.common.services.shared.file.upload.FileManagerFields; //导入依赖的package包/类
public static String getDownloadUrl( final Path path ) {
final StringBuilder sb = new StringBuilder( URLHelper.getServletUrl() );
sb.append( "?" ).append( FileManagerFields.FORM_FIELD_PATH ).append( "=" ).append( URL.encode(path.toURI()) );
return sb.toString();
}