Example usage for org.apache.wicket Component getClassRelativePath

List of usage examples for org.apache.wicket Component getClassRelativePath

Introduction

In this page you can find the example usage for org.apache.wicket Component getClassRelativePath.

Prototype

public final String getClassRelativePath() 

Source Link

Usage

From source file:com.lyndir.lhunath.snaplog.data.object.Issue.java

License:Apache License

/**
 * Create a new {@link Issue} instance.//from   w  w  w. j  av  a  2 s.c  om
 *
 * @param origin  The page that the issue occurred on.
 * @param cause   The exception that caused the issue.
 * @param subject The user that was authenticated when the issue occurred or <code>null</code> if no user was authenticated.
 */
public Issue(final Component origin, final Exception cause, final UserProfile subject) {

    logger.dbg("New issue caused by: %s", cause);

    // Dump the exception to a string.
    StringWriter causeStringWriter = new StringWriter();
    PrintWriter causeStringPrintWriter = new PrintWriter(causeStringWriter);
    try {
        if (cause != null) {
            causeStringPrintWriter.write(cause.toString());
            cause.printStackTrace(causeStringPrintWriter);
        }
    } finally {
        causeStringPrintWriter.close();
    }

    originPath = origin == null ? null : origin.getClassRelativePath();
    this.cause = cause;
    this.subject = subject;

    issueHash = StringUtils.encodeHex(MessageDigests.MD5.of(JSUtils
            .toString(new Object[] { originPath, causeStringWriter.toString() }).getBytes(Charsets.UTF_8)));
    issueCode = UUID.randomUUID().toString();
}