Пример #1
0
  /** Creates a hudson.PluginStrategy, looking at the corresponding system property. */
  protected PluginStrategy createPluginStrategy() {
    String strategyName = System.getProperty(PluginStrategy.class.getName());
    if (strategyName != null) {
      try {
        Class<?> klazz = getClass().getClassLoader().loadClass(strategyName);
        Object strategy = klazz.getConstructor(PluginManager.class).newInstance(this);
        if (strategy instanceof PluginStrategy) {
          LOGGER.info("Plugin strategy: " + strategyName);
          return (PluginStrategy) strategy;
        } else {
          LOGGER.warning(
              "Plugin strategy (" + strategyName + ") is not an instance of hudson.PluginStrategy");
        }
      } catch (ClassNotFoundException e) {
        LOGGER.warning("Plugin strategy class not found: " + strategyName);
      } catch (Exception e) {
        LOGGER.log(
            WARNING,
            "Could not instantiate plugin strategy: "
                + strategyName
                + ". Falling back to ClassicPluginStrategy",
            e);
      }
      LOGGER.info("Falling back to ClassicPluginStrategy");
    }

    // default and fallback
    return new ClassicPluginStrategy(this);
  }
Пример #2
0
  public ResPackage loadMainPkg(ResTable resTable, ExtFile apkFile) throws AndrolibException {
    LOGGER.info("Loading resource table...");
    ResPackage[] pkgs = getResPackagesFromApk(apkFile, resTable, sKeepBroken);
    ResPackage pkg = null;

    switch (pkgs.length) {
      case 1:
        pkg = pkgs[0];
        break;
      case 2:
        if (pkgs[0].getName().equals("android")) {
          LOGGER.warning("Skipping \"android\" package group");
          pkg = pkgs[1];
        } else if (pkgs[0].getName().equals("com.htc")) {
          LOGGER.warning("Skipping \"htc\" stupid package group");
          pkg = pkgs[1];
        }
        break;
    }

    if (pkg == null) {
      throw new AndrolibException("Arsc files with zero or multiple packages");
    }

    resTable.addPackage(pkg, true);
    LOGGER.info("Loaded.");
    return pkg;
  }
Пример #3
0
 @Before
 public void setUp() throws Exception {
   File f = new File(new File(System.getProperty("user.home")), ".jenkins-ci.org");
   if (!f.exists()) {
     LOGGER.warning(f + " doesn't exist. Skipping JDK installation tests");
   } else {
     Properties prop = new Properties();
     FileInputStream in = new FileInputStream(f);
     try {
       prop.load(in);
       String u = prop.getProperty("oracle.userName");
       String p = prop.getProperty("oracle.password");
       if (u == null || p == null) {
         LOGGER.warning(
             f
                 + " doesn't contain oracle.userName and oracle.password. Skipping JDK installation tests.");
       } else {
         DescriptorImpl d = j.jenkins.getDescriptorByType(DescriptorImpl.class);
         d.doPostCredential(u, p);
       }
     } finally {
       in.close();
     }
   }
 }
  /**
   * @param username
   * @return
   * @throws UsernameNotFoundException
   * @throws DataAccessException
   */
  @Override
  public UserDetails loadUserByUsername(String username)
      throws UsernameNotFoundException, DataAccessException {
    UserDetails user = null;
    String connectionString;

    connectionString = "jdbc:mysql://" + myServer + "/" + myDatabase;
    LOGGER.info("MySQLSecurity: Connection String - " + connectionString);
    Connection conn = null;
    try {
      // Connect to the database
      Class.forName("com.mysql.jdbc.Driver").newInstance();
      conn = DriverManager.getConnection(connectionString, myUsername, myPassword);
      LOGGER.info("MySQLSecurity: Connection established.");

      // Prepare the statement and query the user table
      // TODO: Review userQuery to see if there's a better way to do this
      String userQuery = "SELECT * FROM " + myDataTable + " WHERE " + myUserField + " = ?";
      PreparedStatement statement = conn.prepareStatement(userQuery);
      // statement.setString(1, myDataTable);
      // statement.setString(2, myUserField);
      statement.setString(1, username);
      ResultSet results = statement.executeQuery();
      LOGGER.fine("MySQLSecurity: Query executed.");

      // Grab the first result (should be only user returned)
      if (results.first()) {
        // Build the user detail
        Set<GrantedAuthority> groups = new HashSet<GrantedAuthority>();
        groups.add(SecurityRealm.AUTHENTICATED_AUTHORITY);
        user =
            new MySQLUserDetail(
                username,
                results.getString(myPassField),
                true,
                true,
                true,
                true,
                groups.toArray(new GrantedAuthority[groups.size()]));
      } else {
        LOGGER.warning("MySQLSecurity: Invalid Username or Password");
        throw new UsernameNotFoundException("MySQL: User not found");
      }

    } catch (Exception e) {
      LOGGER.warning("MySQLSecurity Realm Error: " + e.getLocalizedMessage());
    } finally {
      if (conn != null) {
        try {
          conn.close();
          LOGGER.info("MySQLSecurity: Connection closed.");
        } catch (Exception ex) {
          /** Ignore any errors * */
        }
      }
    }
    return user;
  }
