org.jfree.util.Log Java Examples

The following examples show how to use org.jfree.util.Log. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ManagedPropertiesMessageCoordinator.java    From olat with Apache License 2.0 6 votes vote down vote up
/**
*/
  @Override
  public void onMessage(Message message) {

      try {
          if (message instanceof TextMessage) {
              TextMessage tm = (TextMessage) message;
              // TODO use MapMessage and allow update of more then one property at one
              String propertyName = tm.getText();
              String value = tm.getStringProperty(propertyName);
              System.out.printf("*****************  Processed message (listener 1) 'key=%s' 'value=%s'. hashCode={%d}\n", propertyName, value, this.hashCode());

              propertiesLoader.setProperty(propertyName, value);
          }
      } catch (JMSException e) {
          Log.error("Error while processing jms message ", e);
      }
  }
 
Example #2
Source File: PropertyManagerEBL.java    From olat with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public List<String> getCourseCalendarSubscriptionProperty(final PropertyParameterObject propertyParameterObject) {
    List<String> infoSubscriptions = new ArrayList<String>();
    List<PropertyImpl> properties = findProperties(propertyParameterObject);

    if (properties.size() > 1) {
        Log.error("more than one property found, something went wrong, deleting them and starting over.");
        for (PropertyImpl prop : properties) {
            propertyManager.deleteProperty(prop);
        }

    } else if (properties.size() == 0l) {
        createAndSaveProperty(propertyParameterObject);
        properties = findProperties(propertyParameterObject);
    }
    String value = properties.get(0).getTextValue();

    if (value != null && !value.equals("")) {
        String[] subscriptions = properties.get(0).getTextValue().split(SEPARATOR);
        infoSubscriptions.addAll(Arrays.asList(subscriptions));
    }

    return infoSubscriptions;
}
 
Example #3
Source File: ManagedPropertiesMessageCoordinator.java    From olat with Apache License 2.0 6 votes vote down vote up
/**
*/
  @Override
  public void onMessage(Message message) {

      try {
          if (message instanceof TextMessage) {
              TextMessage tm = (TextMessage) message;
              // TODO use MapMessage and allow update of more then one property at one
              String propertyName = tm.getText();
              String value = tm.getStringProperty(propertyName);
              System.out.printf("*****************  Processed message (listener 1) 'key=%s' 'value=%s'. hashCode={%d}\n", propertyName, value, this.hashCode());

              propertiesLoader.setProperty(propertyName, value);
          }
      } catch (JMSException e) {
          Log.error("Error while processing jms message ", e);
      }
  }
 
Example #4
Source File: ParserFrontend.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns a SAX parser.
 *
 * @return a SAXParser.
 *
 * @throws ParserConfigurationException if there is a problem configuring the parser.
 * @throws SAXException if there is a problem with the parser initialisation
 */
protected SAXParser getParser() throws ParserConfigurationException, SAXException {
    if (this.factory == null) {
        this.factory = SAXParserFactory.newInstance();
        if (isValidateDTD()) {
            try {
                // dont touch the validating feature, if not needed ..
                this.factory.setValidating(true);
            }
            catch (Exception ex) {
                // the parser does not like the idea of validating ...
                Log.debug("The parser will not validate the xml document.", ex);
            }
        }
    }
    return this.factory.newSAXParser();
}
 
Example #5
Source File: RenderingHintsWriteHandler.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
private String hintFieldToString(final Object o) {
    final Field[] fields = RenderingHints.class.getFields();
    for (int i = 0; i < fields.length; i++) {
        final Field f = fields[i];
        if (Modifier.isFinal(f.getModifiers()) 
            && Modifier.isPublic(f.getModifiers()) 
            && Modifier.isStatic(f.getModifiers())) {
            try {
                final Object value = f.get(null);
                if (o.equals(value)) {
                    return f.getName();
                }
            }
            catch (Exception e) {
                Log.info ("Unable to write RenderingHint", e);
            }
        }
    }
    throw new IllegalArgumentException("Invalid value given");
}
 
