Exemplo n.º 1
0
 private static ClaimBuildAction getClaimForRun(Run<?, ?> run) {
   ClaimBuildAction claimAction = null;
   List<ClaimBuildAction> claimActionList = run.getActions(ClaimBuildAction.class);
   if (claimActionList.size() == 1) {
     claimAction = claimActionList.get(0);
   } else if (claimActionList.size() > 1) {
     Log.warn("Multiple ClaimBuildActions found for job ");
   }
   return claimAction;
 }
 public static Object clone(Object object) throws CloneNotSupportedException {
   if (object == null) {
     throw new IllegalArgumentException("Null 'object' argument.");
   } else if (object instanceof PublicCloneable) {
     return ((PublicCloneable) object).clone();
   } else {
     try {
       Method method = object.getClass().getMethod("clone", (Class[]) null);
       if (Modifier.isPublic(method.getModifiers())) {
         return method.invoke(object, (Object[]) null);
       }
     } catch (NoSuchMethodException e) {
       Log.warn("Object without clone() method is impossible.");
     } catch (IllegalAccessException e2) {
       Log.warn("Object.clone(): unable to call method.");
     } catch (InvocationTargetException e3) {
       Log.warn("Object without clone() method is impossible.");
     }
     throw new CloneNotSupportedException("Failed to clone.");
   }
 }
Exemplo n.º 3
0
  private InterMineObject getRequestedObject(InterMineAPI im, HttpServletRequest request) {

    String idString = request.getParameter("id");
    Integer id = new Integer(Integer.parseInt(idString));
    ObjectStore os = im.getObjectStore();
    InterMineObject requestedObject = null;
    try {
      requestedObject = os.getObjectById(id);
    } catch (ObjectStoreException e) {
      Log.warn("Accessed report page with id: " + id + " but failed to find object.", e);
    }
    return requestedObject;
  }
Exemplo n.º 4
0
  /**
   * Performs the writing of a generic object.
   *
   * @param tagName the tag name.
   * @param object the generic object.
   * @param writer the writer.
   * @param mPlexAttribute ??.
   * @param mPlexValue ??.
   * @throws IOException if there is an I/O error.
   * @throws XMLWriterException if there is a writer error.
   */
  public void write(
      String tagName, Object object, XMLWriter writer, String mPlexAttribute, String mPlexValue)
      throws IOException, XMLWriterException {

    try {
      this.factory.readProperties(object);

      AttributeList attributes = new AttributeList();
      if (mPlexAttribute != null) {
        attributes.setAttribute(mPlexAttribute, mPlexValue);
      }
      AttributeDefinition[] attribDefs = this.factory.getAttributeDefinitions();
      ArrayList properties = new ArrayList();
      for (int i = 0; i < attribDefs.length; i++) {
        AttributeDefinition adef = attribDefs[i];
        String pName = adef.getAttributeName();
        Object propValue = this.factory.getProperty(adef.getPropertyName());
        if (propValue != null) {
          Log.debug("Here: " + this.factory.getBaseClass() + " -> " + adef.getPropertyName());
          String value = adef.getHandler().toAttributeValue(propValue);
          if (value != null) {
            attributes.setAttribute(pName, value);
          }
        }
        properties.add(adef.getPropertyName());
      }
      writer.writeTag(tagName, attributes, false);
      writer.startBlock();

      PropertyDefinition[] propertyDefs = this.factory.getPropertyDefinitions();
      RootXmlWriteHandler rootHandler = getRootHandler();
      for (int i = 0; i < propertyDefs.length; i++) {
        PropertyDefinition pDef = propertyDefs[i];
        String elementName = pDef.getElementName();
        // System.out.println("Searching: " + elementName + " [" + object.getClass() + "]");
        rootHandler.write(
            elementName,
            this.factory.getProperty(pDef.getPropertyName()),
            this.factory.getTypeForTagName(elementName),
            writer);
      }
      writer.endBlock();
      writer.writeCloseTag(tagName);
    } catch (ObjectDescriptionException ode) {
      Log.warn("Unable to write element", ode);
      throw new IOException(ode.getMessage());
    }
  }