Skip to main content
summaryrefslogtreecommitdiffstats
blob: b607759b52a80021bb14fe3057abd1aee03552b9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
/*******************************************************************************
 * Copyright (c) 2002-2005 IBM Corporation and others.
 * All rights reserved.   This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *   IBM - Initial API and implementation
 *******************************************************************************/
package org.eclipse.wst.wsi.internal.core.report.impl;

import java.io.PrintWriter;
import java.io.StringWriter;

import org.eclipse.wst.wsi.internal.core.WSIConstants;
import org.eclipse.wst.wsi.internal.core.document.DocumentElement;
import org.eclipse.wst.wsi.internal.core.profile.validator.EnvelopeValidator;
import org.eclipse.wst.wsi.internal.core.profile.validator.MessageValidator;
import org.eclipse.wst.wsi.internal.core.report.AssertionResult;
import org.eclipse.wst.wsi.internal.core.report.Entry;
import org.eclipse.wst.wsi.internal.core.report.EntryContainer;
import org.eclipse.wst.wsi.internal.core.util.EntryType;
import org.eclipse.wst.wsi.internal.core.xml.XMLUtils;

/**
 * This class represents an entry in a report.
 * 
 * @version 1.0.1
 * @author Peter Brittenham  (peterbr@us.ibm.com)
 */
public class EntryImpl extends EntryResultImpl implements Entry
{
  /**
   * Entry type.
   */
  protected EntryType entryType = null;

  /**
   * Artifact name (optional).
   */
  protected String artifactName = null;

  /**
   * Reference ID.
   */
  protected String referenceID = null;

  /**
   * Parent element name (only used when entry type is "port" or "operation").
   */
  protected String parentElementName = null;

  /**
   * Entry detail object.
   */
  protected Object entryDetail = null;

  /**
   * Entry container.
   */
  protected EntryContainer entryContainer = null;

  /* (non-Javadoc)
   * @see org.wsi.test.report.Entry#getEntryType()
   */
  public EntryType getEntryType()
  {
    return this.entryType;
  }

  /* (non-Javadoc)
   * @see org.wsi.test.report.Entry#setEntryType(EntryType)
   */
  public void setEntryType(EntryType entryType)
  {
    this.entryType = entryType;
  }

  /* (non-Javadoc)
   * @see org.wsi.test.report.Entry#getArtifactName()
   */
  public String getArtifactName()
  {
    return this.artifactName;
  }

  /* (non-Javadoc)
   * @see org.wsi.test.report.Entry#setArtifactName(java.lang.String)
   */
  public void setArtifactName(String artifactName)
  {
    this.artifactName = artifactName;
  }

  /* (non-Javadoc)
   * @see org.wsi.test.report.Entry#getReferenceID()
   */
  public String getReferenceID()
  {
    return this.referenceID;
  }

  /* (non-Javadoc)
   * @see org.wsi.test.report.Entry#setReferenceID(String)
   */
  public void setReferenceID(String referenceID)
  {
    this.referenceID = referenceID;
  }

  /* (non-Javadoc)
   * @see org.wsi.test.report.Entry#getParentElementName()
   */
  public String getParentElementName()
  {
    return this.parentElementName;
  }

  /* (non-Javadoc)
   * @see org.wsi.test.report.Entry#setParentElementName(String)
   */
  public void setParentElementName(String parentElementName)
  {
    this.parentElementName = parentElementName;
  }

  /* (non-Javadoc)
   * @see org.wsi.test.report.Entry#getEntryDetail()
   */
  public Object getEntryDetail()
  {
    return this.entryDetail;
  }

  /* (non-Javadoc)
   * @see org.wsi.test.report.Entry#setEntryDetail(Object)
   */
  public void setEntryDetail(Object entryDetail)
  {
    this.entryDetail = entryDetail;
  }

  /* (non-Javadoc)
   * @see org.wsi.test.report.Entry#getEntryContainer()
   */
  public EntryContainer getEntryContainer()
  {
    return this.entryContainer;
  }

  /* (non-Javadoc)
   * @see org.wsi.test.report.Entry#setEntryContainer(org.wsi.test.report.EntryContainer)
   */
  public void setEntryContainer(EntryContainer entryContainer)
  {
    this.entryContainer = entryContainer;
  }