Example #6
Source File: URLObjectDescription.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Sets the parameters of this description object to match the supplied object.
 *
 * @param o  the object (should be an instance of <code>URL</code>).
 *
 * @throws ObjectFactoryException if the object is not an instance of <code>URL</code>.
 */
public void setParameterFromObject(final Object o) throws ObjectFactoryException {
    if (!(o instanceof URL)) {
        throw new ObjectFactoryException("Is no instance of java.net.URL");
    }

    final URL comp = (URL) o;
    final String baseURL = getConfig().getConfigProperty(Parser.CONTENTBASE_KEY);
    try {
        final URL bURL = new URL(baseURL);
        setParameter("value", IOUtils.getInstance().createRelativeURL(comp, bURL));
    }
    catch (Exception e) {
        Log.warn("BaseURL is invalid: ", e);
    }
    setParameter("value", comp.toExternalForm());
}
 
Example #7
Source File: RenderingHintValueReadHandler.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
private Object stringToHintField (final String name) {
    final Field[] fields = RenderingHints.class.getFields();
    for (int i = 0; i < fields.length; i++) {
        final Field f = fields[i];
        if (Modifier.isFinal(f.getModifiers()) 
            && Modifier.isPublic(f.getModifiers()) 
            && Modifier.isStatic(f.getModifiers())) {
            try {
                final String fieldName = f.getName();
                if (fieldName.equals(name)) {
                    return f.get(null);
                }
            }
            catch (Exception e) {
                Log.info ("Unable to write RenderingHint", e);
            }
        }
    }
    throw new IllegalArgumentException("Invalid value given");
}
 
Example #8
Source File: AbstractXmlReadHandler.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * This method is called at the start of an element.
 *
 * @param tagName  the tag name.
 * @param attrs  the attributes.
 *
 * @throws SAXException if there is a parsing error.
 * @throws XmlReaderException if there is a reader error.
 */
public final void startElement(final String tagName, final Attributes attrs)
    throws XmlReaderException, SAXException {
    if (this.firstCall) {
        if (!this.tagName.equals(tagName)) {
            throw new SAXException("Expected <" + this.tagName + ">, found <" + tagName + ">");
        }
        this.firstCall = false;
        startParsing(attrs);
    }
    else {
        final XmlReadHandler childHandler = getHandlerForChild(tagName, attrs);
        if (childHandler == null) {
            Log.warn ("Unknown tag <" + tagName + ">");
            return;
        }
        childHandler.init(getRootHandler(), tagName);
        this.rootHandler.recurse(childHandler, tagName, attrs);
    }
}
 
Example #9
Source File: ClusterLockDao.java    From olat with Apache License 2.0 6 votes vote down vote up
LockImpl findLock(final String asset) {
    if (Log.isDebugEnabled()) {
        log.debug("findLock: " + asset + " START");
    }
    final DBQuery q = DBFactory.getInstance().createQuery(
            "select alock from " + LockImpl.class.getName() + " as alock inner join fetch alock.owner where alock.asset = :asset");
    q.setParameter("asset", asset);
    final List res = q.list();
    if (res.size() == 0) {
        log.debug("findLock: null END");
        return null;
    } else {
        if (Log.isDebugEnabled()) {
            log.debug("findLock: " + res.get(0) + " END");
        }
        return (LockImpl) res.get(0);
    }
}
 
Example #10
Source File: CollectionObjectDescription.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates an object based on the description.
 *
 * @return The object.
 */
public Object createObject() {
    try {
        final Collection l = (Collection) getObjectClass().newInstance();
        int counter = 0;
        while (getParameterDefinition(String.valueOf(counter)) != null) {
            final Object value = getParameter(String.valueOf(counter));
            if (value == null) {
                break;
            }

            l.add(value);
            counter += 1;
        }
        return l;
    }
    catch (Exception ie) {
        Log.warn("Unable to instantiate Object", ie);
        return null;
    }
}
 
