List of usage examples for java.util.logging Level FINE
Level FINE
To view the source code for java.util.logging Level FINE.
Click Source Link
From source file:com.izforge.izpack.panels.target.TargetPanelHelper.java
/** * Determines if there is IzPack installation information at the specified path that is incompatible with the * current version of IzPack.// ww w . jav a 2 s . c om * <p/> * To be incompatible, the file {@link InstallData#INSTALLATION_INFORMATION} must exist in the supplied directory, * and not contain recognised {@link Pack} instances. * * @param dir the path to check * @param readInstallationInformation check .installationinformation file or skip it * @return {@code true} if there is incompatible installation information, * {@code false} if there is no installation info, or it is compatible */ @SuppressWarnings("unchecked") public static boolean isIncompatibleInstallation(String dir, Boolean readInstallationInformation) { boolean result = false; File file = new File(dir, InstallData.INSTALLATION_INFORMATION); if (file.exists() && readInstallationInformation) { FileInputStream input = null; ObjectInputStream objectInput = null; try { input = new FileInputStream(file); objectInput = new ObjectInputStream(input); List<Object> packs = (List<Object>) objectInput.readObject(); for (Object pack : packs) { if (!(pack instanceof Pack)) { return true; } } } catch (Throwable exception) { logger.log(Level.FINE, "Installation information at path=" + file.getPath() + " failed to deserialize", exception); result = true; } finally { IOUtils.closeQuietly(objectInput); IOUtils.closeQuietly(input); } } return result; }
From source file:eu.europa.ejusticeportal.dss.applet.model.action.OpenPdfAction.java
/** * Execute the OpenPdfAction./*w w w . j a v a 2 s .c o m*/ */ @Override public void doExec() { FileOutputStream fos = null; try { //On MacOS the temp location is difficult to access for a normal user => use user.home instead String userHome = System.getProperty("user.home"); if (new File(userHome).listFiles() == null) { //e.g. safari on mac LOG.info("user.home not accessible, using java.io.tmpdir"); userHome = System.getProperty("java.io.tmpdir"); } LOG.info("save pdf to " + userHome); final File pdfFile = new File(new File(userHome), "dynform" + System.currentTimeMillis() + ".pdf"); pdfFile.deleteOnExit(); final String pdfFilePath = pdfFile.getAbsolutePath(); fos = new FileOutputStream(pdfFile); fos.write(pdf); LOG.log(Level.FINE, "The local path of the pdf is : {0}", pdfFilePath); IOUtils.closeQuietly(fos); Event.getInstance().fire( new StatusRefreshed(MessagesEnum.dss_applet_message_pdf_path, MessageLevel.INFO, pdfFilePath)); openURL(pdfFilePath); } catch (IOException ex) { IOUtils.closeQuietly(fos); // The user can't do anything about this ExceptionUtils.exception( new UnexpectedException("Can't write PDF to temp area of disk (required for display).", ex), LOG); } }
From source file:com.ibm.ws.lars.rest.RepositoryRESTResourceLoggingTest.java
@Test public void testGetAssets(@Mocked final Logger logger, @Mocked final UriInfo info, @Mocked SecurityContext context) throws URISyntaxException, JsonProcessingException, InvalidParameterException { new Expectations() { {/*w w w . jav a 2 s . com*/ info.getQueryParameters(false); logger.isLoggable(Level.FINE); result = true; info.getRequestUri(); result = new URI("http://localhost:9085/ma/v1/assets?foo=bar"); logger.fine("getAssets called with query parameters: foo=bar"); } }; getRestResource().getAssets(info, context); }
From source file:com.google.enterprise.connector.salesforce.security.BaseAuthorizationManager.java
/** * Connector manager sends a collection of documentIDs to the connector * to authorize for an authenticated context * * @param col Collection the docIDs to authorize * @param id AuthenticationIdentity the identity to auth * @return Collection of docs that are authorized *///from w ww. j a v a2 s . co m public Collection authorizeDocids(Collection col, AuthenticationIdentity id) { logger.log(Level.FINER, " SalesForceAuthorizationManager. authorizeDocids called for " + id.getUsername()); //first see if we have a callable authorization module to try String callable_az_module = System .getProperty(BaseConstants.CALLABLE_AZ + "_" + connector.getInstanceName()); if (callable_az_module != null) { logger.log(Level.FINE, "Using Loadable Authorization Module : " + callable_az_module); try { Class cls = Class.forName(callable_az_module); java.lang.reflect.Constructor co = cls.getConstructor(); IAuthorizationModule icau = (IAuthorizationModule) co.newInstance(); Collection auth_col = icau.authorizeDocids(col, id.getUsername()); Collection ret_col = new ArrayList(); for (Iterator i = auth_col.iterator(); i.hasNext();) { String did = (String) i.next(); AuthorizationResponse ap = new AuthorizationResponse(true, did); ret_col.add(ap); } return ret_col; } catch (Exception ex) { logger.log(Level.SEVERE, "Unable to load Authorization Module " + callable_az_module); } } else { logger.log(Level.FINER, "Using Default Authorization Module"); } Iterator itr = col.iterator(); logger.log(Level.FINER, " AUTHORIZING BATCH OF : " + col.size() + " documents"); //vector to hold the list of docs that will eventually get authorized Vector v_docIDs = new Vector(); //create a string of 'docid1','docid2','docid3' to send into the AZ query String doc_wildcard = ""; while (itr.hasNext()) { String docID = (String) itr.next(); v_docIDs.add(docID); doc_wildcard = doc_wildcard + "'" + docID + "'"; if (itr.hasNext()) doc_wildcard = doc_wildcard + ","; } //initialize the collection for the response Collection col_resp = new ArrayList(); String query = connector.getAzquery(); //substitute the doc IDs into the AZ query String modified_az_query = query.replace("$DOCIDS", doc_wildcard); modified_az_query = modified_az_query.replace("$USERID", id.getUsername()); logger.log(Level.FINER, "Attempting Authorizing DocList " + modified_az_query); //get ready to submit the query SFQuery sfq = new SFQuery(); //get the user's sessionID, login server thats in context //this step maynot be necessary if we use the connector's login context //instead of the users... //TODO: figure out which way is better later on Properties session_props = connector.getUserSession(id.getUsername()); //not that it matters, how did the user authenticate.. //if its strong (i.e, we got a session ID, we can submit a full AZ query) String auth_strength = (String) session_props.get(BaseConstants.AUTHENTICATION_TYPE); if (auth_strength.equals(BaseConstants.STRONG_AUTHENTICATION)) { logger.log(Level.FINER, "Using Strong Authentication"); try { //following section is used if we want to AZ using the connectors authenticated super context //its commented out for now but we'll touch on this later // if (connector.getSessionID().equalsIgnoreCase("")){ // SalesForceLogin sfl = new SalesForceLogin(connector.getUsername(),connector.getPassword(),connector.getLoginsrv()); // if (sfl.isLoggedIn()){ // connector.setSessionID(sfl.getSessionID()); // connector.setEndPointServer(sfl.getEndPointServer()); // } // } //for connector-managed sessions //todo figure out someway to purge the older sessions logger.log(Level.INFO, "Submitting [" + (String) session_props.getProperty(BaseConstants.LOGIN_SERVER) + "] [" + (String) session_props.getProperty(BaseConstants.SESSIONID) + "]"); org.w3c.dom.Document az_resp = sfq.submitStatement(modified_az_query, BaseConstants.QUERY_TYPE, (String) session_props.getProperty(BaseConstants.LOGIN_SERVER), (String) session_props.getProperty(BaseConstants.SESSIONID)); //if using system session to check AZ //org.w3c.dom.Document az_resp = sfq.submitStatement(modified_az_query, BaseConstants.QUERY_TYPE,connector.getEndPointServer() , connector.getSessionID()); //now transform the AZ SOAP response into the canonical form using //the AZ XLST provided. String encodedXSLT = connector.getAzxslt(); byte[] decode = org.apache.commons.codec.binary.Base64.decodeBase64(encodedXSLT.getBytes()); org.w3c.dom.Document az_xsl = Util.XMLStringtoDoc(new String(decode)); logger.log(Level.FINER, "AZ Query Response " + Util.XMLDoctoString(az_resp)); Document tx_xml = Util.TransformDoctoDoc(az_resp, az_xsl); tx_xml.getDocumentElement().normalize(); logger.log(Level.FINER, "AZ transform result for " + id.getUsername() + " " + Util.XMLDoctoString(tx_xml)); //TODO...figure out why I can use tx_xml as a document by itself //have to resort to convert tx_xml to string and then back to Document //for some reason DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); StringBuffer sb1 = new StringBuffer(Util.XMLDoctoString(tx_xml)); ByteArrayInputStream bis = new ByteArrayInputStream(sb1.toString().getBytes("UTF-8")); Document doc = db.parse(bis); doc.getDocumentElement().normalize(); //now that the soap response is transformed, extract the documents that were //authorized from the canonical XML AZ form NodeList nl_documents = doc.getElementsByTagName("azdecisions"); //get the NodeList under <document> HashMap hm_azdecisions = new HashMap(); ; Node n_documents = nl_documents.item(0); for (int i = 0; i < n_documents.getChildNodes().getLength(); i++) { Node n_doc = n_documents.getChildNodes().item(i); if (n_doc.getNodeType() == Node.ELEMENT_NODE) { TransformerFactory transfac = TransformerFactory.newInstance(); Transformer trans = transfac.newTransformer(); trans.setOutputProperty(OutputKeys.INDENT, "yes"); if (n_doc.getNodeName().equalsIgnoreCase("docID")) { //ok...so this doc ID was returned so we'll allow/permit this hm_azdecisions.put(n_doc.getFirstChild().getNodeValue(), "PERMIT"); } } } //for each doc ID we got in, iterate and authorize the docs that we got back.. //TODO, ofcourse we could just forego this loop //and simply iterate the hm_azdecisions hashmap to create col_resp for (int i = 0; i < v_docIDs.size(); i++) { //a doc id we got to test String in_docID = (String) v_docIDs.get(i); //if the doc exists in the set we authorized //the more i write this the more i want to just iterate the hm_azdecisions //and get it over with...i'll work on that next week if (hm_azdecisions.containsKey(in_docID)) { AuthorizationResponse ap = new AuthorizationResponse(true, in_docID); col_resp.add(ap); } } } catch (Exception bex) { logger.log(Level.SEVERE, " ERROR SUBMITTING AZ Query " + bex); } } //if the user was just authenticated //we don't have the sessionid so we'lll authorize all docs. //WEAK_AUTH flag should never get set since //we've failed the AU attempt in the BaseAuthenticationManager already else if (auth_strength.equals(BaseConstants.WEAK_AUTHENTICATION)) { logger.log(Level.FINER, "Using Weak Authentication"); if (connector.allowWeakAuth()) { col_resp = new ArrayList(); for (int i = 0; i < v_docIDs.size(); i++) { String docID = (String) v_docIDs.get(i); logger.log(Level.FINER, "Authorizing " + docID); AuthorizationResponse ap = new AuthorizationResponse(true, docID); col_resp.add(ap); } } } return col_resp; }
From source file:com.cloudbees.plugins.deployer.sources.WildcardPathDeploySource.java
/** * {@inheritDoc}//from w w w .j a va 2 s . c om */ @Override @CheckForNull public File getApplicationFile(@NonNull Run run) { File result = null; if (run.getArtifactsDir().isDirectory()) { FileSet fileSet = new FileSet(); fileSet.setProject(new Project()); fileSet.setDir(run.getArtifactsDir()); fileSet.setIncludes(getFilePattern()); try { String[] files = fileSet.getDirectoryScanner().getIncludedFiles(); if (files.length > 0) { result = new File(run.getArtifactsDir(), files[0]); } } catch (BuildException e) { LOGGER.log(Level.FINE, Messages.WildcardPathDeploySource_CouldNotListFromBuildArtifacts(getFilePattern(), run), e); } } return result; }
From source file:magma.agent.behavior.complex.GetToInitialPosition.java
/** * calculates a point on a circle from the own goal to which to go *//*from w ww.j a va 2 s . co m*/ private boolean getCurrentBehavior() { IThisPlayer thisPlayer = worldModel.getThisPlayer(); Vector3D home = thisPlayer.getHomePosition("doesNotMatter"); Vector3D ourPos = thisPlayer.getPosition(); Vector3D ownGoal = worldModel.getOwnGoalPosition(); Vector3D ball = worldModel.getBall().getPosition(); double distanceX = IServerConfigFilesConstants.FIELD_LENGTH - Math.abs(home.getX()); // destination position is certain distance from goal in line with ball Vector3D goalBallDir = new Vector3D(distanceX, ball.subtract(ownGoal).normalize()); Vector3D goalBall = ownGoal.add(goalBallDir); setPosition((float) goalBall.getX(), (float) goalBall.getY(), (float) goalBall.getAlpha()); double directionToTarget = thisPlayer.getBodyDirectionTo(position).degrees(); rotation = (float) directionToTarget; float distanceToTarget = (float) thisPlayer.getDistanceToXY(position); if (distanceToTarget < DISTANCE_PRECISION) { directionToTarget = thisPlayer.getBodyDirectionTo(ball).degrees(); rotation = (float) directionToTarget; } logger.log(Level.FINE, "initial pos: ({0},{1}) distanceToTarget: {2} directionToTarget: {3} " + "ourpos: ({4},{5})", new Object[] { goalBall.getX(), goalBall.getY(), distanceToTarget, directionToTarget, ourPos.getX(), ourPos.getY() }); if (distanceToTarget < DISTANCE_PRECISION) { // we are at the desired position // make sure that we are also in desired direction if (!turnedLeftBefore && directionToTarget > ANGULAR_PRECISION && directionToTarget <= 90) { turnLeft(directionToTarget); return true; } if (!turnedLeftBefore && directionToTarget < -ANGULAR_PRECISION && directionToTarget >= -90) { turnRight(directionToTarget - 180); return true; } if (!turnedLeftBefore && directionToTarget > 90 && directionToTarget < (180 - ANGULAR_PRECISION)) { turnRight(directionToTarget - 180); return true; } if (!turnedRightBefore && directionToTarget < -90 && directionToTarget > -180 + ANGULAR_PRECISION) { turnLeft(180 + directionToTarget); return true; } } if (directionToTarget > 50 && directionToTarget < 130) { // position is left currentBehavior = behaviors.get(IBehavior.STEP_LEFT); return true; } if (directionToTarget < -50 && directionToTarget > -130) { // position is right currentBehavior = behaviors.get(IBehavior.STEP_RIGHT); return true; } if (directionToTarget > 90 || directionToTarget < -90) { // or do we prefer to turn if (!turnedLeftBefore && directionToTarget > 0 && directionToTarget < (180 - ANGULAR_PRECISION)) { turnRight(directionToTarget - 180); return true; } if (!turnedRightBefore && directionToTarget < -ANGULAR_PRECISION) { turnLeft(180 + directionToTarget); return true; } currentBehavior = behaviors.get(IBehavior.STEP_BACKWARD); return true; } return false; }
From source file:eu.edisonproject.training.wsd.Wikipedia.java
protected Set<String> getTitles(String lemma) throws ParseException, UnsupportedEncodingException, IOException { String URLquery = lemma.replaceAll("_", " "); URLquery = URLEncoder.encode(URLquery, "UTF-8"); //sroffset=10 URL url = new URL( PAGE + "?action=query&format=json&redirects&list=search&srlimit=500&srsearch=" + URLquery); Logger.getLogger(Wikipedia.class.getName()).log(Level.FINE, url.toString()); String jsonString = IOUtils.toString(url); Set<String> titles = new TreeSet<>(); JSONObject jsonObj = (JSONObject) JSONValue.parseWithException(jsonString); JSONObject query = (JSONObject) jsonObj.get("query"); JSONArray search = (JSONArray) query.get("search"); if (search != null) { for (Object o : search) { JSONObject res = (JSONObject) o; String title = (String) res.get("title"); // System.err.println(title); if (title != null && !title.toLowerCase().contains("(disambiguation)")) { // if (title != null) { title = title.replaceAll("%(?![0-9a-fA-F]{2})", "%25"); title = title.replaceAll("\\+", "%2B"); title = java.net.URLDecoder.decode(title, "UTF-8"); title = title.replaceAll("_", " ").toLowerCase(); lemma = java.net.URLDecoder.decode(lemma, "UTF-8"); lemma = lemma.replaceAll("_", " "); titles.add(title);//w ww .j a va 2s . c om } } } titles.add(lemma); return titles; }
From source file:com.google.api.server.spi.request.RestServletRequestParamReader.java
@Override public Object[] read() throws ServiceException { // Assumes input stream to be encoded in UTF-8 // TODO: Take charset from content-type as encoding try {//from ww w. j a v a2s . c o m EndpointMethod method = getMethod(); if (method.getParameterClasses().length == 0) { return new Object[0]; } String requestBody = IoUtil.readRequestBody(servletRequest); logger.log(Level.FINE, "requestBody=" + requestBody); // Unlike the Lily protocol, which essentially always requires a JSON body to exist (due to // path and query parameters being injected into the body), bodies are optional here, so we // create an empty body and inject named parameters to make deserialize work. JsonNode node = Strings.isEmptyOrWhitespace(requestBody) ? objectReader.createObjectNode() : objectReader.readTree(requestBody); if (!node.isObject()) { throw new BadRequestException("expected a JSON object body"); } ObjectNode body = (ObjectNode) node; Map<String, Class<?>> parameterMap = getParameterMap(method); // First add query parameters, then add path parameters. If the parameters already exist in // the resource, then the they aren't added to the body object. For compatibility reasons, // the order of precedence is resource field > query parameter > path parameter. for (Enumeration<?> e = servletRequest.getParameterNames(); e.hasMoreElements();) { String parameterName = (String) e.nextElement(); if (!body.has(parameterName)) { Class<?> parameterClass = parameterMap.get(parameterName); ApiParameterConfig parameterConfig = parameterConfigMap.get(parameterName); if (parameterClass != null && parameterConfig.isRepeated()) { ArrayNode values = (ArrayNode) objectReader.createArrayNode(); for (String value : servletRequest.getParameterValues(parameterName)) { values.add(value); } body.set(parameterName, values); } else { body.put(parameterName, servletRequest.getParameterValues(parameterName)[0]); } } } for (Entry<String, String> entry : rawPathParameters.entrySet()) { String parameterName = entry.getKey(); Class<?> parameterClass = parameterMap.get(parameterName); if (parameterClass != null && !body.has(parameterName)) { body.put(parameterName, entry.getValue()); } } for (Entry<String, ApiParameterConfig> entry : parameterConfigMap.entrySet()) { if (!body.has(entry.getKey()) && entry.getValue().getDefaultValue() != null) { body.put(entry.getKey(), entry.getValue().getDefaultValue()); } } return deserializeParams(body); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | IOException e) { e.printStackTrace(); throw new BadRequestException(e); } }
From source file:org.bonitasoft.engine.api.HTTPServerAPITest.java
@Test(expected = ServerWrappedException.class) public void invokeMethodCatchUndeclaredThrowableException() throws Exception { final PrintStream printStream = System.err; final ByteArrayOutputStream myOut = new ByteArrayOutputStream(); System.setErr(new PrintStream(myOut)); final Logger logger = Logger.getLogger(HTTPServerAPI.class.getName()); logger.setLevel(Level.FINE); final ConsoleHandler ch = new ConsoleHandler(); ch.setLevel(Level.FINE);// ww w.j a va 2s . com logger.addHandler(ch); try { final Map<String, Serializable> options = new HashMap<String, Serializable>(); final String apiInterfaceName = "apiInterfaceName"; final String methodName = "methodName"; final List<String> classNameParameters = new ArrayList<String>(); final Object[] parametersValues = null; final HTTPServerAPI httpServerAPI = mock(HTTPServerAPI.class); final String response = "response"; doReturn(response).when(httpServerAPI, "executeHttpPost", eq(options), eq(apiInterfaceName), eq(methodName), eq(classNameParameters), eq(parametersValues), Matchers.any(XStream.class)); doThrow(new UndeclaredThrowableException(new BonitaException("Bonita exception"), "Exception plop")) .when(httpServerAPI, "checkInvokeMethodReturn", eq(response), Matchers.any(XStream.class)); // Let's call it for real: doCallRealMethod().when(httpServerAPI).invokeMethod(options, apiInterfaceName, methodName, classNameParameters, parametersValues); httpServerAPI.invokeMethod(options, apiInterfaceName, methodName, classNameParameters, parametersValues); } finally { System.setErr(printStream); final String logs = myOut.toString(); assertTrue("should have written in logs an exception", logs.contains("java.lang.reflect.UndeclaredThrowableException")); assertTrue("should have written in logs an exception", logs.contains("BonitaException")); assertTrue("should have written in logs an exception", logs.contains("Exception plop")); } }