  /* (non-Javadoc)
   * @see org.wsi.test.report.EntryResult#addAssertionResult(AssertionResult)
   */
  public void addAssertionResult(AssertionResult assertionResult)
  {
    super.addAssertionResult(assertionResult);

    if (this.entryContainer != null)
      this.entryContainer.addAssertionResult(assertionResult);
  }

  /* (non-Javadoc)
   * @see org.wsi.test.report.Entry#getStartXMLString(String)
   */
  public String getStartXMLString(String namespaceName, boolean showLogEntry, boolean envelopeArtifactType)
  {
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);

    String nsName = namespaceName;
    if ((!nsName.equals("") && (!nsName.endsWith(":"))))
      nsName += ":";

    // Create element 
    pw.print("    <" + nsName + ELEM_NAME + " ");

    if (this.entryType != null)
    {
      if (envelopeArtifactType)
	  {
      	// we use the same actual entry for both message and envelope artifacts
      	// we now need to output entry type names that actually pertain to the artifact type
      	pw.print(
                WSIConstants.ATTR_TYPE + "=\"" + getCorrespondingEnvelopeEntryTypeName(this.entryType.getTypeName()) + "\" ");
	  }
	  else
	  {
        pw.print(
          WSIConstants.ATTR_TYPE + "=\"" + this.entryType.getTypeName() + "\" ");
	  }
    }

    else if (this.artifactName != null)
    {
      pw.print(WSIConstants.ATTR_TYPE + "=\"[" + this.artifactName + "]\" ");
    }

    if (this.referenceID != null)
      pw.print(WSIConstants.ATTR_REFERENCE_ID + "=\"" + XMLUtils.xmlEscapedString(this.referenceID) + "\" ");


    // If service name was set then add it
    //if (parentElementName != null) {
    //  pw.print(" " + WSIConstants.ATTR_PARENT_ELEMENT_NAME + "=\"" + this.parentElementName + "\"");
    //}

    // ADD: Need to check for config option that specifies 
    //      that log entries should be added

    // If target is a log entry, then add reference to it
    if ((entryType != null) && (entryType.getArtifactType().isLoggable()) && (showLogEntry)) 
    {
      DocumentElement logEntry = (DocumentElement) entryDetail;
      pw.println("value=\"" + logEntry.toXMLString(WSIConstants.NS_NAME_WSI_LOG) + "\" ");
    }
   
    // End element
    pw.println(">");

    return sw.toString();
  }

  /* (non-Javadoc)
   * @see org.wsi.test.report.Entry#getStartXMLString(String)
   */
  public String getStartXMLString(String namespaceName, boolean showLogEntry)
  {
  	return getStartXMLString(namespaceName, showLogEntry, false);
  }

  /* (non-Javadoc)
   * @see org.wsi.test.report.Entry#getEndXMLString(String)
   */
  public String getEndXMLString(String namespaceName)
  {
    String nsName = namespaceName;
    if ((!nsName.equals("") && (!nsName.endsWith(":"))))
      nsName += ":";

    return "    </" + nsName + ELEM_NAME + ">";
  }

  /* (non-Javadoc)
   * @see org.wsi.test.document.DocumentElement#toXMLString(String)
   */
  public String toXMLString(String namespaceName)
  {
    // Return string
    return getStartXMLString("", false) + getEndXMLString("");
  }

  public String getCorrespondingEnvelopeEntryTypeName(String messageEntryTypeName)
  {
  	String envelopeEntryTypeName = messageEntryTypeName;
  	if (messageEntryTypeName != null)
  	{
  	if (messageEntryTypeName.equals(MessageValidator.TYPE_MESSAGE_ANY))
  		envelopeEntryTypeName = EnvelopeValidator.TYPE_ENVELOPE_ANY;
  	else if (messageEntryTypeName.equals(MessageValidator.TYPE_MESSAGE_REQUEST))
  		envelopeEntryTypeName = EnvelopeValidator.TYPE_ENVELOPE_REQUEST;
  	else if (messageEntryTypeName.equals(MessageValidator.TYPE_MESSAGE_RESPONSE))
  		envelopeEntryTypeName = EnvelopeValidator.TYPE_ENVELOPE_RESPONSE;
  	}

  	return envelopeEntryTypeName;
  }
}

Back to the top