Example #11
Source File: InfoSubscription.java    From olat with Apache License 2.0 6 votes vote down vote up
/**
 * @return
 */
private List<String> getProperty(String key) {
    List<String> infoSubscriptions = new ArrayList<String>();
    List<PropertyImpl> properties = propertyManager.findProperties(ident, null, null, null, key);

    if (properties.size() > 1) {
        Log.error("more than one property found, something went wrong, deleting them and starting over.");
        for (PropertyImpl prop : properties) {
            propertyManager.deleteProperty(prop);
        }

    } else if (properties.size() == 0l) {
        PropertyImpl p = propertyManager.createPropertyInstance(ident, null, null, null, key, null, null, null, null);
        propertyManager.saveProperty(p);
        properties = propertyManager.findProperties(ident, null, null, null, key);
    }
    String value = properties.get(0).getTextValue();

    if (value != null && !value.equals("")) {
        String[] subscriptions = properties.get(0).getTextValue().split(SEPARATOR);
        infoSubscriptions.addAll(Arrays.asList(subscriptions));
    }

    return infoSubscriptions;
}
 
Example #12
Source File: StreamingJsonCompleteDataSetRegistration.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
protected void writeField( String fieldName, String value )
{
    if ( value == null )
    {
        return;
    }

    try
    {
        generator.writeObjectField( fieldName, value );
    }
    catch ( IOException e )
    {
        Log.error( e.getMessage() );
    }
}
 
Example #13
Source File: ClusterLockDao.java    From olat with Apache License 2.0 6 votes vote down vote up
/**
 * @param identName
 *            the name of the identity to release all locks for (only the non-persistent locks in cluster mode, -not- the persistent locks!)
 */
public void releaseAllLocksFor(final String identName) {
    if (Log.isDebugEnabled()) {
        log.debug("releaseAllLocksFor: " + identName + " START");
    }

    final Identity ident = findIdentityByName(identName);

    DBFactory.getInstance().delete("from " + LockImpl.class.getName() + " as alock inner join fetch " + "alock.owner as owner where owner.key = ?", ident.getKey(),
            Hibernate.LONG);
    // cluster:: can we save a query (and is it appropriate considering encapsulation)
    // here by saying: alock.owner as owner where owner.name = ? (using identName parameter)
    if (Log.isDebugEnabled()) {
        log.debug("releaseAllLocksFor: " + identName + " END");
    }
}
 
Example #14
Source File: PropertyManagerEBL.java    From olat with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public List<String> getCourseCalendarSubscriptionProperty(final PropertyParameterObject propertyParameterObject) {
    List<String> infoSubscriptions = new ArrayList<String>();
    List<PropertyImpl> properties = findProperties(propertyParameterObject);

    if (properties.size() > 1) {
        Log.error("more than one property found, something went wrong, deleting them and starting over.");
        for (PropertyImpl prop : properties) {
            propertyManager.deleteProperty(prop);
        }

    } else if (properties.size() == 0l) {
        createAndSaveProperty(propertyParameterObject);
        properties = findProperties(propertyParameterObject);
    }
    String value = properties.get(0).getTextValue();

    if (value != null && !value.equals("")) {
        String[] subscriptions = properties.get(0).getTextValue().split(SEPARATOR);
        infoSubscriptions.addAll(Arrays.asList(subscriptions));
    }

    return infoSubscriptions;
}
 
Example #15
Source File: StreamingJsonCompleteDataSetRegistration.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void writeField( String fieldName, Boolean value )
{
    if ( value == null )
    {
        return;
    }

    try
    {
        generator.writeObjectField( fieldName, value );
    }
    catch ( IOException e )
    {
        Log.error( e.getMessage() );
    }
}
 
