- Timestamp:
- 08/18/11 12:39:22 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ether_megapoli/trunk/common/implementation/com/ether/WebHelper.java
r89 r130 4 4 import java.io.PrintWriter; 5 5 import java.security.InvalidParameterException; 6 import java.util.Locale; 7 import java.util.ResourceBundle; 6 8 7 9 import javax.servlet.ServletOutputStream; … … 14 16 import org.jetbrains.annotations.Nullable; 15 17 16 import com.ether. WebException.WebCode;18 import com.ether.EtherException.EtherCode; 17 19 18 20 public final class WebHelper … … 23 25 24 26 @NotNull 25 public static String getRequestParameter( @NotNull final HttpServletRequest httpServletRequest, @Nullable final String parameterName, @Nullable final String defaultParameterValue, final boolean canBeNull )26 27 public static String getRequestParameter( @NotNull final HttpServletRequest httpServletRequest, @Nullable final String parameterName, @Nullable final String defaultParameterValue, final boolean canBeNull ) 28 throws InvalidParameterException 27 29 { 28 29 if(null == parameterName)30 31 30 String parameterValue; 31 if( null == parameterName ) 32 parameterValue = defaultParameterValue; 33 32 34 parameterValue = httpServletRequest.getParameter( parameterName ); 33 35 … … 54 56 } 55 57 56 public static void displayAjaxError(@NotNull final HttpServletResponse response, @Nullable final String methodName) 57 throws WebException 58 { 59 try { 60 response.setStatus(HttpServletResponse.SC_NOT_IMPLEMENTED); 61 response.setCharacterEncoding(UTF8Charset.getEncoding()); 62 response.setContentType("text/plain;charset="+ UTF8Charset.getEncoding()); 63 final ServletOutputStream outputStream = response.getOutputStream(); 64 outputStream.print("error.method_not_implemented : " + methodName+ " is not implemented."); 65 outputStream.flush(); 66 outputStream.close(); 67 } catch (IOException e) { 68 throw new WebException(WebCode.IO_EXCEPTION_ERROR_TO_GET_OUTPUTSTREAM, e); 69 } 58 public static void displayAjaxError( @NotNull final HttpServletResponse response, @Nullable final String methodName ) 59 throws EtherException 60 { 61 try 62 { 63 response.setStatus( HttpServletResponse.SC_NOT_IMPLEMENTED ); 64 response.setCharacterEncoding( UTF8Charset.getEncoding() ); 65 response.setContentType( "text/plain;charset=" + UTF8Charset.getEncoding() ); 66 final ServletOutputStream outputStream = response.getOutputStream(); 67 outputStream.print( "error.method_not_implemented : " + methodName + " is not implemented." ); 68 outputStream.flush(); 69 outputStream.close(); 70 } 71 catch( IOException e ) 72 { 73 throw new EtherException( EtherCode.IO_EXCEPTION_ERROR_TO_GET_OUTPUTSTREAM, e ); 74 } 75 } 76 77 @NotNull 78 public static ResourceBundle getBundle( @Nullable final Locale locale ) 79 { 80 if( null != locale ) 81 return ResourceBundle.getBundle( "ApplicationResources", locale ); 82 else 83 return ResourceBundle.getBundle( "ApplicationResources" ); 70 84 } 71 85 72 86 private static final Log LOGGER = LogFactory.getLog( WebHelper.class ); 73 87 74 88 private static final String CONTENT_TYPE_TEXT_JSON = "text/javascript;charset=" + UTF8Charset.getEncoding(); 75 private static final char JSON_TAG_BEGIN = ' ' 89 private static final char JSON_TAG_BEGIN = ' '; // '('; 76 90 private static final char JSON_TAG_END = ' '; // ')'; 77 91 }
Note: See TracChangeset
for help on using the changeset viewer.