List of usage examples for java.util Vector isEmpty
public synchronized boolean isEmpty()
From source file:com.brightcove.test.upload.HLS.Encrypted.HLSEncryptionIntegrationTest.java
/** * Verify the SSL Enforcement Check on Rendition URL * @throws MediaAPIError //w w w . j a v a 2 s .c o m */ @Test public void testSSLEnforcementCheckOnRenditionURL() throws MediaAPIError { setOriginAttributes(mEnvironment, hlsConfig.getAttributesForSSLEnformentCheckOnRendition()); setGobblesEdgeAttributes(mEnvironment, hlsConfig.getAttributesForSSLGobblesConfig()); Vector rendition = retriveRenditionURL(mAccountInfo, mEnvironment, videoId); if (!rendition.isEmpty()) { AppleStreamingCheck appleCheck = new AppleStreamingCheck(); appleCheck.assetEnforcementCheck(rendition); } }
From source file:com.brightcove.test.upload.HLS.Encrypted.HLSEncryptionIntegrationTest.java
/** * Test does following checks 1. Verify the output when TTL Token on rendition is valid 2. * Verify the Rendition url has SSL support 3. Verify the output when TTL Token on rendition URL * are expired//www . j a v a 2 s . com * @throws MediaAPIError */ @Test public void testSSLTTLOnRendition() throws MediaAPIError { setOriginAttributes(mEnvironment, hlsConfig.getAttributesAllRenditionSSLTTL()); setGobblesEdgeAttributes(mEnvironment, hlsConfig.getAttributesForTTLSSLGobblesConfig()); AppleStreamingCheck appleCheck = new AppleStreamingCheck(); Vector rendition = retriveRenditionURL(mAccountInfo, mEnvironment, videoId); if (!rendition.isEmpty()) { appleCheck.assertTTL(rendition); appleCheck.assertURLAreSSLSecured(rendition); appleCheck.assertTTLExpiration(rendition); } }
From source file:edu.umn.cs.spatialHadoop.nasa.MultiHDFPlot.java
public static boolean multiplot(Path[] input, Path output, OperationsParams params) throws IOException, InterruptedException, ClassNotFoundException, ParseException { String timeRange = params.get("time"); final Date dateFrom, dateTo; final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy.MM.dd"); try {/*from w w w . j a va 2 s. c om*/ String[] parts = timeRange.split("\\.\\."); dateFrom = dateFormat.parse(parts[0]); dateTo = dateFormat.parse(parts[1]); } catch (ArrayIndexOutOfBoundsException e) { System.err.println("Use the seperator two periods '..' to seperate from and to dates"); return false; // To avoid an error that causes dateFrom to be uninitialized } catch (ParseException e) { System.err.println("Illegal date format in " + timeRange); return false; } // Number of frames to combine in each image int combine = params.getInt("combine", 1); // Retrieve all matching input directories based on date range Vector<Path> matchingPathsV = new Vector<Path>(); for (Path inputFile : input) { FileSystem inFs = inputFile.getFileSystem(params); FileStatus[] matchingDirs = inFs.listStatus(input, new PathFilter() { @Override public boolean accept(Path p) { String dirName = p.getName(); try { Date date = dateFormat.parse(dirName); return date.compareTo(dateFrom) >= 0 && date.compareTo(dateTo) <= 0; } catch (ParseException e) { LOG.warn("Cannot parse directory name: " + dirName); return false; } } }); for (FileStatus matchingDir : matchingDirs) matchingPathsV.add(new Path(matchingDir.getPath(), "*.hdf")); } if (matchingPathsV.isEmpty()) { LOG.warn("No matching directories to given input"); return false; } Path[] matchingPaths = matchingPathsV.toArray(new Path[matchingPathsV.size()]); Arrays.sort(matchingPaths); // Clear all paths to ensure we set our own paths for each job params.clearAllPaths(); // Create a water mask if we need to recover holes on write if (params.get("recover", "none").equals("write")) { // Recover images on write requires a water mask image to be generated first OperationsParams wmParams = new OperationsParams(params); wmParams.setBoolean("background", false); Path wmImage = new Path(output, new Path("water_mask")); HDFPlot.generateWaterMask(wmImage, wmParams); params.set(HDFPlot.PREPROCESSED_WATERMARK, wmImage.toString()); } // Start a job for each path int imageWidth = -1; int imageHeight = -1; boolean overwrite = params.getBoolean("overwrite", false); boolean pyramid = params.getBoolean("pyramid", false); FileSystem outFs = output.getFileSystem(params); Vector<Job> jobs = new Vector<Job>(); boolean background = params.getBoolean("background", false); Rectangle mbr = new Rectangle(-180, -90, 180, 90); for (int i = 0; i < matchingPaths.length; i += combine) { Path[] inputPaths = new Path[Math.min(combine, matchingPaths.length - i)]; System.arraycopy(matchingPaths, i, inputPaths, 0, inputPaths.length); Path outputPath = new Path(output, inputPaths[0].getParent().getName() + (pyramid ? "" : ".png")); if (overwrite || !outFs.exists(outputPath)) { // Need to plot Job rj = HDFPlot.plotHeatMap(inputPaths, outputPath, params); if (imageHeight == -1 || imageWidth == -1) { if (rj != null) { imageHeight = rj.getConfiguration().getInt("height", 1000); imageWidth = rj.getConfiguration().getInt("width", 1000); mbr = (Rectangle) OperationsParams.getShape(rj.getConfiguration(), "mbr"); } else { imageHeight = params.getInt("height", 1000); imageWidth = params.getInt("width", 1000); mbr = (Rectangle) OperationsParams.getShape(params, "mbr"); } } if (background && rj != null) jobs.add(rj); } } // Wait until all jobs are done while (!jobs.isEmpty()) { Job firstJob = jobs.firstElement(); firstJob.waitForCompletion(false); if (!firstJob.isSuccessful()) { System.err.println("Error running job " + firstJob.getJobID()); System.err.println("Killing all remaining jobs"); for (int j = 1; j < jobs.size(); j++) jobs.get(j).killJob(); throw new RuntimeException("Error running job " + firstJob.getJobID()); } jobs.remove(0); } // Draw the scale in the output path if needed String scalerange = params.get("scalerange"); if (scalerange != null) { String[] parts = scalerange.split("\\.\\."); double min = Double.parseDouble(parts[0]); double max = Double.parseDouble(parts[1]); String scale = params.get("scale", "none").toLowerCase(); if (scale.equals("vertical")) { MultiHDFPlot.drawVerticalScale(new Path(output, "scale.png"), min, max, 64, imageHeight, params); } else if (scale.equals("horizontal")) { MultiHDFPlot.drawHorizontalScale(new Path(output, "scale.png"), min, max, imageWidth, 64, params); } } // Add the KML file createKML(outFs, output, mbr, params); return true; }
From source file:cc.wulian.smarthomev5.fragment.singin.handler.DecodeThread.java
public DecodeThread(IQRScanHandlerResult scanHandlerResult, Vector<BarcodeFormat> decodeFormats, String characterSet) {/* w w w.j a v a 2 s. com*/ this.scanHandlerResult = scanHandlerResult; handlerInitLatch = new CountDownLatch(1); hints = new Hashtable<DecodeHintType, Object>(1); if (decodeFormats == null || decodeFormats.isEmpty()) { decodeFormats = new Vector<BarcodeFormat>(); decodeFormats.addAll(DecodeFormatManager.PRODUCT_FORMATS); decodeFormats.addAll(DecodeFormatManager.INDUSTRIAL_FORMATS); decodeFormats.addAll(DecodeFormatManager.QR_CODE_FORMATS); decodeFormats.addAll(DecodeFormatManager.ONE_D_FORMATS); decodeFormats.addAll(DecodeFormatManager.DATA_MATRIX_FORMATS); decodeFormats.addAll(DecodeFormatManager.AZTEC_FORMATS); decodeFormats.addAll(DecodeFormatManager.PDF417_FORMATS); } hints.put(DecodeHintType.POSSIBLE_FORMATS, decodeFormats); if (characterSet != null) { hints.put(DecodeHintType.CHARACTER_SET, characterSet); } }
From source file:org.executequery.gui.editor.QueryEditorDelegate.java
/** * Increments the history index value.//from w w w .ja va 2s .co m */ private int incrementHistoryNum() { // for previous Vector<String> history = getSqlCommandHistory(); if (!history.isEmpty()) { int historyCount = history.size(); if (currentStatementHistoryIndex < historyCount - 1) { currentStatementHistoryIndex++; } queryEditor.setHasNextStatement(true); if (currentStatementHistoryIndex == historyCount - 1) { queryEditor.setHasPreviousStatement(false); } } return currentStatementHistoryIndex; }
From source file:org.zaproxy.zap.extension.pscanrules.ContentSecurityPolicyScanner.java
@Override public void scanHttpResponseReceive(HttpMessage msg, int id, Source source) { boolean cspHeaderFound = false; int noticesRisk = Alert.RISK_INFO; // LOGGER.setLevel(Level.DEBUG); //Enable for debugging if (LOGGER.isDebugEnabled()) { LOGGER.debug("Start " + id + " : " + msg.getRequestHeader().getURI().toString()); }/*from w ww. ja v a2 s .c o m*/ long start = System.currentTimeMillis(); if (!msg.getResponseHeader().isHtml() && !AlertThreshold.LOW.equals(this.getAlertThreshold())) { // Only really applies to HTML responses, but also check everything on Low threshold return; } // Content-Security-Policy is supported by Chrome 25+, Firefox 23+, // Safari 7+, Edge but not Internet Explorer Vector<String> cspOptions = msg.getResponseHeader().getHeaders(HTTP_HEADER_CSP); if (cspOptions != null && !cspOptions.isEmpty()) { cspHeaderFound = true; } // X-Content-Security-Policy is an older header, supported by Firefox // 4.0+, and IE 10+ (in a limited fashion) Vector<String> xcspOptions = msg.getResponseHeader().getHeaders(HTTP_HEADER_XCSP); if (xcspOptions != null && !xcspOptions.isEmpty()) { raiseAlert(msg, Constant.messages.getString(MESSAGE_PREFIX + "xcsp.name"), id, Constant.messages.getString(MESSAGE_PREFIX + "xcsp.desc"), getHeaderField(msg, HTTP_HEADER_XCSP).get(0), cspHeaderFound ? Alert.RISK_INFO : Alert.RISK_LOW, xcspOptions.get(0)); } // X-WebKit-CSP is supported by Chrome 14+, and Safari 6+ Vector<String> xwkcspOptions = msg.getResponseHeader().getHeaders(HTTP_HEADER_WEBKIT_CSP); if (xwkcspOptions != null && !xwkcspOptions.isEmpty()) { raiseAlert(msg, Constant.messages.getString(MESSAGE_PREFIX + "xwkcsp.name"), id, Constant.messages.getString(MESSAGE_PREFIX + "xwkcsp.desc"), getHeaderField(msg, HTTP_HEADER_WEBKIT_CSP).get(0), cspHeaderFound ? Alert.RISK_INFO : Alert.RISK_LOW, xwkcspOptions.get(0)); } if (cspHeaderFound) { ArrayList<Notice> notices = new ArrayList<>(); Origin origin = URI.parse(msg.getRequestHeader().getURI().toString()); String policyText = cspOptions.toString().replace("[", "").replace("]", ""); Policy pol = ParserWithLocation.parse(policyText, origin, notices); // Populate notices if (!notices.isEmpty()) { String cspNoticesString = getCSPNoticesString(notices); if (cspNoticesString.contains(Constant.messages.getString(MESSAGE_PREFIX + "notices.errors")) || cspNoticesString .contains(Constant.messages.getString(MESSAGE_PREFIX + "notices.warnings"))) { noticesRisk = Alert.RISK_LOW; } else { noticesRisk = Alert.RISK_INFO; } raiseAlert(msg, Constant.messages.getString(MESSAGE_PREFIX + "notices.name"), id, cspNoticesString, getHeaderField(msg, HTTP_HEADER_CSP).get(0), noticesRisk, cspOptions.get(0)); } List<String> allowedWildcardSources = getAllowedWildcardSources(policyText, origin); if (!allowedWildcardSources.isEmpty()) { String allowedWildcardSrcs = allowedWildcardSources.toString().replace("[", "").replace("]", ""); String wildcardSrcDesc = Constant.messages.getString(MESSAGE_PREFIX + "wildcard.desc", allowedWildcardSrcs); raiseAlert(msg, Constant.messages.getString(MESSAGE_PREFIX + "wildcard.name"), id, wildcardSrcDesc, getHeaderField(msg, HTTP_HEADER_CSP).get(0), Alert.RISK_MEDIUM, cspOptions.get(0)); } if (pol.allowsUnsafeInlineScript()) { raiseAlert(msg, Constant.messages.getString(MESSAGE_PREFIX + "scriptsrc.unsafe.name"), id, Constant.messages.getString(MESSAGE_PREFIX + "scriptsrc.unsafe.desc"), getHeaderField(msg, HTTP_HEADER_CSP).get(0), Alert.RISK_MEDIUM, cspOptions.get(0)); } if (pol.allowsUnsafeInlineStyle()) { raiseAlert(msg, Constant.messages.getString(MESSAGE_PREFIX + "stylesrc.unsafe.name"), id, Constant.messages.getString(MESSAGE_PREFIX + "stylesrc.unsafe.desc"), getHeaderField(msg, HTTP_HEADER_CSP).get(0), Alert.RISK_MEDIUM, cspOptions.get(0)); } } if (LOGGER.isDebugEnabled()) { LOGGER.debug("\tScan of record " + String.valueOf(id) + " took " + (System.currentTimeMillis() - start) + " ms"); } }
From source file:com.wallabystreet.kinjo.common.transport.ws.WSEngine.java
private void process(Element wsdd) throws DeploymentException { Service svc = new Service(server.getConfig(), (AxisClient) server.getClientEngine()); Call call = null;//from w w w . ja v a 2 s . co m try { call = (org.apache.axis.client.Call) svc.createCall(); } catch (ServiceException e) { log.error("", e); throw new DeploymentException(e); } call.setTargetEndpointAddress("local://AdminService"); call.setUseSOAPAction(true); call.setSOAPActionURI("urn:AdminService"); Vector result = null; Object[] params = new Object[] { new SOAPBodyElement(wsdd) }; try { result = (Vector) call.invoke(params); } catch (RemoteException e) { /* since this runs locally, this exception shouldn't ever raise */ throw new DeploymentException(e); } if (result == null || result.isEmpty()) { log.debug("result message of call is empty"); } else { SOAPBodyElement body = (SOAPBodyElement) result.elementAt(0); log.debug("result message of call is: \n" + body.toString()); } }
From source file:org.ecoinformatics.seek.ecogrid.quicksearch.QuickSearchAction.java
/** * The todo Implementation of abstract method. It will search ecogrid site * //from w w w. j ava 2s . c o m * @param e * ActionEvent */ public synchronized void actionPerformed(ActionEvent e) { datasetPanel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); CacheManager cm; try { cm = CacheManager.getInstance(); //cm.showDB(); } catch (CacheException e1) { e1.printStackTrace(); } String searchValue = null; if (datasetPanel != null) { searchValue = datasetPanel.getSearchTextFieldValue(); // searchType = datasetPanel.getSearchDataSrcType(); resultRoot = datasetPanel.getResultRoot(); } // // If no search term is entered, return immediately. if (searchValue == null || searchValue.trim().equals("")) { return; } System.out.println("searching.."); searchServicesVector = controller.getSelectedServicesList(); actionList = new Vector(); // transfer endpoint based EcoGridService to namespace based Search // Scope Vector searchScopeVector = transformEcoGridServiceToSearchScope(); if (!searchScopeVector.isEmpty() && resultRoot != null) { resultRoot.removeAllEntities(); // go through every namespace in search scope for (int i = 0; i < searchScopeVector.size(); i++) { // vecotr to store the ResultRecord for one search scope SearchScope searchScope = (SearchScope) searchScopeVector.elementAt(i); // String namespace = searchScope.getNamespace(); // get quick search query from metadata specification class MetadataSpecificationInterface metadataSpecClass = searchScope.getMetadataSpecification(); // *** Temporary Code String namespace = searchScope.getNamespace(); QueryType quickSearchQuery = null; try { quickSearchQuery = metadataSpecClass.getQuickSearchEcoGridQuery(searchValue); } catch (InvalidEcogridQueryException inE) { log.debug("The error to generate quick search query ", inE); return; } Vector searchEndPoints = searchScope.getEndPoints(); if (searchEndPoints == null) { log.debug("No search end points can be found"); return; } // go through the end points vector and create query action searchEndPointsVector(searchEndPoints, quickSearchQuery, searchValue, metadataSpecClass, namespace); } // for log.debug("Initial query action ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ " + actionList.size()); completedRequests = new CountDown(actionList.size()); // start query action datasetPanel.resetResultsPanel(); boolean forRegistryQuery = false; datasetPanel.startSearchProgressBar(forRegistryQuery); for (int i = 0; i < actionList.size(); i++) { QueryAction queryAction = (QueryAction) actionList.elementAt(i); queryAction.actionPerformed(null); } } // if datasetPanel.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); }
From source file:net.sf.jabref.sql.importer.DbImportAction.java
private void performImport() { if (!connectedToDB) { return;//from w w w . j a v a2 s . c o m } frame.output(Localization.lang("Attempting SQL import...")); DBExporterAndImporterFactory factory = new DBExporterAndImporterFactory(); DatabaseImporter importer = factory.getImporter(dbs.getDbPreferences().getServerType()); try { try (Connection conn = importer.connectToDB(dbs); Statement statement = conn.createStatement(); ResultSet rs = statement.executeQuery(SQLUtil.queryAllFromTable("jabref_database"))) { Vector<Vector<String>> matrix = new Vector<>(); while (rs.next()) { Vector<String> v = new Vector<>(); v.add(rs.getString("database_name")); matrix.add(v); } if (matrix.isEmpty()) { JOptionPane.showMessageDialog(frame, Localization.lang("There are no available databases to be imported"), Localization.lang("Import from SQL database"), JOptionPane.INFORMATION_MESSAGE); } else { DBImportExportDialog dialogo = new DBImportExportDialog(frame, matrix, DBImportExportDialog.DialogType.IMPORTER); if (dialogo.removeAction) { String dbName = dialogo.selectedDB; DatabaseUtil.removeDB(dialogo, dbName, conn, databaseContext); performImport(); } else if (dialogo.moreThanOne) { // use default DB mode for import databases = importer.performImport(dbs, dialogo.listOfDBs, Globals.prefs.getDefaultBibDatabaseMode()); for (DBImporterResult res : databases) { databaseContext = res.getDatabaseContext(); dbs.isConfigValid(true); } frame.output(Localization.lang("%0 databases will be imported", Integer.toString(databases.size()))); } else { frame.output(Localization.lang("Importing canceled")); } } } } catch (Exception ex) { String preamble = Localization.lang("Could not import from SQL database for the following reason:"); String errorMessage = SQLUtil.getExceptionMessage(ex); dbs.isConfigValid(false); JOptionPane.showMessageDialog(frame, preamble + '\n' + errorMessage, Localization.lang("Import from SQL database"), JOptionPane.ERROR_MESSAGE); frame.output(Localization.lang("Error importing from database")); LOGGER.error("Error importing from database", ex); } }
From source file:nl.tricode.magnolia.blogs.dialog.action.SaveWordpressBlogDialogAction.java
@Override public void execute() throws ActionExecutionException { if (validator.isValid()) { try {//from www.j a va 2 s . c o m log.debug("Start wordPress import."); log.debug("Import into DAM [" + this.shouldImportImages + "]."); log.debug("Import into Contacts [" + this.shouldImportContacts + "]."); Vector<Hashtable<String, Object>> blog = getWordpressPosts(); if (!blog.isEmpty()) { log.debug("Blog size [" + blog.size() + "]"); for (Hashtable<String, Object> blogPost : blog) { processPost(blogPost); } finishImport(); } else { shell.openNotification(MessageStyleTypeEnum.INFO, false, "No WordPress posts were found."); callback.onCancel(); } } catch (ActionExecutionException e) { cancelImport(); throw new ActionExecutionException(e); } } else { log.error("Validation error(s). Import cancelled."); } }