Example #16
Source File: GithubOauthLoginAction.java    From DotCi with MIT License 6 votes vote down vote up
public HttpResponse doFinishLogin(StaplerRequest request, StaplerResponse rsp) throws IOException {

        String code = request.getParameter("code");

        if (code == null || code.trim().length() == 0) {
            Log.info("doFinishLogin: missing code.");
            return HttpResponses.redirectToContextRoot();
        }

        String content = postForAccessToken(code);

        String accessToken = extractToken(content);
        updateOfflineAccessTokenForUser(accessToken);
        request.getSession().setAttribute("access_token", accessToken);

        String newProjectSetupUrl = getJenkinsRootUrl() + "/" + GithubReposController.URL;
        return HttpResponses.redirectTo(newProjectSetupUrl);
    }
 
Example #17
Source File: MappingModel.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Adds a multiplex mapping.
 * 
 * @param mappingInfo  the mapping.
 */
public void addMultiplexMapping(final MultiplexMappingInfo mappingInfo) {
    if (!this.mappingInfos.containsKey(mappingInfo.getBaseClass())) {
        this.multiplexMappings.add(mappingInfo);
        this.mappingInfos.put(mappingInfo.getBaseClass(), mappingInfo);
    }
    else {
        final Object o = this.mappingInfos.get(mappingInfo.getBaseClass());
        if (o instanceof ManualMappingInfo) {
            throw new IllegalArgumentException
                ("This mapping is already a manual mapping.");
        }
        else {
            Log.info(
                "Duplicate Multiplex mapping: " + mappingInfo.getBaseClass(), new Exception()
            );
        }
    }

}
 
Example #18
Source File: MappingModel.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Adds a manual mapping.
 * 
 * @param mappingInfo  the mapping.
 */
public void addManualMapping(final ManualMappingInfo mappingInfo) {
    if (!this.mappingInfos.containsKey(mappingInfo.getBaseClass())) {
        this.manualMappings.add(mappingInfo);
        this.mappingInfos.put(mappingInfo.getBaseClass(), mappingInfo);
    }
    else {
        final Object o = this.mappingInfos.get(mappingInfo.getBaseClass());
        if (o instanceof ManualMappingInfo) {
            Log.info ("Duplicate manual mapping: " + mappingInfo.getBaseClass());
        }
        else {
            throw new IllegalArgumentException
                ("This mapping is already a multiplex mapping.");
        }
    }
}
 
Example #19
Source File: PropertyFileConfiguration.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Loads the properties stored in the given file. This method does nothing if
 * the file does not exist or is unreadable. Appends the contents of the loaded
 * properties to the already stored contents.
 *
 * @param in the input stream used to read the properties.
 */
public void load(final InputStream in)
{
  if (in == null)
  {
    throw new NullPointerException();
  }

  try
  {
    final BufferedInputStream bin = new BufferedInputStream(in);
    final Properties p = new Properties();
    p.load(bin);
    this.getConfiguration().putAll(p);
    bin.close();
  }
  catch (IOException ioe)
  {
    Log.warn("Unable to read configuration", ioe);
  }

}
 
Example #20
Source File: AbstractModelReader.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Loads the given class, and ignores all exceptions which may occur
 * during the loading. If the class was invalid, null is returned instead.
 *
 * @param className the name of the class to be loaded.
 * @return the class or null.
 */
protected Class loadClass(final String className) {
    if (className == null) {
        return null;
    }
    if (className.startsWith("::")) {
        return BasicTypeSupport.getClassRepresentation(className);
    }
    try {
        return ObjectUtilities.getClassLoader(getClass()).loadClass(className);
    }
    catch (Exception e) {
        // ignore buggy classes for now ..
        Log.warn("Unable to load class", e);
        return null;
    }
}
 
Example #21
Source File: AbstractBoot.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Loads the specified booter implementation.
 *
 * @param classname  the class name.
 *
 * @return The boot class.
 */
