/**
   * Returns true if the user represented by the current request plays the named role.
   *
   * @param role the named role to test.
   * @return true if the user plays the role.
   */
  public boolean isUserInRole(String role) {
    ServletInvocation invocation = getInvocation();

    if (invocation == null) {
      if (getRequest() != null) return getRequest().isUserInRole(role);
      else return false;
    }

    HashMap<String, String> roleMap = invocation.getSecurityRoleMap();

    if (roleMap != null) {
      String linkRole = roleMap.get(role);

      if (linkRole != null) role = linkRole;
    }

    String runAs = getRunAs();

    if (runAs != null) return runAs.equals(role);

    WebApp webApp = getWebApp();

    Principal user = getUserPrincipal();

    if (user == null) {
      if (log.isLoggable(Level.FINE)) log.fine(this + " no user for isUserInRole");

      return false;
    }

    RoleMapManager roleManager = webApp != null ? webApp.getRoleMapManager() : null;

    if (roleManager != null) {
      Boolean result = roleManager.isUserInRole(role, user);

      if (result != null) {
        if (log.isLoggable(Level.FINE)) log.fine(this + " userInRole(" + role + ")->" + result);

        return result;
      }
    }

    Login login = webApp == null ? null : webApp.getLogin();

    boolean inRole = login != null && login.isUserInRole(user, role);

    if (log.isLoggable(Level.FINE)) {
      if (login == null) log.fine(this + " no Login for isUserInRole");
      else if (user == null) log.fine(this + " no user for isUserInRole");
      else if (inRole) log.fine(this + " " + user + " is in role: " + role);
      else log.fine(this + " failed " + user + " in role: " + role);
    }

    return inRole;
  }
示例#2
0
  /**
   * Sends a specific <tt>Request</tt> to the STUN server associated with this
   * <tt>StunCandidateHarvest</tt>.
   *
   * @param request the <tt>Request</tt> to send to the STUN server associated with this
   *     <tt>StunCandidateHarvest</tt>
   * @param firstRequest <tt>true</tt> if the specified <tt>request</tt> should be sent as the first
   *     request in the terms of STUN; otherwise, <tt>false</tt>
   * @return the <tt>TransactionID</tt> of the STUN client transaction through which the specified
   *     <tt>Request</tt> has been sent to the STUN server associated with this
   *     <tt>StunCandidateHarvest</tt>
   * @param transactionID the <tt>TransactionID</tt> of <tt>request</tt> because <tt>request</tt>
   *     only has it as a <tt>byte</tt> array and <tt>TransactionID</tt> is required for the
   *     <tt>applicationData</tt> property value
   * @throws StunException if anything goes wrong while sending the specified <tt>Request</tt> to
   *     the STUN server associated with this <tt>StunCandidateHarvest</tt>
   */
  protected TransactionID sendRequest(
      Request request, boolean firstRequest, TransactionID transactionID) throws StunException {
    if (!firstRequest && (longTermCredentialSession != null))
      longTermCredentialSession.addAttributes(request);

    StunStack stunStack = harvester.getStunStack();
    TransportAddress stunServer = harvester.stunServer;
    TransportAddress hostCandidateTransportAddress = hostCandidate.getTransportAddress();

    if (transactionID == null) {
      byte[] transactionIDAsBytes = request.getTransactionID();

      transactionID =
          (transactionIDAsBytes == null)
              ? TransactionID.createNewTransactionID()
              : TransactionID.createTransactionID(harvester.getStunStack(), transactionIDAsBytes);
    }
    synchronized (requests) {
      try {
        transactionID =
            stunStack.sendRequest(
                request, stunServer, hostCandidateTransportAddress, this, transactionID);
      } catch (IllegalArgumentException iaex) {
        if (logger.isLoggable(Level.INFO)) {
          logger.log(
              Level.INFO,
              "Failed to send "
                  + request
                  + " through "
                  + hostCandidateTransportAddress
                  + " to "
                  + stunServer,
              iaex);
        }
        throw new StunException(StunException.ILLEGAL_ARGUMENT, iaex.getMessage(), iaex);
      } catch (IOException ioex) {
        if (logger.isLoggable(Level.INFO)) {
          logger.log(
              Level.INFO,
              "Failed to send "
                  + request
                  + " through "
                  + hostCandidateTransportAddress
                  + " to "
                  + stunServer,
              ioex);
        }
        throw new StunException(StunException.NETWORK_ERROR, ioex.getMessage(), ioex);
      }

      requests.put(transactionID, request);
    }
    return transactionID;
  }