Пример #5
0
    /** Thread to handle incoming requests. */
    @Override
    public void run() {
      // start message queue
      while (!Thread.interrupted()) {
        try {
          // wait for new message
          Message msg = mQueuedMessageConnection.readMessage();

          mPongFlag = true;
          if (msg.getRequest() == Instruction.PONG) {
            continue;
          }

          // notify listeners
          for (Receiver r : mReceivers) {
            r.OnNewMessage(msg);
          }
        }
        // The thread was interrupted
        catch (InterruptedIOException ex) {
          LOGGER.warning(ex.getMessage());
          mWorkerQueue.add(
              new Runnable() {
                public void run() {
                  _disconnect();
                  if (mConnectEnabled) {
                    _connect();
                  }
                }
              });
          return;
        }
        // The socket was close of any reason
        catch (IOException ex) {
          LOGGER.warning(ex.getMessage());
          mWorkerQueue.add(
              new Runnable() {
                public void run() {
                  _disconnect();
                  if (mConnectEnabled) {
                    _connect();
                  }
                }
              });
          return;
        }
      }
      LOGGER.log(Level.INFO, "[[MessageReceiver THREAD done]]");

      mWorkerQueue.add(
          new Runnable() {
            public void run() {
              _disconnect();
            }
          });
    }
Пример #6
0
  @Override
  public ReferencedEnvelope getBounds() {
    try {
      ReferencedEnvelope bounds = featureSource.getBounds();
      if (bounds != null) {
        FeatureType schema = featureSource.getSchema();
        CoordinateReferenceSystem schemaCrs = schema.getCoordinateReferenceSystem();
        CoordinateReferenceSystem boundsCrs = bounds.getCoordinateReferenceSystem();

        if (boundsCrs == null && schemaCrs != null) {
          LOGGER.warning(
              "Bounds crs not defined; assuming bounds from schema are correct for "
                  + featureSource);
          bounds =
              new ReferencedEnvelope(
                  bounds.getMinX(),
                  bounds.getMaxX(),
                  bounds.getMinY(),
                  bounds.getMaxY(),
                  schemaCrs);
        }
        if (boundsCrs != null
            && schemaCrs != null
            && !CRS.equalsIgnoreMetadata(boundsCrs, schemaCrs)) {
          LOGGER.warning(
              "Bounds crs and schema crs are not consistent; forcing the use of the schema crs so they are consistent");
          // bounds = bounds.transform(schemaCrs, true );
          bounds =
              new ReferencedEnvelope(
                  bounds.getMinX(),
                  bounds.getMaxX(),
                  bounds.getMinY(),
                  bounds.getMaxY(),
                  schemaCrs);
        }
        return bounds;
      }
    } catch (IOException e) {
      // feature bounds unavailable
    }

    CoordinateReferenceSystem crs = featureSource.getSchema().getCoordinateReferenceSystem();
    if (crs != null) {
      // returns the envelope based on the CoordinateReferenceSystem
      Envelope envelope = CRS.getEnvelope(crs);
      if (envelope != null) {
        return new ReferencedEnvelope(envelope); // nice!
      } else {
        return new ReferencedEnvelope(crs); // empty bounds
      }
    } else {
      return null; // unknown
    }
  }
 private void warnOnUnsupportedOptions(Map<String, List<String>> optionsMap) {
   for (String key : optionsMap.keySet()) {
     if (!allKeys.contains(key)) {
       LOGGER.warning("Unknown or Unsupported Option '" + key + "'");
     }
   }
 }
