Older blog entries for waffel (starting at number 24)

using keychain under cygwin


If you want to use the keychain tool under cygwin to aviod entering your passwort for your external server again and agin, you may follow my short guide:

In the follow example I work on my home PC named master and want to use the keychain tool with my server test-server.de.

  1. Install the keychain tool under cygwin
  2. Start you cygwin bash and generate your own private and public key pair:
    ssh-keygen
    

    Of course you should set a password for your private key. The keys are now in $HOME/.ssh/

  3. Copy your public key from $HOME/.ssh/id_rsa.pub to your test-server.de (in a temporary folder)
  4. Login to your test-server.de
  5. Copy the content of your public key and insert it at the end of your $HOME/.ssh/known_host. If the file does not exists, create a new one.
  6. Logout from your test-server.de
  7. Now you can do the following every time you start your cygwin shell:
  8. Start the keychain tool with your private key:
    /usr/bin/keychain $HOME/.ssh/id_rsa
    
  9. Source the generated sh file from keychain:
    source $HOME/.keychain/master-sh
    

    Dependend of your hostname (in my example master) the file name from the keychain directory may differ.

To stop the ssh-agent (which is started in the background from the keychain tool) you may use

keychain -k all

If you have more than one server where you want to connect without retyping the password you can re run steps 3-6 from the guide.

Posted in software Tagged: bash, cygwin, generate, key, keychain, login, ssh, ssh-agent

Syndicated 2009-11-06 13:39:31 from waffel's Weblog

Calculate your training heart frequency


The formula to calculate your trainig heart frenquency is:

  • THF: training heart frequency
  • CA: chronological age
  • RHF: rest heart frequency

THF=220-CA-RHF*0,65+RHF

For example, if your age is 30 years and your rest heart frequency is 60, then your training heart frequency is 144,5. This means if you start your training (for example jogging) you can watch your pulse. You should then have minimal a pulse of 144,5 to have a training result (trains your heart and your circular flow).

Posted in medicine Tagged: frequency, heart, pulse, training

Syndicated 2009-11-02 12:59:13 from waffel's Weblog