示例#3
0
  public void render(FacesContext context) throws FacesException {
    if (context.getResponseComplete()) return;

    Application app = context.getApplication();
    ViewHandler view = app.getViewHandler();

    beforePhase(context, PhaseId.RENDER_RESPONSE);

    try {
      if (log.isLoggable(Level.FINER)) log.finer(context.getViewRoot() + " before render view");

      view.renderView(context, context.getViewRoot());
    } catch (java.io.IOException e) {
      if (sendError(context, "renderView", e)) return;

      throw new FacesException(e);
    } catch (RuntimeException e) {
      if (sendError(context, "renderView", e)) return;

      throw e;
    } finally {
      afterPhase(context, PhaseId.RENDER_RESPONSE);

      logMessages(context);
    }
  }
示例#4
0
  /**
   * Creates a <tt>ServerReflexiveCandidate</tt> using {@link #hostCandidate} as its base and the
   * <tt>XOR-MAPPED-ADDRESS</tt> attribute in <tt>response</tt> for the actual
   * <tt>TransportAddress</tt> of the new candidate. If the message is malformed and/or does not
   * contain the corresponding attribute, this method simply has no effect.
   *
   * @param response the STUN <tt>Response</tt> which is supposed to contain the address we should
   *     use for the new candidate
   */
  protected void createServerReflexiveCandidate(Response response) {
    TransportAddress addr = getMappedAddress(response);

    if (addr != null) {
      ServerReflexiveCandidate srvrRflxCand = createServerReflexiveCandidate(addr);

      if (srvrRflxCand != null) {
        try {
          addCandidate(srvrRflxCand);
        } finally {
          // Free srvrRflxCand if it has not been consumed.
          if (!containsCandidate(srvrRflxCand)) {
            try {
              srvrRflxCand.free();
            } catch (Exception ex) {
              if (logger.isLoggable(Level.FINE)) {
                logger.log(
                    Level.FINE,
                    "Failed to free" + " ServerReflexiveCandidate: " + srvrRflxCand,
                    ex);
              }
            }
          }
        }
      }
    }
  }
  /**
   * Copies the properties of a specific <tt>DatagramPacket</tt> to another <tt>DatagramPacket</tt>.
   * The property values are not cloned.
   *
   * @param src the <tt>DatagramPacket</tt> which is to have its properties copied to <tt>dest</tt>
   * @param dest the <tt>DatagramPacket</tt> which is to have its properties set to the value of the
   *     respective properties of <tt>src</tt>
   */
  public static void copy(DatagramPacket src, DatagramPacket dest) {
    synchronized (dest) {
      dest.setAddress(src.getAddress());
      dest.setPort(src.getPort());

      byte[] srcData = src.getData();

      if (srcData == null) dest.setLength(0);
      else {
        byte[] destData = dest.getData();

        if (destData == null) dest.setLength(0);
        else {
          int destOffset = dest.getOffset();
          int destLength = destData.length - destOffset;
          int srcLength = src.getLength();

          if (destLength >= srcLength) destLength = srcLength;
          else if (logger.isLoggable(Level.WARNING)) {
            logger.log(Level.WARNING, "Truncating received DatagramPacket data!");
          }
          System.arraycopy(srcData, src.getOffset(), destData, destOffset, destLength);
          dest.setLength(destLength);
        }
      }
    }
  }
  @Override
  public boolean login(boolean isFail) {
    try {
      WebApp webApp = getWebApp();

      if (webApp == null) {
        if (log.isLoggable(Level.FINE)) log.finer("authentication failed, no web-app found");

        getResponse().sendError(HttpServletResponse.SC_FORBIDDEN);

        return false;
      }

      // If the authenticator can find the user, return it.
      Login login = webApp.getLogin();

      if (login != null) {
        Principal user = login.login(this, getResponse(), isFail);

        return user != null;
        /*
        if (user == null)
          return false;

        setAttribute(AbstractLogin.LOGIN_NAME, user);

        return true;
        */
      } else if (isFail) {
        if (log.isLoggable(Level.FINE))
          log.finer("authentication failed, no login module found for " + webApp);

        getResponse().sendError(HttpServletResponse.SC_FORBIDDEN);

        return false;
      } else {
        // if a non-failure, then missing login is fine

        return false;
      }
    } catch (IOException e) {
      log.log(Level.FINE, e.toString(), e);

      return false;
    }
  }
