| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
package org.apache.tapestry5.corelib.pages; |
| 16 | |
|
| 17 | |
import org.apache.tapestry5.SymbolConstants; |
| 18 | |
import org.apache.tapestry5.annotations.ContentType; |
| 19 | |
import org.apache.tapestry5.annotations.Property; |
| 20 | |
import org.apache.tapestry5.ioc.annotations.Inject; |
| 21 | |
import org.apache.tapestry5.ioc.annotations.Symbol; |
| 22 | |
import org.apache.tapestry5.ioc.internal.util.InternalUtils; |
| 23 | |
import org.apache.tapestry5.services.ExceptionReporter; |
| 24 | |
import org.apache.tapestry5.services.Request; |
| 25 | |
import org.apache.tapestry5.services.Session; |
| 26 | |
|
| 27 | |
import java.util.List; |
| 28 | |
import java.util.regex.Pattern; |
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
|
| 35 | |
|
| 36 | |
@ContentType("text/html") |
| 37 | 2 | public class ExceptionReport implements ExceptionReporter |
| 38 | |
{ |
| 39 | |
private static final String PATH_SEPARATOR_PROPERTY = "path.separator"; |
| 40 | |
|
| 41 | |
|
| 42 | |
|
| 43 | 2 | private static final Pattern PATH_RECOGNIZER = Pattern.compile("\\..*path$"); |
| 44 | |
|
| 45 | |
@Property |
| 46 | |
private String attributeName; |
| 47 | |
|
| 48 | |
@Inject |
| 49 | |
@Property |
| 50 | |
private Request request; |
| 51 | |
|
| 52 | |
@Inject |
| 53 | |
@Symbol(SymbolConstants.PRODUCTION_MODE) |
| 54 | |
@Property(write = false) |
| 55 | |
private boolean productionMode; |
| 56 | |
|
| 57 | |
@Inject |
| 58 | |
@Symbol(SymbolConstants.TAPESTRY_VERSION) |
| 59 | |
@Property(write = false) |
| 60 | |
private String tapestryVersion; |
| 61 | |
|
| 62 | |
@Inject |
| 63 | |
@Symbol(SymbolConstants.APPLICATION_VERSION) |
| 64 | |
@Property(write = false) |
| 65 | |
private String applicationVersion; |
| 66 | |
|
| 67 | |
@Property(write = false) |
| 68 | |
private Throwable rootException; |
| 69 | |
|
| 70 | |
@Property |
| 71 | |
private String propertyName; |
| 72 | |
|
| 73 | 2 | private final String pathSeparator = System.getProperty(PATH_SEPARATOR_PROPERTY); |
| 74 | |
|
| 75 | |
public void reportException(Throwable exception) |
| 76 | |
{ |
| 77 | 70 | rootException = exception; |
| 78 | 70 | } |
| 79 | |
|
| 80 | |
public boolean getHasSession() |
| 81 | |
{ |
| 82 | 70 | return request.getSession(false) != null; |
| 83 | |
} |
| 84 | |
|
| 85 | |
public Session getSession() |
| 86 | |
{ |
| 87 | 3380 | return request.getSession(false); |
| 88 | |
} |
| 89 | |
|
| 90 | |
public Object getAttributeValue() |
| 91 | |
{ |
| 92 | 3318 | return getSession().getAttribute(attributeName); |
| 93 | |
} |
| 94 | |
|
| 95 | |
|
| 96 | |
|
| 97 | |
|
| 98 | |
public List<String> getSystemProperties() |
| 99 | |
{ |
| 100 | 70 | return InternalUtils.sortedKeys(System.getProperties()); |
| 101 | |
} |
| 102 | |
|
| 103 | |
public String getPropertyValue() |
| 104 | |
{ |
| 105 | 4480 | return System.getProperty(propertyName); |
| 106 | |
} |
| 107 | |
|
| 108 | |
public boolean isComplexProperty() |
| 109 | |
{ |
| 110 | 4060 | return PATH_RECOGNIZER.matcher(propertyName).find() && getPropertyValue().contains(pathSeparator); |
| 111 | |
} |
| 112 | |
|
| 113 | |
public String[] getComplexPropertyValue() |
| 114 | |
{ |
| 115 | |
|
| 116 | |
|
| 117 | 280 | return getPropertyValue().split(pathSeparator); |
| 118 | |
} |
| 119 | |
} |