Пример #8
0
  public void updateStatistics(Request request, boolean cachedResponse) {
    URI proxyUri = null;
    try {
      proxyUri = new URI(request.getOptions().getProxyURI());
    } catch (URISyntaxException e) {
      LOGGER.warning(String.format("Proxy-uri malformed: %s", request.getOptions().getProxyURI()));
    }

    if (proxyUri == null) {
      // throw new IllegalArgumentException("proxyUri == null");
      return;
    }

    // manage the address requester
    String addressString = proxyUri.getHost();
    if (addressString != null) {
      // manage the resource requested
      String resourceString = proxyUri.getPath();
      if (resourceString != null) {
        // check if there is already an entry for the row/column
        // association
        StatHelper statHelper = statsTable.get(addressString, resourceString);
        if (statHelper == null) {
          // create a new stat if it not present
          statHelper = new StatHelper();

          // add the new element to the table
          statsTable.put(addressString, resourceString, statHelper);
        }

        // increment the count of the requests
        statHelper.increment(cachedResponse);
      }
    }
  }
    @Override
    protected void projectOpened() {
      GradleModelLoader.addModelLoadedListener(modelLoadListener);
      reloadProject(true);

      if (licenseChangeListener != null) {
        LOGGER.warning("projectOpened() without close.");
        properties.getLicenseHeader().removeChangeListener(licenseChangeListener);
      }

      licenseChangeListener =
          new ChangeListener() {
            @Override
            public void stateChanged(ChangeEvent e) {
              registerLicense();
            }
          };
      properties.getLicenseHeader().addChangeListener(licenseChangeListener);

      SwingUtilities.invokeLater(
          new Runnable() {
            @Override
            public void run() {
              opened = true;
              registerLicenseNow();
            }
          });
    }
Пример #10
0
  @Test
  public void testPostAsJSON() throws Exception {
    if (!RemoteOWSTestSupport.isRemoteWMSStatesAvailable(LOGGER)) {
      LOGGER.warning("Skipping layer posting test as remote server is not available");
      return;
    }

    assertNull(catalog.getResourceByName("sf", "bugsites", WMSLayerInfo.class));

    String json =
        "{"
            + "'wmsLayer':{"
            + "'name':'bugsites',"
            + "'nativeName':'og:bugsites',"
            + "'srs':'EPSG:4326',"
            + "'nativeCRS':'EPSG:4326',"
            + "'store':'demo'"
            + "}"
            + "}";
    MockHttpServletResponse response =
        postAsServletResponse("/rest/workspaces/sf/wmsstores/demo/wmslayers/", json, "text/json");

    assertEquals(201, response.getStatusCode());
    assertNotNull(response.getHeader("Location"));
    assertTrue(
        response
            .getHeader("Location")
            .endsWith("/workspaces/sf/wmsstores/demo/wmslayers/bugsites"));

    WMSLayerInfo layer = catalog.getResourceByName("sf", "bugsites", WMSLayerInfo.class);
    assertNotNull(layer.getNativeBoundingBox());
  }
Пример #11
0
  private Object getValue(
      final ValueNode node, Object metadata, Map<String, Set<Object>> excluded, boolean overwrite)
      throws ParseException {
    if (metadata instanceof AbstractMetadata
        && !(metadata instanceof Period)
        && !(metadata instanceof Instant)) {
      Object obj = asFullMap(metadata).get(node.name);
      if (obj instanceof Collection) {
        final Collection result = new ArrayList<>();
        final Iterator it = ((Collection) obj).iterator();
        while (it.hasNext()) {
          final Object o = getSingleValue(node, it.next(), excluded, overwrite);
          if (o != null) result.add(o);
        }
        return result;
      } else {
        return getSingleValue(node, obj, excluded, overwrite);
      }
    } else if (metadata instanceof Collection && ((Collection) metadata).isEmpty()) {
      return null;

    } else if (metadata != null) {
      // TODO filter : type, default value, etc...
      final Method getter = ReflectionUtilities.getGetterFromName(node.name, metadata.getClass());
      if (getter != null) {
        return ReflectionUtilities.invokeMethod(metadata, getter);
      }
      LOGGER.warning(
          "Unable to find:" + metadata.getClass().getName() + " getter for:" + node.name);
      return null;

    } else {
      return null;
    }
  }