示例#7
0
  /**
   * Returns the current stream connection that is opened.
   *
   * @return a stream connection, can be a cached one, never <code>null</code>.
   * @throws IOException in case of I/O problems creating the stream connection.
   */
  private StreamConnection getStreamConnection() throws IOException {
    if (this.connection == null) {
      final String uri = this.config.getConnectionURI();

      if (LOG.isLoggable(Level.INFO)) {
        LOG.info("Connecting to " + uri);
      }

      this.connection = createStreamConnection(uri);
    }
    return this.connection;
  }
  /** Deserializes the object from XML */
  public Serializable fromXml(XmppStreamReader in) throws IOException, XMLStreamException {
    boolean isFinest = log.isLoggable(Level.FINEST);

    String type = in.getAttributeValue(null, "type");

    DataForm form = new DataForm(type);

    ArrayList<DataField> fieldList = new ArrayList<DataField>();
    ArrayList<DataItem> itemList = new ArrayList<DataItem>();
    ArrayList<DataInstructions> instructionsList = new ArrayList<DataInstructions>();

    int tag = in.nextTag();
    while (tag > 0) {
      if (isFinest) debug(in);

      if (XMLStreamReader.END_ELEMENT == tag) {
        form.setFieldList(fieldList);
        form.setItemList(itemList);
        form.setInstructionsList(instructionsList);

        return form;
      }

      if (XMLStreamReader.START_ELEMENT == tag && "field".equals(in.getLocalName())) {
        fieldList.add(parseField(in));
      } else if (XMLStreamReader.START_ELEMENT == tag && "item".equals(in.getLocalName())) {
        itemList.add(parseItem(in));
      } else if (XMLStreamReader.START_ELEMENT == tag && "reported".equals(in.getLocalName())) {
        form.setReported(parseReported(in));
      } else if (XMLStreamReader.START_ELEMENT == tag && "title".equals(in.getLocalName())) {
        String title = in.getElementText();

        form.setTitle(title);

        skipToEnd(in, "title");
      } else if (XMLStreamReader.START_ELEMENT == tag && "instructions".equals(in.getLocalName())) {
        String value = in.getElementText();

        instructionsList.add(new DataInstructions(value));

        skipToEnd(in, "instructions");
      } else if (XMLStreamReader.START_ELEMENT == tag) {
        log.finer(this + " <" + in.getLocalName() + "> is an unknown tag");

        skipToEnd(in, in.getLocalName());
      }

      tag = in.nextTag();
    }

    return null;
  }
示例#9
0
  /**
   * Sets the current device controller to the given value.
   *
   * @param aDeviceName the name of the device controller to set, cannot be <code>null</code>.
   */
  public synchronized void setDeviceController(final String aDeviceName) {
    if (LOG.isLoggable(Level.INFO)) {
      final String name = (aDeviceName == null) ? "no device" : aDeviceName;
      LOG.log(Level.INFO, "Setting current device controller to: \"{0}\" ...", name);
    }

    final Collection<DeviceController> devices = getDevices();
    for (DeviceController device : devices) {
      if (aDeviceName.equals(device.getName())) {
        this.currentDevCtrl = device;
      }
    }

    updateActions();
  }
