Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package net.nan21.dnet.core.web.controller.ui.extjs;
  
  import java.io.File;
  import java.util.HashMap;
  import java.util.List;
  import java.util.Map;
  
  import  javax.servlet.http.HttpServletRequest;
 import  javax.servlet.http.HttpServletResponse;
 
 
 import  org.springframework.security.core.context.SecurityContextHolder;
 import  org.springframework.web.bind.annotation.PathVariable;
 import  org.springframework.web.bind.annotation.RequestMapping;
 import  org.springframework.web.bind.annotation.RequestMethod;
 import  org.springframework.web.bind.annotation.ResponseBody;
 import  org.springframework.web.servlet.ModelAndView;
 
 @RequestMapping(value = "/frame", method = RequestMethod.GET)
 
 	private String cacheFolder;
Handler for a frame html page.

Parameters:
frame
request
response
Returns:
Throws:
Exception
 
 	@RequestMapping(value = "/{bundle}/{frameFQN}", method = RequestMethod.GET)
 	protected ModelAndView home(@PathVariable("frameFQN"String frame,
 			HttpServletRequest request, HttpServletResponse response)
 			throws Exception {
 
 		try {
 			@SuppressWarnings("unused")
 			SessionUser su = (SessionUser) SecurityContextHolder.getContext()
 					.getAuthentication().getPrincipal();
 		} catch (java.lang.ClassCastException e) {
 			throw new NotAuthorizedRequestException("Not authenticated");
 		}
 
 		Map<StringObjectmodel = new HashMap<StringObject>();
 		this._prepare(modelrequestresponse);
 
 		String[] tmp = request.getPathInfo().split("/");
 		String frameFQN = tmp[tmp.length - 1];
 		String bundle = tmp[tmp.length - 2];
 		String[] t = frameFQN.split("\\.");
 		String frameName = t[t.length - 1];
 
 		model.put("item"frameFQN);
 		model.put("itemSimpleName"frameName);
 		model.put("bundle"bundle);
 
 		// get extensions
 		model.put("extensions",
 
 		model.put("extensionsContent"getExtensionContent(frameFQN));
 
 
 			List<StringlistCmp = new ArrayList<String>();
 			List<StringlistTrl = new ArrayList<String>();
 
 			loader.resolveFrameDependencies(bundleframeName,
 					(Stringmodel.get("shortLanguage"), listCmplistTrl);
 
 			model.put("frameDependenciesCmp"listCmp);
 			model.put("frameDependenciesTrl"listTrl);
 
 		} else {
 			if (this. == null) {
 				synchronized (this) {
 					if (this. == null) {
 
 						if (this. == null) {
 						}
 
 						File cf = new File(this.);
 						if (!cf.exists()) {
 
 							if (!cf.mkdirs()) {
 								throw new Exception(
										"Cache folder "
" does not exist and could not be created.");
							}
						}
						if (!cf.isDirectory() || !cf.canWrite()) {
							throw new Exception(
									"Cache folder "
" is not writeable. Cannot pack and cache the frame dependencies for the configured `prod` working mode. ");
						}
						this. = true;
					}
				}
			}
		}
		return new ModelAndView(this.model);
	}

Handler to return the cached js file with the dependent components.

Parameters:
bundle
frame
request
response
Returns:
Throws:
Exception
	@RequestMapping(value = "/{bundle}/{frame}.js", method = RequestMethod.GET)
	@ResponseBody
	public String frameCmpJs(@PathVariable("bundle"String bundle,
			@PathVariable("frame"String frame, HttpServletRequest request,
			HttpServletResponse responsethrows Exception {
		try {
			SessionUser su = (SessionUser) SecurityContextHolder.getContext()
					.getAuthentication().getPrincipal();
catch (java.lang.ClassCastException e) {
			throw new NotAuthorizedRequestException("Not authenticated");
		}
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("UTF-8");
		String fileName = frame + ".js";
		File f = new File(this. + "/" + bundle + "." + fileName);
		if (!f.exists()) {
			loader.packFrameCmp(bundleframef);
		}
		this.sendFile(fresponse.getOutputStream());
		return null;
	}

Handler to return the cached js file with the dependent translations.

Parameters:
bundle
frame
language
request
response
Returns:
Throws:
Exception
	@RequestMapping(value = "/{bundle}/{language}/{frame}.js", method = RequestMethod.GET)
	@ResponseBody
	public String frameTrlJs(@PathVariable("bundle"String bundle,
			@PathVariable("frame"String frame,
			@PathVariable("language"String language,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		try {
			SessionUser su = (SessionUser) SecurityContextHolder.getContext()
					.getAuthentication().getPrincipal();
catch (java.lang.ClassCastException e) {
			throw new NotAuthorizedRequestException("Not authenticated");
		}
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("UTF-8");
		String fileName = frame + "-" + language + ".js";
		File f = new File(this. + "/" + bundle + "." + fileName);
		if (!f.exists()) {
			loader.packFrameTrl(bundleframelanguagef);
		}
		this.sendFile(fresponse.getOutputStream());
		return null;
	}

Helper method to create , configure and return an DependencyLoader instance

Returns:
		return loader;
	}
New to GrepCode? Check out our FAQ X