Пример #12
0
 public void buildSources(File appDir) throws AndrolibException {
   if (!buildSourcesRaw(appDir, "classes.dex")
       && !buildSourcesSmali(appDir, "smali", "classes.dex")
       && !buildSourcesJava(appDir)) {
     LOGGER.warning("Could not find sources");
   }
 }
Пример #13
0
  @Test
  public void testPostAsXML() throws Exception {
    if (!RemoteOWSTestSupport.isRemoteWMSStatesAvailable(LOGGER)) {
      LOGGER.warning("Skipping layer posting test as remote server is not available");
      return;
    }

    assertNull(catalog.getResourceByName("sf", "bugsites", WMSLayerInfo.class));

    String xml =
        "<wmsLayer>"
            + "<name>bugsites</name>"
            + "<nativeName>og:bugsites</nativeName>"
            + "<srs>EPSG:4326</srs>"
            + "<nativeCRS>EPSG:4326</nativeCRS>"
            + "<store>demo</store>"
            + "</wmsLayer>";
    MockHttpServletResponse response =
        postAsServletResponse("/rest/workspaces/sf/wmsstores/demo/wmslayers/", xml, "text/xml");

    assertEquals(201, response.getStatusCode());
    assertNotNull(response.getHeader("Location"));
    assertTrue(
        response
            .getHeader("Location")
            .endsWith("/workspaces/sf/wmsstores/demo/wmslayers/bugsites"));

    WMSLayerInfo layer = catalog.getResourceByName("sf", "bugsites", WMSLayerInfo.class);
    assertNotNull(layer.getNativeBoundingBox());
  }
  protected static final String getDefaultAction(JavaMethod method) {
    String tns = method.getOwner().getTargetNamespace();
    String delim = "/";
    // TODO: is this the correct way to find the separator ?
    try {
      URI uri = new URI(tns);
      if (uri.getScheme().equalsIgnoreCase("urn")) delim = ":";
    } catch (URISyntaxException e) {
      LOGGER.warning("TargetNamespace of WebService is not a valid URI");
    }
    if (tns.endsWith(delim)) tns = tns.substring(0, tns.length() - 1);
    // this assumes that fromjava case there won't be input name.
    // if there is input name in future, then here name=inputName
    // else use operation name as follows.
    String name =
        (method.getMEP().isOneWay())
            ? method.getOperationName()
            : method.getOperationName() + "Request";

    return new StringBuilder(tns)
        .append(delim)
        .append(method.getOwner().getPortTypeName().getLocalPart())
        .append(delim)
        .append(name)
        .toString();
  }
Пример #15
0
  private void scan(String pattern) {
    LOGGER.fine("Scanning " + pattern + " for hs_err_pid files");

    pattern = pattern.replace("%p", "*").replace("%%", "%");
    File f = new File(pattern).getAbsoluteFile();
    if (!pattern.contains("*")) scanFile(f);
    else { // GLOB
      File commonParent = f;
      while (commonParent != null && commonParent.getPath().contains("*")) {
        commonParent = commonParent.getParentFile();
      }
      if (commonParent == null) {
        LOGGER.warning("Failed to process " + f);
        return; // huh?
      }

      FileSet fs =
          Util.createFileSet(
              commonParent, f.getPath().substring(commonParent.getPath().length() + 1), null);
      DirectoryScanner ds = fs.getDirectoryScanner(new Project());
      for (String child : ds.getIncludedFiles()) {
        scanFile(new File(commonParent, child));
      }
    }
  }
    private ClientConnection getOrWaitForCreation() throws IOException {
      ClientNetworkConfig networkConfig = client.getClientConfig().getNetworkConfig();
      long connectionAttemptLimit = networkConfig.getConnectionAttemptLimit();
      long connectionAttemptPeriod = networkConfig.getConnectionAttemptPeriod();
      long waitTime = connectionAttemptLimit * connectionAttemptPeriod * 2;
      if (waitTime < 0) {
        waitTime = Long.MAX_VALUE;
      }

      final ClientConnection currentOwnerConnection = ownerConnection;
      if (currentOwnerConnection != null) {
        return currentOwnerConnection;
      }

      long remainingWait = waitTime;
      synchronized (ownerConnectionLock) {
        long waitStart = System.currentTimeMillis();
        while (ownerConnection == null && remainingWait > 0) {
          try {
            ownerConnectionLock.wait(remainingWait);
            remainingWait = waitTime - (System.currentTimeMillis() - waitStart);
          } catch (InterruptedException e) {
            throw new IOException(e);
          }
        }
        if (ownerConnection == null) {
          LOGGER.warning("Wait for owner connection is timed out");
          throw new IOException("Wait for owner connection is timed out");
        }
        return ownerConnection;
      }
    }
