<%@ page contentType="text/html; charset=euc-kr"%>
<jsp:directive.page import="java.util.List" />
<jsp:directive.page import="java.sql.Timestamp" />
<jsp:directive.page import="org.kldp.ebmsh.moniter.persistant.MessageStore" />
<jsp:directive.page import="org.kldp.ebmsh.moniter.persistant.EbmsMoniterManager" />
<jsp:directive.page import="org.kldp.ebmsh.moniter.persistant.Tracker" />
<jsp:directive.page import="org.kldp.ebmsh.moniter.persistant.InComingMessage" />
<jsp:directive.page import="org.kldp.ebmsh.moniter.persistant.MessageStatus" />
<jsp:directive.page import="org.kldp.ebmsh.moniter.persistant.MessageStatusConstraints" />

<%
	String documentId = request.getParameter("documentId");
	String messageId = request.getParameter("messageId");
%>

<!--검색-->
<table width="100%" border="0" cellpadding="0" cellspacing="1"
	bgcolor="#CDDCED">
	<tr>
		<td
			style="PADDING-LEFT: 10px; PADDING-RIGHT: 20px; PADDING-TOP: 5px; PADDING-BOTTOM: 5px;"
			bgcolor="#FFFFFF">
			<table width="100%" border="0" align="center" cellpadding="0"
				cellspacing="0">
				<tr>
					<td width="15">
						<img src="<%= request.getContextPath() %>/image/search/icon_arrow.gif" width="11" height="11">
					</td>
					<td>
						<span class="style2">메세지정보</span>
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>


<table width="100%" border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td height="5"></td>
	</tr>
	<tr>
		<td style="PADDING-LEFT: 20px; PADDING-RIGHT: 20px; PADDING-TOP: 5px; PADDING-BOTTOM: 5px;" bgcolor="#F7F7F7">
			<div id="MessageInfo">
				<div class="ContentArea">
					<ul>
						<li><span class="MessageInfoLabel">문서 ID </span>: 
						<%
							if(documentId == null) 
								out.println("-");
							else
								out.println(documentId);
						%>
						</li>
						
						<li><span class="MessageInfoLabel">메시지 ID </span>: <%= messageId %></li>
					</ul>
				</div>
			</div>
		</td>
	</tr>
</table>
<br>

<%
	EbmsMoniterManager manager = new EbmsMoniterManager();
	
	List trackerDetailList = manager.getTrackers(messageId);
%>
<table width="100%" border="0" cellpadding="0" cellspacing="1"
	bgcolor="#CDDCED">
	<tr>
		<td
			style="PADDING-LEFT: 10px; PADDING-RIGHT: 20px; PADDING-TOP: 5px; PADDING-BOTTOM: 5px;"
			bgcolor="#FFFFFF">
			<table width="100%" border="0" align="center" cellpadding="0"
				cellspacing="0">
				<tr>
					<td width="15">
						<img src="<%= request.getContextPath() %>/image/search/icon_arrow.gif" width="11" height="11">
					</td>
					<td>
						<span class="style2">Tracking 정보</span>
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>
<!--/검색-->
<table width="100%" border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td height="5"></td>
	</tr>
	<tr>
		<td
			style="PADDING-LEFT: 20px; PADDING-RIGHT: 20px; PADDING-TOP: 5px; PADDING-BOTTOM: 5px;"
			bgcolor="#F7F7F7">
			<div id="TrackingInfo">
				<div class="ContentArea">
				<table>
					<tr>
						<th id="trackingTime">
							시 간
						</th>
		
						<th id="state">
							상 태
						</th>
		
						<th id="information">
							설 명
						</th>
					</tr>
					
					<%
						for(int i = 0; i < trackerDetailList.size(); i++) {
							Tracker tracker = (Tracker)trackerDetailList.get(i);
		
							Timestamp trackingTime = tracker.getTrackingTime();
							String state = tracker.getState();
							String information = tracker.getInformation();
							
							if( information == null )
								information = "";
					%>
							<tr>
								<td>
									<%= trackingTime %>
								</td>
		
								<td>
									<%= state %>
								</td>
		
								<td>
									<%= information %>
								</td>
							</tr>
					<%
						}
					%>
				</table>
			</div>
		</div>
		</td>
	</tr>
</table>

<br>