示例#10
0
  /**
   * Runs the tool denoted by the given name.
   *
   * @param aToolName the name of the tool to run, cannot be <code>null</code>;
   * @param aParent the parent window to use, can be <code>null</code>.
   */
  public void runTool(final String aToolName, final Window aParent) {
    if (LOG.isLoggable(Level.INFO)) {
      LOG.log(Level.INFO, "Running tool: \"{0}\" ...", aToolName);
    }

    final Tool tool = findToolByName(aToolName);
    if (tool == null) {
      JOptionPane.showMessageDialog(
          aParent, "No such tool found: " + aToolName, "Error ...", JOptionPane.ERROR_MESSAGE);
    } else {
      final ToolContext context = createToolContext();
      tool.process(aParent, this.dataContainer, context, this);
    }

    updateActions();
  }
  public static void shutdownThreadPoolsNow() {
    try {
      ThreadPoolManager.shutdownAllNow();
    } catch (Throwable ex) {
      // Log info:
      {
        Level level = Level.SEVERE;
        Logger logger = log;
        if (logger.isLoggable(level)) {
          String message = "Failure to stop thread pools!";
          logger.log(level, message, ex);
        }
      }

      throw new RuntimeException(ex);
    }
  }
  protected void statFlush() {
    try {
      DSLDataAccessorFactory f = DefaultDSLDataAccessorFactory.getInstance();
      DSLDataAccessor a = f.getDSLDataAccessor();

      a.statFlush();
    } catch (Throwable ex) {
      // Log info:
      {
        Level level = Level.SEVERE;
        Logger logger = log;
        if (logger.isLoggable(level)) {
          String message = "Failure to flush statistical info!";
          logger.log(level, message, ex);
        }
      }
    }
  }
示例#13
0
  private void logMessages(FacesContext context) {
    UIViewRoot root = context.getViewRoot();
    String viewId = "";

    if (root != null) viewId = root.getViewId();

    Iterator<FacesMessage> iter = context.getMessages();

    while (iter != null && iter.hasNext()) {
      FacesMessage msg = iter.next();

      if (log.isLoggable(Level.FINE)) {
        if (msg.getDetail() != null)
          log.fine(
              viewId + " [ " + msg.getSeverity() + "] " + msg.getSummary() + " " + msg.getDetail());
        else log.fine(viewId + " [ " + msg.getSeverity() + "] " + msg.getSummary());
      }
    }
  }
  public boolean isRequestRecognizable(DSLAMProviderRequest request) throws IOException {
    boolean res = false;

    {
      Map<String, Object> systemProperties =
          DSLAMProviderUtil.readSNMPTargetSystemProperties(request);

      String[] subStrings = getSubStringForDetection();

      if (DSLAMProviderUtil.doesTargetSystemPropertiesContain(systemProperties, subStrings)) {
        res = true;
      }

      // Log result:
      {
        Logger logger = ProviderLog.getLogger();
        Level level = Level.FINE;
        if (logger.isLoggable(level)) {
          String message =
              "The result of request recognition for DSLAM \""
                  + request.getTarget()
                  + "\" against allocator \""
                  + getAllocatorName()
                  + "\" is: "
                  + res
                  + " (DSLAM-system-properties="
                  + systemProperties
                  + ", allocator-sub-strings="
                  + Arrays.toString(subStrings)
                  + ")!";
          logger.log(level, message);
        }
      }
    }

    return res;
  }
/**
 * DataForm
 *
 * <p>XEP-0004: http://www.xmpp.org/extensions/xep-0004.html <code><pre>
 * namespace = jabber:x:data
 *
 * element x {
 *   attribute type,
 *
 *   instructions*,
 *   title?,
 *   field*,
 *   reported?,
 *   item*
 * }
 *
 * element field {
 *    attribute label?,
 *    attribute type?,
 *    attribute var?,
 *
 *    desc?,
 *    required?,
 *    value*,
 *    option*,
 * }
 *
 * element item {
 *   field+
 * }
 *
 * element option {
 *   attribute label?,
 *
 *   value*
 * }
 *
 * element reported {
 *   field+
 * }
 *
 * element value {
 *   string
 * }
 * </pre></code>
 */
public class XmppDataFormMarshal extends AbstractXmppMarshal {
  private static final Logger log = Logger.getLogger(XmppDataFormMarshal.class.getName());
  private static final boolean _isFinest = log.isLoggable(Level.FINEST);

  /** Returns the namespace uri for the XMPP stanza value */
  public String getNamespaceURI() {
    return "jabber:x:data";
  }

  /** Returns the local name for the XMPP stanza value */
  public String getLocalName() {
    return "x";
  }

  /** Returns the java classname of the object */
  public String getClassName() {
    return DataForm.class.getName();
  }