Пример #17
0
    @Override
    public void run() {
      try {
        RingBuffer<byte[]> ringBuffer = disruptor.getRingBuffer();
        long previousRate = 0;

        // Warm up
        if (!sendMessages(ringBuffer, rate, 30)) {
          LOGGER.warning("Failed during warmup");
          return;
        }

        while (true) {
          if (sendMessages(ringBuffer, rate, 10)) {
            previousRate = rate;
            rate *= 2;
          } else {
            LOGGER.info("Failed at: " + rate + " messages per second");
            break;
          }
        }

        long upperBound = rate;
        long lowerBound = previousRate;

        while (true) {
          long newRate = (upperBound + lowerBound) / 2;
          long rateDelta = newRate - rate;

          if (-16 < rateDelta && rateDelta < 16) {
            LOGGER.info("Stable at: " + rate + " messages per second");
            return;
          }

          previousRate = rate;
          rate = newRate;

          if (sendMessages(ringBuffer, rate, 10)) {
            lowerBound = rate;
          } else {
            upperBound = rate;
          }
        }
      } catch (InterruptedException e) {
        LOGGER.warning("Exiting...");
      }
    }
Пример #18
0
 public void buildResources(ExtFile appDir, Map<String, Object> usesFramework)
     throws BrutException {
   if (!buildResourcesRaw(appDir)
       && !buildResourcesFull(appDir, usesFramework)
       && !buildManifest(appDir, usesFramework)) {
     LOGGER.warning("Could not find resources");
   }
 }
Пример #19
0
 /**
  * return parameter description, applying the configured MarkupFormatter for jenkins instance.
  *
  * @since 1.521
  */
 public String getFormattedDescription() {
   try {
     return Jenkins.getInstance().getMarkupFormatter().translate(description);
   } catch (IOException e) {
     LOGGER.warning("failed to translate description using configured markup formatter");
     return "";
   }
 }
Пример #20
0
  /**
   * Retrieves the build number of this CloudTest server. Postcondition: The build number returned
   * is never null.
   */
  public VersionNumber getBuildNumber() throws IOException {
    if (url == null) {
      // User didn't enter a value in the Configure Jenkins page.
      // Nothing we can do.
      throw new IllegalStateException("No URL has been configured for this CloudTest server.");
    }

    final String[] v = new String[1];
    try {
      HttpClient hc = createClient();

      GetMethod get = new GetMethod(url);
      hc.executeMethod(get);

      if (get.getStatusCode() != 200) {
        throw new IOException(get.getStatusLine().toString());
      }

      SAXParser sp = SAXParserFactory.newInstance().newSAXParser();
      sp.parse(
          get.getResponseBodyAsStream(),
          new DefaultHandler() {
            @Override
            public InputSource resolveEntity(String publicId, String systemId)
                throws IOException, SAXException {
              if (systemId.endsWith(".dtd")) return new InputSource(new StringReader(""));
              return null;
            }

            @Override
            public void startElement(
                String uri, String localName, String qName, Attributes attributes)
                throws SAXException {
              if (qName.equals("meta")) {
                if ("buildnumber".equals(attributes.getValue("name"))) {
                  v[0] = attributes.getValue("content");
                  throw new SAXException("found");
                }
              }
            }
          });
      LOGGER.warning("Build number not found in " + url);
    } catch (SAXException e) {
      if (v[0] != null) return new VersionNumber(v[0]);

      LOGGER.log(Level.WARNING, "Failed to load " + url, e);
    } catch (ParserConfigurationException e) {
      throw new Error(e);
    }

    // If we reach this point, then we failed to extract the build number.
    throw new IOException(
        "Failed to extract build number from \'"
            + this.getDescriptor().getDisplayName()
            + "\': <"
            + url
            + ">.");
  }
