本文整理汇总了Java中net.sourceforge.stripes.action.StreamingResolution类的典型用法代码示例。如果您正苦于以下问题:Java StreamingResolution类的具体用法?Java StreamingResolution怎么用?Java StreamingResolution使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StreamingResolution类属于net.sourceforge.stripes.action包,在下文中一共展示了StreamingResolution类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: uploadFile
import net.sourceforge.stripes.action.StreamingResolution; //导入依赖的package包/类
@POST
@HandlesEvent("upload")
public Resolution uploadFile() {
String errorMsg = null;
if (upload != null) {
try {
mediaAsset = mediaAssetService.create(upload.getInputStream(), upload.getFileName());
mediaAsset.setGroup(GROUP_CMS);
mediaAssetService.update(mediaAsset);
filename = mediaAsset.getName().getStr();
} catch (IOException e) {
errorMsg = e.getMessage();
return new StreamingResolution("text/xml", errorMsg);
}
return view("ckeditor/file_select");
}
return new StreamingResolution("text/xml", "An unknown error has occurred!");
}
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:22,代码来源:FileManagerCKEditorAction.java
示例2: get
import net.sourceforge.stripes.action.StreamingResolution; //导入依赖的package包/类
@Request("/get/{id}")
public Result get(@PathParam("id") Id id) {
MediaAsset mediaAsset = mediaAssetService.get(id);
MediaAssetFile file = mediaAsset.getFile();
StreamingResolution streamingResolution = new StreamingResolution(file.getMimeType(), file.getContent());
streamingResolution.setFilename(file.getName());
Result viewStr = Results.stream(file.getMimeType(), file.getContent());
if (!file.getMimeType().contains("image")) {
viewStr.filename(file.getName());
}
if (MimeType.APPLICATION_PDF.equals(file.getMimeType())) {
String downloadParam = getRequest().getParameter(FILE_DOWNLOAD);
if (downloadParam != null && "1".equals(downloadParam))
viewStr.attachment(true);
else
viewStr.attachment(false);
}
return viewStr;
}
示例3: renderContent
import net.sourceforge.stripes.action.StreamingResolution; //导入依赖的package包/类
public Resolution renderContent(String content) {
Configuration conf = FreemarkerHelper.newConfig(app.servletContext(), null);
try {
Template temp = new Template("templateName", new StringReader(content), conf);
// Template temp = conf.getTemplate(new
// StringBuilder(Templates.getWidgetsPath()).append("/").append(path).append(templateSuffix).toString());
StringWriter sw = new StringWriter();
temp.process(null, sw);
return new StreamingResolution("text/html", sw.toString());
} catch (IOException | TemplateException e) {
throw new RuntimeException(e);
}
}
示例4: getOnkiHttp
import net.sourceforge.stripes.action.StreamingResolution; //导入依赖的package包/类
@HandlesEvent("getOnkiHttp")
public Resolution getOnkiHttp() throws HttpException, IOException {
String json = "";
String language = getUserLocale().toLanguageTag().split("-")[0];
HttpClient httpClient = new HttpClient();
httpClient.getParams().setParameter("http.protocol.version", HttpVersion.HTTP_1_1);
httpClient.getParams().setParameter("http.protocol.content-charset", "UTF-8");
GetMethod get = new GetMethod("http://onki.fi/key-"+this.getOnkiAccessKey()+"/api/v2/http/onto/" + ontologyId + "/search?q=" + term + "&l=" + language);
httpClient.executeMethod(get);
if (get.getStatusCode() == 200) {
json = get.getResponseBodyAsString();
}
//logger.info("getOnkiHttp(): "+json);
return new StreamingResolution(MIME_JS, json);
}
示例5: removeFileFromUpload
import net.sourceforge.stripes.action.StreamingResolution; //导入依赖的package包/类
/**
* Removes original file from uploaded list so user can upload a new one
* incase they uploaded a wrong one at first.
*
* @return Success of removal
* @throws UnsupportedEncodingException
*/
@HandlesEvent("removeFileFromUpload")
public Resolution removeFileFromUpload() throws UnsupportedEncodingException {
File file = null;
String response = "";
String dir = this.getUploadDirectory(true);
fileToDelete = URLDecoder.decode(fileToDelete, "UTF-8");
file = new File(dir + fileToDelete);
if (file.canRead()) {
// Delete possible thumbnail image
new File(dir + "thumb_" + FilenameUtils.removeExtension(fileToDelete) + ".png").delete();
if (file.delete()) {
response = "true";
} else {
response = "false";
}
} else {
response = "false";
}
return new StreamingResolution(MIME_TEXT, response);
}
示例6: deleteWatchedFolder
import net.sourceforge.stripes.action.StreamingResolution; //导入依赖的package包/类
/**
* Deletes watched given folder
*
* @return Success in text (true / false)
*/
@HandlesEvent("deleteWatchedFolder")
public Resolution deleteWatchedFolder() {
String ingestDir = this.getIngestDirectory(true);
File dir = new File(ingestDir + watchedFile);
String response = "";
try {
FileUtils.deleteDirectory(dir);
} catch (IOException e) {
response = "false";
e.printStackTrace();
return new StreamingResolution(MIME_TEXT, response);
}
response = "true";
return new StreamingResolution(MIME_TEXT, response);
}
示例7: getObjectBreadcrumb
import net.sourceforge.stripes.action.StreamingResolution; //导入依赖的package包/类
/**
* Creates a path to given object, including links to objects that are in
* the path
*
* @param pid Object whose path is to be created
* @return Path to given object in string format
*/
@HandlesEvent("getObjectBreadcrumb")
public Resolution getObjectBreadcrumb() {
FedoraBean fObject = Osa.fedoraManager.getObject(pid);
/*TODO:
* - check publicity level of the path-component
* - if name can not be shown, replace with text: confidential/restricted
* */
User user = this.getContext().getUser();
String path = "";
plainView = (plainView != null) ? true : false;
String publicityLevel = ((CaptureBean) fObject.getDataStream(FedoraBean.DATASTREAM_CAPTURE)).getPublicityLevel();
if (user.isAnonymous()) { //+
if (publicityLevel.equals("public")) {
path = Osa.searchManager.getObjectPath(pid, user, plainView);
} else {
path = "confidential/restricted";
}
} else {
path = Osa.searchManager.getObjectPath(pid, user, plainView);
}
return new StreamingResolution(MIME_TEXT, path);
}
示例8: showDatastream
import net.sourceforge.stripes.action.StreamingResolution; //导入依赖的package包/类
@HandlesEvent("showDatastream")
public Resolution showDatastream() throws MalformedURLException, IOException {
String username = Osa.fedoraManager.username;
String password = Osa.fedoraManager.password;
String credentials = username + ":" + password;
byte[] encoded = new Base64().encode(credentials.getBytes("UTF-8"));
String encoding = new String(encoded);
URL url = new URL(Osa.fedoraManager.baseUrl +link);
URLConnection conn = url.openConnection();
conn.setDoInput(true);
conn.setRequestProperty("Authorization", String.format("Basic %s", encoding));
InputStream is = conn.getInputStream();
DataInputStream in = new DataInputStream(is);
return new StreamingResolution("text/xml", in).setFilename("history.xml");
}
示例9: showLogFile
import net.sourceforge.stripes.action.StreamingResolution; //导入依赖的package包/类
@HandlesEvent("showLogFile")
public Resolution showLogFile() {
if (!isDocumentAdder()) {
return new ForwardResolution(ERROR_500);
}
FileInputStream fis = null;
DataInputStream dis = null;
File logFile = new File(this.getLogDirectory(logName,true)+ "/" +filename);
if (logFile.canRead()) {
try {
fis = new FileInputStream(logFile);
} catch (FileNotFoundException e) {
e.printStackTrace();
return new StreamingResolution(MIME_TEXT, new LocalizableMessage("error.filenotfound").getMessage(getUserLocale()));
}
dis = new DataInputStream(fis);
} else {
return new StreamingResolution(MIME_TEXT, new LocalizableMessage("error.filenotfound").getMessage(getUserLocale()));
}
// Force view in browser
StreamingResolution streamRes = new StreamingResolution(MIME_TEXT, dis).setAttachment(false);
streamRes.setCharacterEncoding("UTF-8");
return streamRes;
}
示例10: removeLogFile
import net.sourceforge.stripes.action.StreamingResolution; //导入依赖的package包/类
@HandlesEvent("removeLogFile")
public Resolution removeLogFile() {
String logDir = this.getLogDirectory(null, true);
File file = null;
HashMap<String, String> responseMap = new HashMap<String, String>();
for (String filename : watchedFiles) {
file = new File(logDir + "/" + filename);
if (file.canRead()) {
if (file.delete()) {
responseMap.put(file.getName(), "true");
} else {
responseMap.put(file.getName(), "false");
}
} else {
responseMap.put(file.getName(), "false");
}
}
return new StreamingResolution(MIME_JS, new flexjson.JSONSerializer().serialize(responseMap));
}
示例11: deleteRole
import net.sourceforge.stripes.action.StreamingResolution; //导入依赖的package包/类
@HandlesEvent("deleteRole")
public Resolution deleteRole () {
String dn = "";
String result = "";
for (String roleDn : entryDns) {
try {
dn = cleanUtf8Encoded(roleDn);
Osa.authManager.deleteEntry(dn, EntryType.ROLE);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
logger.info("deleted entry "+dn);
}
result = "success";
return new StreamingResolution(MIME_TEXT,result);
}
示例12: logout
import net.sourceforge.stripes.action.StreamingResolution; //导入依赖的package包/类
@HandlesEvent("logout")
public Resolution logout() {
HttpSession session = this.getContext().getRequest().getSession();
HttpServletResponse response = this.getContext().getResponse();
if (session != null) {
User user = (User) session.getAttribute("user");
if (user != null) {
Osa.dbManager.get("sql").removeCurrentuser(user.getDn());
}
session.removeAttribute("user");
session.invalidate();
}
response.setDateHeader("Expires",-1);
response.setHeader("Cache-Control","no-store");
response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setContentType("text/html");
return new StreamingResolution(MIME_TEXT, INDEX.replaceAll("/", ""));
}
示例13: createGroupTable
import net.sourceforge.stripes.action.StreamingResolution; //导入依赖的package包/类
@HandlesEvent("createGroupTable")
public Resolution createGroupTable() {
Vector<String> groups = Osa.authManager.getGroups(getUserOrganizationName());
Collections.sort(groups);
String json = "";
json = "{" +
"\"sEcho\": "+sEcho+"," +
"\"iTotalRecords\": "+groups.size()+"," +
"\"iTotalDisplayRecords\": " +groups.size()+",";
json += "\"aaData\": [";
for (String group : groups) {
json += "[";
json += "\""+group+"\"";
json += "],";
}
if (groups.size() > 0) {
json = json.substring(0, json.length()-1);
}
json += "]}";
return new StreamingResolution(MIME_JS, json);
}
示例14: deleteUser
import net.sourceforge.stripes.action.StreamingResolution; //导入依赖的package包/类
@HandlesEvent("deleteUser")
public Resolution deleteUser() {
String dn = "";
String result = "";
for (String usrDn : entryDns) {
try {
dn = cleanUtf8Encoded(usrDn);
Osa.authManager.deleteEntry(dn, EntryType.USER);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
logger.info("deleted entry "+dn);
}
result = "success";
return new StreamingResolution(MIME_TEXT,result);
}
示例15: facetOptions
import net.sourceforge.stripes.action.StreamingResolution; //导入依赖的package包/类
@HandlesEvent("getAjaxBrowseOptions")
public Resolution facetOptions() throws Exception {
search = getContext().getSearch();
try {
search = Osa.searchManager.search(search, this.getContext().getUser(), this.getContext().getUser().getOrganization());
jsonFacetValues = new HashMap<String, Object>();
for (String key : search.getFacets().keySet()) {
jsonFacetValues.put(key, search.getFacets().get(key).toString());
}
if (search.getFacetFilters() != null) {
jsonFacetValues.put("getFacetFilters", new flexjson.JSONSerializer().deepSerialize(search.getFacetFilters().entrySet().toString()));
}
jsonFacetValues.put("NumberOfResults", search.getTotalSize());
jsonOptions = new flexjson.JSONSerializer().deepSerialize(jsonFacetValues);
return new StreamingResolution("application/json", jsonOptions);
} catch (Exception e) {
logger.error(e);
return null;
}
}