  /** Serializes the object to XML */
  public void toXml(XmppStreamWriter out, Serializable object)
      throws IOException, XMLStreamException {
    DataForm form = (DataForm) object;

    out.writeStartElement("", getLocalName(), getNamespaceURI());
    out.writeNamespace("", getNamespaceURI());

    if (form.getType() != null) out.writeAttribute("type", form.getType());

    if (form.getTitle() != null) {
      out.writeStartElement("title");
      out.writeCharacters(form.getTitle());
      out.writeEndElement(); // </title>
    }

    DataInstructions[] instructions = form.getInstructions();
    if (instructions != null) {
      for (DataInstructions instruction : instructions) {
        toXml(out, instruction);
      }
    }

    DataField[] fields = form.getField();
    if (fields != null) {
      for (DataField field : fields) {
        toXml(out, field);
      }
    }

    if (form.getReported() != null) toXml(out, form.getReported());

    DataItem[] items = form.getItem();
    if (items != null) {
      for (DataItem item : items) {
        toXml(out, item);
      }
    }

    out.writeEndElement(); // </form>
  }

  private void toXml(XmppStreamWriter out, DataField field) throws IOException, XMLStreamException {
    out.writeStartElement("field");

    if (field.getLabel() != null) out.writeAttribute("label", field.getLabel());

    if (field.getType() != null) out.writeAttribute("type", field.getType());

    if (field.getVar() != null) out.writeAttribute("var", field.getVar());

    if (field.getDesc() != null) {
      out.writeStartElement("desc");
      out.writeCharacters(field.getDesc());
      out.writeEndElement(); // </desc>
    }

    if (field.isRequired()) {
      out.writeStartElement("required");
      out.writeEndElement(); // </required>
    }

    DataValue[] values = field.getValue();
    if (values != null) {
      for (int i = 0; i < values.length; i++) {
        DataValue value = values[i];

        out.writeStartElement("value");
        out.writeCharacters(value.getValue());
        out.writeEndElement(); // </value>
      }
    }

    DataOption[] options = field.getOption();
    if (options != null) {
      for (int i = 0; i < options.length; i++) {
        toXml(out, options[i]);
      }
    }

    out.writeEndElement(); // </field>
  }

  private void toXml(XmppStreamWriter out, DataOption option)
      throws IOException, XMLStreamException {
    out.writeStartElement("option");

    if (option.getLabel() != null) out.writeAttribute("label", option.getLabel());

    DataValue[] values = option.getValue();
    if (values != null) {
      for (int i = 0; i < values.length; i++) {
        DataValue value = values[i];

        out.writeStartElement("value");
        out.writeCharacters(value.getValue());
        out.writeEndElement(); // </value>
      }
    }

    out.writeEndElement(); // </option>
  }

  private void toXml(XmppStreamWriter out, DataItem item) throws IOException, XMLStreamException {
    out.writeStartElement("item");

    DataField[] fields = item.getField();
    if (fields != null) {
      for (int i = 0; i < fields.length; i++) {
        toXml(out, fields[i]);
      }
    }

    out.writeEndElement(); // </item>
  }

  private void toXml(XmppStreamWriter out, DataReported reported)
      throws IOException, XMLStreamException {
    out.writeStartElement("reported");

    DataField[] fields = reported.getField();
    if (fields != null) {
      for (int i = 0; i < fields.length; i++) {
        toXml(out, fields[i]);
      }
    }

    out.writeEndElement(); // </reported>
  }

  private void toXml(XmppStreamWriter out, DataInstructions instructions)
      throws IOException, XMLStreamException {
    out.writeStartElement("instructions");

    if (instructions.getValue() != null) out.writeCharacters(instructions.getValue());

    out.writeEndElement(); // </instructions>
  }