Пример #21
0
  @Override
  protected void doGet(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    InputStream is = null;
    BufferedInputStream bis = null;
    File artifactFile = null;
    ArtifactDownloadFuture masterFuture = null;

    try {
      String path = req.getPathInfo();
      if (path != null && path.startsWith("/")) {
        path = path.substring(1);
      }

      try {
        ArtifactDownloadFuture future = new ArtifactDownloadFuture(path);
        masterFuture = requestMap.putIfAbsent(path, future);
        if (masterFuture == null) {
          masterFuture = future;
          executorService.submit(future);
          artifactFile = masterFuture.get();
        } else {
          artifactFile = masterFuture.get();
        }

        requestMap.remove(path);
        if (artifactFile == null) {
          resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
          return;
        }

        is = new FileInputStream(artifactFile);
        LOGGER.log(Level.INFO, String.format("Writing response for file : %s", path));
        resp.setStatus(HttpServletResponse.SC_OK);
        resp.setContentType("application/octet-stream");
        resp.setDateHeader("Date", System.currentTimeMillis());
        resp.setHeader("Connection", "close");
        resp.setContentLength(is.available());
        resp.setHeader("Server", "MavenProxy Proxy/" + FabricConstants.FABRIC_VERSION);
        byte buffer[] = new byte[8192];
        int length;
        while ((length = is.read(buffer)) != -1) {
          resp.getOutputStream().write(buffer, 0, length);
        }
        resp.getOutputStream().flush();
      } catch (Exception ex) {
        LOGGER.warning("Error while downloading artifact:" + ex.getMessage());
      } finally {
        Closeables.closeQuitely(is);
        if (masterFuture != null && artifactFile != null) {
          masterFuture.release(artifactFile);
        }
      }
    } catch (Exception ex) {
      resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    }
  }
Пример #22
0
 /**
  * Rename a legacy file to a new name, with care to Windows where {@link File#renameTo(File)}
  * doesn't work if the destination already exists.
  */
 private void rename(File legacyFile, File newFile) throws IOException {
   if (!legacyFile.exists()) return;
   if (newFile.exists()) {
     Util.deleteFile(newFile);
   }
   if (!legacyFile.renameTo(newFile)) {
     LOGGER.warning("Failed to rename " + legacyFile + " to " + newFile);
   }
 }
Пример #23
0
 /**
  * Look out for a typical error a plugin developer makes. See
  * http://hudson.361315.n4.nabble.com/Help-Hint-needed-Post-build-action-doesn-t-stay-activated-td2308833.html
  */
 private T verifyNewInstance(T t) {
   if (t != null && t.getDescriptor() != this) {
     // TODO: should this be a fatal error?
     LOGGER.warning(
         "Father of "
             + t
             + " and its getDescriptor() points to two different instances. Probably malplaced @Extension. See http://hudson.361315.n4.nabble.com/Help-Hint-needed-Post-build-action-doesn-t-stay-activated-td2308833.html");
   }
   return t;
 }
Пример #24
0
  @Override
  public Class<?> getMapping(ResultSet columnMetaData, Connection cx) throws SQLException {

    String typeName = columnMetaData.getString("TYPE_NAME");
    if ("UUID".equalsIgnoreCase(typeName)) {
      return UUID.class;
    } else if ("BLOB".equalsIgnoreCase(typeName)) {
      String schemaName = columnMetaData.getString("TABLE_SCHEM");
      String tableName = columnMetaData.getString("TABLE_NAME");
      String columnName = columnMetaData.getString("COLUMN_NAME");

      // look up in geometry columns table
      StringBuffer sql = new StringBuffer("SELECT type FROM geometry_columns WHERE ");
      if (schemaName != null) {
        sql.append("f_table_schema = '").append(schemaName).append("'").append(" AND ");
      }
      sql.append("f_table_name = '").append(tableName).append("' AND ");
      sql.append("f_geometry_column = '").append(columnName).append("'");

      Statement st = cx.createStatement();
      try {
        LOGGER.fine(sql.toString());
        ResultSet rs = st.executeQuery(sql.toString());
        try {
          if (rs.next()) {
            String type = rs.getString(1);
            Geometries g = Geometries.getForName(type);
            if (g != null) {
              return g.getBinding();
            }
            LOGGER.warning("Geometry type " + type + " not supported.");
          }
        } finally {
          dataStore.closeSafe(rs);
        }
      } finally {
        dataStore.closeSafe(st);
      }

      // not a geometry blob, return byte[].class
      return byte[].class;
    }

    // do a check for a column remark which marks this as a geometry
    // do this mostly for backwards compatability
    String remark = columnMetaData.getString("REMARKS");
    if (remark != null) {
      Geometries g = Geometries.getForName(remark);
      if (g != null) {
        return g.getBinding();
      }
    }

    return null;
  }
 /**
  * Marks the given node as offline if free disk space is below the configured threshold.
  *
  * @param c the node
  * @return the free space
  * @since 1.521
  */
 @Restricted(NoExternalUse.class)
 public DiskSpace markNodeOfflineIfDiskspaceIsTooLow(Computer c) {
   DiskSpace size = (DiskSpace) super.data(c);
   if (size != null && size.size < getThresholdBytes()) {
     size.setTriggered(this.getClass(), true);
     if (getDescriptor().markOffline(c, size)) {
       LOGGER.warning(Messages.DiskSpaceMonitor_MarkedOffline(c.getName()));
     }
   }
   return size;
 }
