use of org.osgi.service.http.runtime.dto.FailedErrorPageDTO in project felix by apache.
the class ErrorPageRegistry method getRuntimeInfo.
/**
* Get DTOs for error pages.
* @param dto The servlet context DTO
* @param failedErrorPageDTOs The failed error page DTOs
*/
public void getRuntimeInfo(final ServletContextDTO dto, final Collection<FailedErrorPageDTO> failedErrorPageDTOs) {
final List<ErrorPageDTO> errorPageDTOs = new ArrayList<ErrorPageDTO>();
final List<ErrorRegistrationStatus> statusList = this.status;
for (final ErrorRegistrationStatus status : statusList) {
for (final Map.Entry<Integer, ErrorRegistration> entry : status.reasonMapping.entrySet()) {
final ErrorPageDTO state = ErrorPageDTOBuilder.build(status.getHandler(), entry.getKey());
state.errorCodes = Arrays.copyOf(entry.getValue().errorCodes, entry.getValue().errorCodes.length);
state.exceptions = Arrays.copyOf(entry.getValue().exceptions, entry.getValue().exceptions.length);
if (entry.getKey() == -1) {
errorPageDTOs.add(state);
} else {
failedErrorPageDTOs.add((FailedErrorPageDTO) state);
}
}
}
if (!errorPageDTOs.isEmpty()) {
dto.errorPageDTOs = errorPageDTOs.toArray(new ErrorPageDTO[errorPageDTOs.size()]);
}
}
use of org.osgi.service.http.runtime.dto.FailedErrorPageDTO in project felix by apache.
the class ErrorPageDTOBuilder method build.
/**
* Build a servlet DTO from a servlet handler
* @param handler The servlet handler
* @param reason If reason is -1, a servlet DTO is created, otherwise a failed servlet DTO is returned
* @return A servlet DTO
*/
public static ErrorPageDTO build(final ServletHandler handler, final int reason) {
final ErrorPageDTO dto = build(handler.getServletInfo(), reason != -1);
BaseServletDTOBuilder.fill(dto, handler);
if (reason != -1) {
((FailedErrorPageDTO) dto).failureReason = reason;
}
return dto;
}
use of org.osgi.service.http.runtime.dto.FailedErrorPageDTO in project felix by apache.
the class ErrorPageDTOBuilder method build.
/**
* Build a servlet DTO from a servlet info
* @param info The servlet info
* @return A servlet DTO
*/
public static ErrorPageDTO build(final ServletInfo info, final boolean failed) {
final ErrorPageDTO dto = (failed ? new FailedErrorPageDTO() : new ErrorPageDTO());
BaseServletDTOBuilder.fill(dto, info);
dto.errorCodes = BuilderConstants.EMPTY_LONG_ARRAY;
dto.exceptions = BuilderConstants.EMPTY_STRING_ARRAY;
return dto;
}
Aggregations