  /** Deserializes the object from XML */
  public Serializable fromXml(XmppStreamReader in) throws IOException, XMLStreamException {
    boolean isFinest = log.isLoggable(Level.FINEST);

    String type = in.getAttributeValue(null, "type");

    DataForm form = new DataForm(type);

    ArrayList<DataField> fieldList = new ArrayList<DataField>();
    ArrayList<DataItem> itemList = new ArrayList<DataItem>();
    ArrayList<DataInstructions> instructionsList = new ArrayList<DataInstructions>();

    int tag = in.nextTag();
    while (tag > 0) {
      if (isFinest) debug(in);

      if (XMLStreamReader.END_ELEMENT == tag) {
        form.setFieldList(fieldList);
        form.setItemList(itemList);
        form.setInstructionsList(instructionsList);

        return form;
      }

      if (XMLStreamReader.START_ELEMENT == tag && "field".equals(in.getLocalName())) {
        fieldList.add(parseField(in));
      } else if (XMLStreamReader.START_ELEMENT == tag && "item".equals(in.getLocalName())) {
        itemList.add(parseItem(in));
      } else if (XMLStreamReader.START_ELEMENT == tag && "reported".equals(in.getLocalName())) {
        form.setReported(parseReported(in));
      } else if (XMLStreamReader.START_ELEMENT == tag && "title".equals(in.getLocalName())) {
        String title = in.getElementText();

        form.setTitle(title);

        skipToEnd(in, "title");
      } else if (XMLStreamReader.START_ELEMENT == tag && "instructions".equals(in.getLocalName())) {
        String value = in.getElementText();

        instructionsList.add(new DataInstructions(value));

        skipToEnd(in, "instructions");
      } else if (XMLStreamReader.START_ELEMENT == tag) {
        log.finer(this + " <" + in.getLocalName() + "> is an unknown tag");

        skipToEnd(in, in.getLocalName());
      }

      tag = in.nextTag();
    }

    return null;
  }

  /** Deserializes the object from XML */
  public DataField parseField(XMLStreamReader in) throws IOException, XMLStreamException {
    String label = in.getAttributeValue(null, "label");
    String type = in.getAttributeValue(null, "type");
    String var = in.getAttributeValue(null, "var");

    DataField field = new DataField(type, var, label);

    ArrayList<DataValue> valueList = new ArrayList<DataValue>();
    ArrayList<DataOption> optionList = new ArrayList<DataOption>();

    int tag = in.nextTag();
    while (tag > 0) {
      if (_isFinest) debug(in);

      if (XMLStreamReader.END_ELEMENT == tag) {
        field.setValueList(valueList);
        field.setOptionList(optionList);

        return field;
      }

      if (XMLStreamReader.START_ELEMENT == tag && "desc".equals(in.getLocalName())) {
        String desc = in.getElementText();

        field.setDesc(desc);

        skipToEnd(in, "desc");
      } else if (XMLStreamReader.START_ELEMENT == tag && "option".equals(in.getLocalName())) {
        optionList.add(parseOption(in));
      } else if (XMLStreamReader.START_ELEMENT == tag && "required".equals(in.getLocalName())) {
        field.setRequired(true);

        skipToEnd(in, "required");
      } else if (XMLStreamReader.START_ELEMENT == tag && "value".equals(in.getLocalName())) {
        String value = in.getElementText();

        valueList.add(new DataValue(value));

        skipToEnd(in, "value");
      } else if (XMLStreamReader.START_ELEMENT == tag) {
        log.finer(this + " <" + in.getLocalName() + "> is an unknown tag");

        skipToEnd(in, in.getLocalName());
      }

      tag = in.nextTag();
    }

    skipToEnd(in, "field");

    return field;
  }

  /** Deserializes the object from XML */
  public DataItem parseItem(XMLStreamReader in) throws IOException, XMLStreamException {
    DataItem item = new DataItem();

    ArrayList<DataField> fieldList = new ArrayList<DataField>();

    int tag = in.nextTag();
    while (tag > 0) {
      if (_isFinest) debug(in);

      if (XMLStreamReader.END_ELEMENT == tag) {
        item.setFieldList(fieldList);

        return item;
      }

      if (XMLStreamReader.START_ELEMENT == tag && "field".equals(in.getLocalName())) {
        fieldList.add(parseField(in));
      } else if (XMLStreamReader.START_ELEMENT == tag) {
        log.finer(this + " <" + in.getLocalName() + "> is an unknown tag");

        skipToEnd(in, in.getLocalName());
      }

      tag = in.nextTag();
    }

    skipToEnd(in, "item");

    return item;
  }