protected AbstractBoot loadBooter(final String classname) {
    if (classname == null) {
        return null;
    }
    try {
        final Class c = ObjectUtilities.getClassLoader(
                getClass()).loadClass(classname);
        final Method m = c.getMethod("getInstance", (Class[]) null);
        return (AbstractBoot) m.invoke(null, (Object[]) null);
    }
    catch (Exception e) {
        Log.info ("Unable to boot dependent class: " + classname);
        return null;
    }
}
 
Example #22
Source File: DefaultLogModule.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Initalizes the module. This method initializes the logging system, if the
 * System.out logtarget is selected.
 *
 * @param subSystem the sub-system.
 * @throws ModuleInitializeException if an error occured.
 */
public void initialize(final SubSystem subSystem)
        throws ModuleInitializeException
{
  if (LogConfiguration.isDisableLogging())
  {
    return;
  }

  if (LogConfiguration.getLogTarget().equals
          (PrintStreamLogTarget.class.getName()))
  {
    DefaultLog.installDefaultLog();
    Log.getInstance().addTarget(new PrintStreamLogTarget());

    if ("true".equals(subSystem.getGlobalConfig().getConfigProperty
            ("org.jfree.base.LogAutoInit")))
    {
      Log.getInstance().init();
    }
    Log.info("Default log target started ... previous log messages " +
            "could have been ignored.");
  }
}
 
Example #23
Source File: ObjectFactoryLoader.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Starts a object definition. The object definition collects all properties of
 * an bean-class and defines, which constructor should be used when creating the
 * class.
 *
 * @param className the class name of the defined object
 * @param register the (optional) register name, to lookup and reference the object later.
 * @param ignore  ignore?
 * 
 * @return true, if the definition was accepted, false otherwise.
 * @throws ObjectDescriptionException if an unexpected error occured.
 */
protected boolean startObjectDefinition(final String className, final String register, final boolean ignore)
    throws ObjectDescriptionException {

    if (ignore) {
        return false;
    }
    this.target = loadClass(className);
    if (this.target == null) {
        Log.warn(new Log.SimpleMessage("Failed to load class ", className));
        return false;
    }
    this.registerName = register;
    this.propertyDefinition = new ArrayList();
    this.attributeDefinition = new ArrayList();
    this.constructorDefinition = new ArrayList();
    this.lookupDefinitions = new ArrayList();
    this.orderedNames = new ArrayList();
    return true;
}
 
Example #24
Source File: PackageManager.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Loads all modules mentioned in the report configuration starting with
 * the given prefix. This method is used during the boot process of
 * JFreeReport. You should never need to call this method directly.
 *
 * @param modulePrefix the module prefix.
 */
public void load(final String modulePrefix) {
    if (this.initSections.contains(modulePrefix)) {
        return;
    }
    this.initSections.add(modulePrefix);

    final Configuration config = this.booter.getGlobalConfig();
    final Iterator it = config.findPropertyKeys(modulePrefix);
    int count = 0;
    while (it.hasNext()) {
        final String key = (String) it.next();
        if (key.endsWith(".Module")) {
            final String moduleClass = config.getConfigProperty(key);
            if (moduleClass != null && moduleClass.length() > 0) {
                addModule(moduleClass);
                count++;
            }
        }
    }
    Log.debug("Loaded a total of " + count + " modules under prefix: " + modulePrefix);
}
 
Example #25
Source File: ChartConstants.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * @return java.awt.Stroke for JFreeChart renderer to draw lines
 */
