Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package act.util;
/*-
* #%L
* ACT Framework
* %%
* Copyright (C) 2014 - 2017 ActFramework
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import static org.osgl.http.H.Format.*;
import act.Act;
import act.app.ActionContext;
import act.view.Template;
import act.view.ViewManager;
import org.osgl.$;
import org.osgl.http.H;
import org.osgl.mvc.ErrorPageRenderer;
import org.osgl.mvc.MvcConfig;
import org.osgl.mvc.result.ErrorResult;
import org.osgl.util.S;
import java.util.HashMap;
import java.util.Map;
public class ActErrorPageRender extends ErrorPageRenderer {
public static final String ARG_ERROR = "_error";
private volatile Boolean i18n;
private Map> templateCache = new HashMap<>();
@Override
protected String renderTemplate(ErrorResult error, H.Format format) {
ActionContext context = ActionContext.current();
if (null == context) {
return null;
}
Integer errorCode = error.errorCode();
int statusCode = error.statusCode();
fixRequestAcceptFormat(context);
Template t = getTemplate(statusCode, context);
if (null == t) {
String errorMsg = error.getMessage();
if (null == errorMsg) {
errorMsg = MvcConfig.errorMessage(error.status());
}
if (i18n()) {
String translated = context.i18n(true, errorMsg);
if (translated == errorMsg) {
translated = context.i18n(true, MvcConfig.class, errorMsg);
}
errorMsg = translated;
}
H.Format accept = context.accept();
if (H.Format.JSON == accept) {
return jsonContent(error, errorCode, errorMsg);
} else if (HTML == accept) {
String header = S.concat("HTTP/1.1 ", Integer.toString(statusCode), " ", errorMsg);
return S.concat(""
, header
, "