<%
	MessageStore messageStore = manager.getMessageStoreMessage(messageId);

	InComingMessage incomingMessage = manager.getInComingMessage(messageId);
	
	MessageStatus messageStatus = manager.getMessageStatus(messageId);
%>
<table width="100%" border="0" cellpadding="0" cellspacing="1"
	bgcolor="#CDDCED">
	<tr>
		<td
			style="PADDING-LEFT: 10px; PADDING-RIGHT: 20px; PADDING-TOP: 5px; PADDING-BOTTOM: 5px;"
			bgcolor="#FFFFFF">
			<table width="100%" border="0" align="center" cellpadding="0"
				cellspacing="0">
				<tr>
					<td width="15">
						<img src="<%= request.getContextPath() %>/image/search/icon_arrow.gif" width="11" height="11">
					</td>
					<td>
						<span class="style2">Ebxml 메시지 정보</span>
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>
<!--/검색-->
<table width="100%" border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td height="5"></td>
	</tr>
	<tr>
		<td
			style="PADDING-LEFT: 20px; PADDING-RIGHT: 20px; PADDING-TOP: 5px; PADDING-BOTTOM: 5px;"
			bgcolor="#F7F7F7">
			<div id="EbxmlMessageInfo">
				<div class="ContentArea">
				<%
					if( messageStore == null ) {
				%>
						<div class="NoEbxmlInformation">Ebxml 메시지 정보가 없습니다.</div>
				<%
					}
					else {
				%>
						<ul>
							<li><span class="EbxmlMessageInfoLabel">Message ID </span>: <%= messageStore.getMessageId() %></li>
							<li><span class="EbxmlMessageInfoLabel">Cpa </span>: <%= messageStore.getCpaId() %></li>
							<li><span class="EbxmlMessageInfoLabel">From </span>: <%= messageStore.getFromPartyId() %></li>
							<li><span class="EbxmlMessageInfoLabel">To </span>: <%= messageStore.getToPartyId() %></li>
							<li><span class="EbxmlMessageInfoLabel">Conversation ID </span>: <%= messageStore.getConversationId() %></li>
							<li><span class="EbxmlMessageInfoLabel">Service </span>: <%= messageStore.getService() %></li>
							<li><span class="EbxmlMessageInfoLabel">Action </span>: <%= messageStore.getAction() %></li>
						</ul>
						
						<div class="ViewEbxmlMessage">
							<a href="viewEbxmlMessage.jsp?messagePath=<%= incomingMessage.getMSGFilePath() %>" target="_blank">메시지 원문 보기</a>
						</div>
				<%
					}
				%>
				</div>
			</div>
		</td>
	</tr>
</table>


<br>

<table width="100%" border="0" cellpadding="0" cellspacing="1"
	bgcolor="#CDDCED">
	<tr>
		<td
			style="PADDING-LEFT: 10px; PADDING-RIGHT: 20px; PADDING-TOP: 5px; PADDING-BOTTOM: 5px;"
			bgcolor="#FFFFFF">
			<table width="100%" border="0" align="center" cellpadding="0"
				cellspacing="0">
				<tr>
					<td width="15">
						<img src="<%= request.getContextPath() %>/image/search/icon_arrow.gif" width="11" height="11">
					</td>
					<td>
						<span class="style2">메시지 처리</span>
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>
<!--/검색-->
<table width="100%" border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td height="5"></td>
	</tr>
	<tr>
		<td
			style="PADDING-LEFT: 20px; PADDING-RIGHT: 20px; PADDING-TOP: 5px; PADDING-BOTTOM: 5px;"
			bgcolor="#F7F7F7">
			<div id="MessageProcess">
			<div class="ContentArea">
		<%
			if( messageStatus == null || messageStatus.getStatus() == MessageStatusConstraints.Receive || messageStatus.getStatus() == MessageStatusConstraints.Fail ) {
		%>
				<div class="NoMessageProcess">
					메시지를 재처리 할 수 없습니다.
				</div>
		<%
			}
			else {
		%>
				<ul>
					<li><a href="applicationLayerProcess.jsp?messageId=<%= messageStore.getMessageId() %>&messagePath=<%= incomingMessage.getMSGFilePath() %>">메시지 다시 처리</a></li>
				</ul>
		<%
			}
		%>
		</div>
		</div>
		</td>
	</tr>
</table>