Пример #26
0
 @Override
 protected ImageIcon doInBackground() throws Exception {
   ImageIcon loadedIcon;
   try {
     loadedIcon = new ImageIcon(new URL(url));
   } catch (MalformedURLException ex) {
     LOGGER.warning("Invalid url for " + search + ": " + url);
     return null;
   }
   return loadedIcon;
 }
Пример #27
0
  /**
   * Checks the bounds process returned the expected envelope
   *
   * @param request
   * @param id
   * @throws Exception
   */
  void executeState1BoundsTest(String request, String id) throws Exception {
    if (!RemoteOWSTestSupport.isRemoteWMSStatesAvailable(LOGGER)) {
      LOGGER.warning("Remote OWS tests disabled, skipping test with " + id + " reference source");
      return;
    }

    MockHttpServletResponse resp = postAsServletResponse(root(), request);
    ReferencedEnvelope re = toEnvelope(resp.getOutputStreamContent());
    assertEquals(-91.516129, re.getMinX(), 0.001);
    assertEquals(36.986771, re.getMinY(), 0.001);
    assertEquals(-87.507889, re.getMaxX(), 0.001);
    assertEquals(42.509361, re.getMaxY(), 0.001);
  }
Пример #28
0
  @Test
  public void testGetAllAvailable() throws Exception {
    if (!RemoteOWSTestSupport.isRemoteWMSStatesAvailable(LOGGER)) {
      LOGGER.warning("Skipping layer availability test as remote server is not available");
      return;
    }

    Document dom = getAsDOM("/rest/workspaces/sf/wmsstores/demo/wmslayers.xml?list=available");
    // print(dom);

    // can't control the demo server enough to check the type names, but it should have something
    // more than just topp:states
    assertXpathEvaluatesTo("true", "count(//wmsLayerName) > 0", dom);
  }
Пример #29
0
 @Override
 public void run() {
   // if pong was received, ok, send new ping
   if (mPongFlag) {
     mPongFlag = false;
     LOGGER.warning("Ping sent...");
     sendMessage(new Message(Instruction.PING));
   }
   // if no pong was received, we assume a timeout and reconnect
   else {
     LOGGER.warning("Pong timed out, restarting connection.");
     cancel();
     mWorkerQueue.add(
         new Runnable() {
           public void run() {
             _disconnect();
             if (mConnectEnabled) {
               _connect();
             }
           }
         });
   }
 }
Пример #30
0
 /**
  * Method remove
  *
  * @param node
  */
 public void removeNode(WebNode node) {
   storableNodes.add(node);
   if (storableNodes.size() >= config.getBatchSize()) {
     long start = System.currentTimeMillis(); // Counter
     getQuery().storeVertices(storableNodes);
     storableNodes.clear();
     timeStoreVertices += System.currentTimeMillis() - start; // Counter
   }
   if (removedNodeIds.contains(node.getId())) {
     LOGGER.warning("Node: " + node.getId() + " already removed");
   } else {
     nodes.remove(node.getId());
     removedNodeIds.add(node.getId());
   }
 }