  /** Deserializes the object from XML */
  public DataReported parseReported(XMLStreamReader in) throws IOException, XMLStreamException {
    DataReported reported = new DataReported();

    ArrayList<DataField> fieldList = new ArrayList<DataField>();

    int tag = in.nextTag();
    while (tag > 0) {
      if (_isFinest) debug(in);

      if (XMLStreamReader.END_ELEMENT == tag) {
        reported.setFieldList(fieldList);

        return reported;
      }

      if (XMLStreamReader.START_ELEMENT == tag && "field".equals(in.getLocalName())) {
        fieldList.add(parseField(in));
      } else if (XMLStreamReader.START_ELEMENT == tag) {
        log.finer(this + " <" + in.getLocalName() + "> is an unknown tag");

        skipToEnd(in, in.getLocalName());
      }

      tag = in.nextTag();
    }

    skipToEnd(in, "reported");

    return reported;
  }

  /** Deserializes the object from XML */
  public DataOption parseOption(XMLStreamReader in) throws IOException, XMLStreamException {
    String label = in.getAttributeValue(null, "label");

    DataOption option = new DataOption(label);

    ArrayList<DataValue> valueList = new ArrayList<DataValue>();

    int tag = in.nextTag();
    while (tag > 0) {
      if (_isFinest) debug(in);

      if (XMLStreamReader.END_ELEMENT == tag) {
        option.setValueList(valueList);

        return option;
      }

      if (XMLStreamReader.START_ELEMENT == tag && "value".equals(in.getLocalName())) {
        String value = in.getElementText();

        valueList.add(new DataValue(value));

        skipToEnd(in, "value");
      } else if (XMLStreamReader.START_ELEMENT == tag) {
        log.finer(this + " <" + in.getLocalName() + "> is an unknown tag");

        skipToEnd(in, in.getLocalName());
      }

      tag = in.nextTag();
    }

    skipToEnd(in, "option");

    return option;
  }
}
示例#16
0
  public void execute(FacesContext context) throws FacesException {
    boolean isFiner = log.isLoggable(Level.FINER);

    if (context.getResponseComplete() || context.getRenderResponse()) return;

    beforePhase(context, PhaseId.RESTORE_VIEW);

    try {
      if (isFiner) log.finer("JSF[] before restore view");

      restoreView(context);
    } finally {
      afterPhase(context, PhaseId.RESTORE_VIEW);
    }

    if (context.getResponseComplete() || context.getRenderResponse()) return;

    UIViewRoot viewRoot = context.getViewRoot();

    beforePhase(context, PhaseId.APPLY_REQUEST_VALUES);

    try {
      if (isFiner) log.finer(context.getViewRoot() + " before process decodes");

      viewRoot.processDecodes(context);
    } catch (RuntimeException e) {
      log.log(Level.WARNING, e.toString(), e);
    } finally {
      afterPhase(context, PhaseId.APPLY_REQUEST_VALUES);
    }

    //
    // Process Validations (processValidators)
    //

    if (context.getResponseComplete() || context.getRenderResponse()) return;

    beforePhase(context, PhaseId.PROCESS_VALIDATIONS);

    try {
      if (isFiner) log.finer(context.getViewRoot() + " before process validators");

      viewRoot.processValidators(context);
    } finally {
      afterPhase(context, PhaseId.PROCESS_VALIDATIONS);
    }

    //
    // Update Model Values (processUpdates)
    //

    if (context.getResponseComplete() || context.getRenderResponse()) return;

    beforePhase(context, PhaseId.UPDATE_MODEL_VALUES);

    try {
      if (isFiner) log.finer(context.getViewRoot() + " before process updates");

      viewRoot.processUpdates(context);
    } catch (RuntimeException e) {
      if (sendError(context, "processUpdates", e)) return;
    } finally {
      afterPhase(context, PhaseId.UPDATE_MODEL_VALUES);
    }

    //
    // Invoke Application (processApplication)
    //

    if (context.getResponseComplete() || context.getRenderResponse()) return;

    beforePhase(context, PhaseId.INVOKE_APPLICATION);

    try {
      if (isFiner) log.finer(context.getViewRoot() + " before process application");

      viewRoot.processApplication(context);
    } finally {
      afterPhase(context, PhaseId.INVOKE_APPLICATION);
    }
  }