Howto upgrade ]project-open[ 3.1 to vmware 3.2 version


We have a self compiled version of ]project-open[ version 3.1 running on our intranet server. Because there is no more support for this version and there is also no more any documentation about this version out there we have decided to switch to the ]project-open[ vmware 3.2 version. There are some steps required to get all data from 3.1 into the 3.2 installation.

First of all: Make a backup of your database!

  1. Login as admin into your 3.1 web interface and make a postges backup http://[YOUR_SERVER]/intranet/admin/backup/
  2. The backup data is now on your 3.1 machine under /web/projop/filesystemstorage/backup/[YOUR_BACKUP_FILE].sql .
  3. Download the ]project-open[ vmware image from sourceforge. Because we use virtualbox instead of vmware we mount the vmware image into our virtualbox.
  4. In virtualbox you have to select SCSI:1 as your harddisk interface because the vmware installation tries to mount /dev/sda1 as your root.
  5. after success start of the virtualbox you have to login as root (default password is root)
  6. Now you have to switch your runlevel to S (single user mode) with init S.
  7. In this runlevel you have to restart postgres with /etc/init.d/postgesql restart.
  8. Switch now from root to postgres with su - postgres.
  9. Connect to the postgresql master database template1 with psql template1
  10. Drop the projop database drop database projop;
  11. Now you can leave the postgresql shell with \q
  12. Create a new projop database createdb projop --owner projop
  13. Set postgres dialect for the database createlang plpqsql projop
  14. Import the tsearch2 tablees psql projop -f /web/projop/packages/intranet-search-pg/postgresql/tsearch2.sql
  15. Import your backup from the 3.1 system (copy the data from your 3.1 machine first) psql projop -f /web/projop/filesystemstorage/backup/[YOUR_BACKUP_FILE].sql
  16. Run the post patch psql projop -f /web/projop/preconf/poall.post-patch.sql
  17. Switch back to root exit
  18. Switch back to the runlevel 5 init 5
  19. Restart the postgresql system /etc/init.d/postgresql restart
  20. In you web browser you should now be able to login as administator (username and password from your old 3.1 system!)
  21. Update all enabled packages http://[YOUR_SERVER]/acs-admin/apm/packages-install?update_only_p=1
  22. Select on the page all packages which should be upgraded and start the update procedure (this may take any time)
  23. Restart the projop web server with http://[YOUR_SERVER]/acs-admin/server-restart

I hope thats all and your system is now running with ]project-open[ 3.2.

Posted in administration Tagged: project-open, update, upgrade, virtualbox, vmware

Syndicated 2009-10-02 10:05:02 from waffel's Weblog

bugs fixed for log4cpp


I have fixed some issues for log4cpp and hope I can go forward to clean up all outstanding tracker entries on sourceforge.

Log4cpp is a library of C++ classes for flexible logging to files, syslog, IDSA and other destinations. It is modeled after the Log for Java library (http://www.log4j.org), staying as close to their API as is reasonable.

Overview of fixed bugs:

I have also changed to current development version from 1.0 to 1.1 and hope I can push a bugfix release in the next month’s out.

There is also an interesting article with a good introduction and a small example from Sun.

Posted in cpp, log4cpp Tagged: bug, cpp, log4cpp, logging

Syndicated 2009-09-08 07:08:34 from waffel's Weblog

git over https failed to push some refs


I have tried to use our main git repository over https but I had gotten error messages like


PUT 54510da55977f5c1e47e5356b996762f4544b90d failed, aborting (22/403)
MKCOL 3b04e830cf4e221491e38443beac0f2f4a2e61c1 failed, aborting (22/403)
PUT 96496dc5f4115e3b9a90757410158f2ba7d12c80 failed, aborting (22/403)
MKCOL af7988694ce7cc8fbfd6b40deffe78d7231cffc8 failed, aborting (22/403)
Updating remote server info
error: failed to push some refs to 'https://myserver.de/myproject.git'

It was hard to discover whats going wrong here. I have set the GIT_CURL_VERBOSE=1 flag to see if there was an communication problem with my server. The communication itself was ok … but the server returns always a 403 (permission denied).

Next I had a look into my apache logs and I had seen follow error messages:


Permission denied: Unable to create a collection.

This looks like a file permission problem. I have setup a new group for my git repository and give apache the rights for read and write. But the problems still occured.

The solution was to set the correct Limit directive in the configuration for my git repository:


Alias /git /usr/var/git
<directory "/usr/var/git">
  DAV filesystem
  Options +Indexes

  AuthType Basic
  AuthName "git repositories"
  AuthUserFile /etc/apache/git.users.auth

  <limit GET PUT POST DELETE PROPPATCH MKCOL COPY MOVE LOCK UNLOCK>
    Require valid-user
  </limit>
</directory>

After a apache reload the push and pull commands working nice.

Posted in git Tagged: apache2, git, https, problem

Syndicated 2009-09-01 15:38:02 from waffel's Weblog

use your own variable in eclipse code templates


On my work we develop eclipse plugins and want to add the current bundle id and bundle version to the since field for class comments. There are not much examples around this problem (we have searched google and eclipse help) so let me explain how you can achive this.

For example we want to define follow code template:


/**
 * @author ${user}
 *
 * ${tags}
 * @since ${bundleId} ${bundleVersion}
 */

The bundleId and bundleVersion variable are not provided by the standard code template variables. Now we have to find out how we can achive this problem.

First of all you need to develop your own eclipse plugin which should provide such feature. The new plugin requires follow dependencies:

  • org.eclipse.core.resources;bundle-version=”3.5.0″,
  • org.eclipse.ui;bundle-version=”3.5.0″,
  • org.eclipse.jface.text;bundle-version=”3.5.0″,
  • org.eclipse.jdt.core;bundle-version=”3.5.0″,
  • org.eclipse.jdt.ui;bundle-version=”3.5.0″,
  • org.eclipse.core.runtime;bundle-version=”3.5.0″,
  • org.eclipse.pde.core;bundle-version=”3.5.0″

The PDE dependency is needed to get the current bundle id and the bundle version. If you need other features (for example a maven project version) you have depend on other plugins. But in this example I’ll show you how to add bundle id and bundle version as extra variable for the eclipse code templates.

Next you have to create a extention to register your own variable resolver at startup. The variable resolvers are the heart of the plugin because they providing new variables for the code templates to be used and resolving the content if you use the code template.

plugin.xml:


< ?xml version="1.0" encoding="UTF-8"?>
< ?eclipse version="3.4"?>
<plugin>
   <extension point="org.eclipse.ui.startup">
      <startup class="yourplugin.eclipse.javadoc.internal.RegisterResolvers">
      </startup>
   </extension>
</plugin>

The RegisterResolvers class implements the IStartup interface from eclipse. This class registers the variable resolvers to the code template context. This is required to have the variables available in the code templates from eclipse.

RegisterResolver:


/**
   *
   * {@inheritDoc}
   *
   * @see IStartup#earlyStartup()
   *
   */
  public void earlyStartup() {
    // check if plug-in org.eclipse.jdt.ui is already active
    final Bundle bundle = Platform.getBundle(PLUGIN_ID);
    if (bundle != null && bundle.getState() == Bundle.ACTIVE) {
      // register resolvers
      registerResolvers();
    } else {
      // register listener to get informed, when plug-in becomes active
      final BundleContext bundleContext = Activator.getDefault().getBundle().getBundleContext();
      bundleContext.addBundleListener(new BundleListener() {
        public void bundleChanged(final BundleEvent pEvent) {
          final Bundle bundle2 = pEvent.getBundle();
          if (!bundle2.getSymbolicName().equals(PLUGIN_ID)) {
            return;
          }
          if (bundle2.getState() == Bundle.ACTIVE) {
            registerResolvers();
            bundleContext.removeBundleListener(this);
          }
        }
      });
    }
  }

/**
   *
   * Internal method to register resolvers with all context types.
   *
   */
  private void registerResolvers() {
    final ContextTypeRegistry codeTemplateContextRegistry = JavaPlugin.getDefault().getCodeTemplateContextRegistry();
    final Iterator ctIter = codeTemplateContextRegistry.contextTypes();
    while (ctIter.hasNext()) {
      final TemplateContextType contextType = (TemplateContextType) ctIter.next();
      contextType.addResolver(new BundleIdResolver());
      contextType.addResolver(new BundleVersionResolver());

    }
  }

The bundleIdResolver extends the TemplateVariableResolver and defines (in the default constructor) the variable name which can be used later in the code template, a description and overrides the resolve method.

The resolve method checks if the current project is a plugin project and if so returns the bundle id from the project.


public class BundleIdResolver extends TemplateVariableResolver {
  /**
   *
   * Constructs a new <code>BundleIdResolver</code>.
   *
   */
  public BundleIdResolver() {
    super("bundleId", "id of the bundle containing the current compilation unit");
  }

  /**
   *
   * {@inheritDoc}
   *
   * @see TemplateVariableResolver#resolve(org.eclipse.jface.text.templates.TemplateContext)
   *
   */
  @Override
  protected String resolve(final TemplateContext pContext) {
    final CodeTemplateContext context = (CodeTemplateContext) pContext;
    final IPluginModelBase pluginModelBase = PluginRegistry.findModel(context.getJavaProject().getProject());
    if (pluginModelBase == null) {
      return null;
    }
    return pluginModelBase.getBundleDescription().getSymbolicName();
  }
}

Now you can come up with the question why not you can use the standard eclipse extention point mechanism and create your own context.

Well, we want to extend the java context but the current eclipse implementation doe’s not provide such functionality. For sure if you want to have your own context you can do this with the standard extention point mechanism (as the Ant example). There is a small example about the eclipse editor templates.

Thanks to my colleague Marco Lehmann for the complete solution.

Posted in java Tagged: code template, eclipse, java, plugin

Syndicated 2009-08-21 12:08:44 from waffel's Weblog

How to test spring session or request scope beans


Often you need test cases where you want to use spring configured beans from a existing spring configuration instead of writing mock objects.

In such cases you can use the spring ContextConfiguration class annotation to load your spring configurations. For test cases you may also extend the AbstractTestNGSpringContextTests which gives you nice test support facilities.

But how to test beans which using special scopes like session or request?

The AbstractTestNGSpringContextTests does not provide support to test scoped beans.

Our test module provides a SimpleMapScope implementation, which can be used for scoped beans. There is also a spring configuration for the scopes request and session: session-request-testscopes.xml which can be used as a ContextConfiguration location.

For example you can write follow simple test case:


....

@ContextConfiguration(locations = {"/org/waffel/test/session-request-testscopes.xml",
  "/org/waffel/my-app-beans.xml})
public class SimpleScopeBeansTest extends AbstractTestNGSpringContextTests {

  /**
   * A bean which is in scope session.
   */
  @Autowired
  @Qualifier("sessionScopedBean")
  private MyBean sessionScopedBean;

  @Test
  public void testAccessToBean() {
    AssertNotNull(sessionScopedBean);
  }

....

This test uses the test scope spring configuration and another spring configuration, where the sessionScopedBean is in scope session. With the autowired feature, you have instantly access to the bean. Also if the bean is in session or request scope.

The SimpleMapScope implementation:


package org.waffel.test.spring;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.ObjectFactory;
import org.springframework.beans.factory.config.Scope;

/**
 * This simple scope implementation uses internal a {@link Map} to hold objects
 * in the scope. This scope implementation can be used for testing beans which
 * wants to be stayed for example in session or request scope.
 * <p>
 * To use this scope in your test cases, simple configure a
 * {@link org.springframework.beans.factory.config.CustomScopeConfigurer} with
 * the required scope name:
 *
 * <pre>
 * &lt;bean class=&quot;org.springframework.beans.factory.config.CustomScopeConfigurer&quot;&gt;
 *   &lt;property name=&quot;scopes&quot;&gt;
 *     &lt;map&gt;
 *       &lt;entry key=&quot;session&quot;&gt;
 *         &lt;bean class=&quot;com.siemens.spice.dc.spring.SessionScope&quot; /&gt;
 *       &lt;/entry&gt;
 *     &lt;/map&gt;
 *   &lt;/property&gt;
 * &lt;/bean&gt;
 * </pre>
 *
 * Because the
 * {@link org.springframework.beans.factory.config.CustomScopeConfigurer} is a
 * {@link org.springframework.beans.factory.config.BeanPostProcessor} all
 * requested beans for the scope loaded with that post processor if the
 * registered scope match.
 * </p>
 *
 * @author waffel
 */
public class SimpleMapScope implements Scope {

  /**
   * This map contains for each bean name or ID the created object. The objects
   * are created with a spring object factory.
   */
  private final Map<string , Object> objectMap = new HashMap</string><string , Object>();

  /**
   * {@inheritDoc}
   */
  public Object get(final String theName, final ObjectFactory theObjectFactory) {
    Object object = objectMap.get(theName);
    if (null == object) {
      object = theObjectFactory.getObject();
      objectMap.put(theName, object);
    }
    return object;
  }

  /**
   * {@inheritDoc}
   */
  public String getConversationId() {
    return null;
  }

  /**
   * {@inheritDoc}
   */
  public void registerDestructionCallback(final String theName, final Runnable theCallback) {
    // nothing to do ... this is optional and not required
  }

  /**
   * {@inheritDoc}
   */
  public Object remove(final String theName) {
    return objectMap.remove(theName);
  }

}

The session-request-testscopes.xml source:


< ?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

  <bean class="org.springframework.beans.factory.config.CustomScopeConfigurer">
    <property name="scopes">
      <map>
        <entry key="session">
          <bean class="org.waffel.test.spring.SimpleMapScope" />
        </entry>
        <entry key="request">
          <bean class="org.waffel.test.spring.SimpleMapScope" />
        </entry>
      </map>
    </property>
  </bean>

</beans>

Another approach can be found in ahöhma’s weblog.

Posted in spring Tagged: java, request, scope, session, singleton, spring, test, TestNG, unit

Syndicated 2009-04-27 11:45:59 from waffel's Weblog

Article about Buzztard (Part one)


Dave Phillips wrotes a very nice article about one of may open source projects: buzztard.

I hope in the next month’s there is more time for me to work on buzztard. As you know I write mostly testcases and discuss with other developers about the software design.

Posted in software Tagged: buzztard, C, gnome, music, tracker

Syndicated 2009-02-20 18:14:39 from waffel's Weblog

how to use EL from java in a JSF 1.2 environment


There are not much examples, how to use a ELExpression from your java code. The most examples I found, are focussing on “implement your own ELResolver”. The best documentation comes from SUN in form of tutorials and package/javadoc.

Now I will provide some tips how to deal with EL expressions from java. I have tested and implemented this in a JSF 1.2 web application, where I have access to the FacesContext.

In JSF 1.2 you have access to expression factory:


// get application from faces context
Application app = FacesContext.getInstance().getApplication();
ExpressionFactory exprFactory = app.getExpressionFactory();

Now you can use the expression factory to get a MethodExpression or ValueExpression. In my projects we need very often ValueExpressions.

But first you need also an ELContext. There are many implementations available of such context (for JSP, Faces and so on) and enough documentation how to create your own context.
You can access such context again from the faces context:


// getting the ELContext from faces context
ELContext elContext = FacesContext.getInstance().getELContext();
// creating value expression with the help of the expression factory and the ELContext
ValueExpression valExpr = exprFactory.createValueExpression(elContext, "#{devBean.devMode}", Boolean.class);

In this example I will use the boolean value from a “devBean” to work later with this value. Of course, you can inject the value expression, required class type and so on.
The last needed thing is to assign the value to a local variable:


Boolean developmentMode = (Boolean) valExpr.getValue(elContext);

Thats it!

Posted in java, JSF, software   Tagged: EL, ELContext, JSF, JSF1.2   

Syndicated 2008-11-28 19:47:09 from waffel's Weblog

updating mediawiki is easy


I have updated some homepages to the brand new mediawiki version 1.13.2 which was very easy. They have a very good description what you have to do, if you update to a new version and a very nice update script which works also for very old wiki versions (I have tested this with the 1.4.5 version).

But there ara small problems with own skin (for example on http://www.buzztard.org). The skin have to be fixed per hand. Hopfully ensonic can do this the next days.

Posted in administration, software   Tagged: mediawiki, upgrade   

Syndicated 2008-11-13 12:33:10 from waffel's Weblog

15 older entries...

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!