public static Stroke translateLineStyle( float lineWidth, final String lineStyle ) {
  // Negative linewidths not allowed, reset to default.
  if ( lineWidth < 0 ) {
    Log.error( ( "LineChartExpression.ERROR_0001_INVALID_LINE_WIDTH" ) ); //$NON-NLS-1$
    lineWidth = 1.0f;
  }

  final int strokeType;
  if ( LINE_STYLE_DASH_STR.equals( lineStyle ) ) {
    strokeType = StrokeUtility.STROKE_DASHED;
  } else if ( LINE_STYLE_DOT_STR.equals( lineStyle ) ) {
    strokeType = StrokeUtility.STROKE_DOTTED;
  } else if ( LINE_STYLE_DASHDOT_STR.equals( lineStyle ) ) {
    strokeType = StrokeUtility.STROKE_DOT_DASH;
  } else if ( LINE_STYLE_DASHDOTDOT_STR.equals( lineStyle ) ) {
    strokeType = StrokeUtility.STROKE_DOT_DOT_DASH;
  } else {
    if ( lineWidth == 0 ) {
      strokeType = StrokeUtility.STROKE_NONE;
    } else {
      strokeType = StrokeUtility.STROKE_SOLID;
    }
  }

  return StrokeUtility.createStroke( strokeType, lineWidth );
}
 
Example #26
Source File: ReadTestCaseExecutionMedia.java    From cerberus-source with GNU General Public License v3.0 5 votes vote down vote up
private void returnPDF(HttpServletRequest request, HttpServletResponse response, TestCaseExecutionFile tc, String filePath) {

        File pdfFile = null;
        filePath = StringUtil.addSuffixIfNotAlready(filePath, File.separator);
        pdfFile = new File(filePath + tc.getFileName());
        response.setContentType("application/pdf");
        response.setContentLength((int) pdfFile.length());
        try {
            Files.copy(pdfFile, response.getOutputStream());
        } catch (IOException e) {
            Log.warn(e);
        }

    }
 
Example #27
Source File: GitLabSecurityRealm.java    From gitlab-oauth-plugin with MIT License 5 votes vote down vote up
private String extractToken(String content) {

        try {
            ObjectMapper mapper = new ObjectMapper();
            JsonNode jsonTree = mapper.readTree(content);
            JsonNode node = jsonTree.get("access_token");
            if (node != null) {
                return node.asText();
            }
        } catch (IOException e) {
            Log.error(e.getMessage(), e);
        }
        return null;
    }
 
Example #28
Source File: MTGDavFolderResource.java    From MtgDesktopCompanion with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void delete() throws NotAuthorizedException, ConflictException, BadRequestException {
	try {
		Files.deleteIfExists(mtgpath);
	} catch (IOException e) {
		Log.error("error delete()",e);
		throw new BadRequestException(this);
	}
}
 
Example #29
Source File: PIDGraph.java    From BowlerStudio with GNU General Public License v3.0 5 votes vote down vote up
public void run(){
	while (true){
		ThreadUtil.wait(50);
		if(lastData[0] != data[0] || lastData[1]!=data[1]){
			lastData[0]=data[0];
			lastData[1]=data[1];
			try{
				
				
				double time = (System.currentTimeMillis()-startTime);
				
				dataTable.add(new GraphDataElement((long) time,data));
				XYDataItem s = new XYDataItem(time,data[0]);
				XYDataItem p = new XYDataItem(time,data[1]);

				if(setpoints.getItemCount()>99){
					setpoints.remove(0);
				}
				setpoints.add(s);
				
				if(positions.getItemCount()>99){
					positions.remove(0);
				}
				positions.add(p);

			}catch(Exception e){
				System.err.println("Failed to set a data point");
				e.printStackTrace();
				Log.error(e);
				Log.error(e.getStackTrace());
				init();
			}
		}
	}
}
 
Example #30
Source File: XmlUtil.java    From cerberus-source with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns a {@link Document} from the given {@link Node}
 *
 * @param node to transform to {@link Document}
 * @return a {@link Document} from the given {@link Node}
 * @throws XmlUtilException if an error occurs
 */
public static Document fromNode(Node node) throws XmlUtilException {
    try {
        Document document = XmlUtil.newDocument();
        document.appendChild(document.adoptNode(node.cloneNode(true)));
        return document;
    } catch (DOMException e) {
        Log.warn("Unable to create document from node " + node, e);
        return null;
    }
}