waffel is currently certified at Journeyer level.

Name: Thomas Wabner
Member since: 2006-03-05 09:38:38
Last Login: 2008-06-26 08:05:52

FOAF RDF Share This

Homepage: http://www.eksor.de

Recent blog entries by waffel

Syndication: RSS 2.0

update wrong timestamp for a page in mediawiki

I had the problem, that one of my VMs, serving our wiki, got the wrong system date. The date was pointing to year 2018.

Some users of our wiki changed the content while the VM has the wrong date. After I see the problem I update the VM and re-connect it to NTP again and the time was corrected.

But, the paged changed in the the “wrong” timeframe are stored with this wrong timeframe in the wiki database.

Now every call on recent changes shows the pages, changed in the wrong timeframe” always at top (because of this future date).

Now I found a way to “fix” this in the database. To do this, you need access to your wiki DB with RW rights. I have done this on mysql (but these SQL statements should also work on other database systems):


update revision set rev_timestamp=20150101000000 where rev_timestamp > 20150108115205;

update recentchanges set rc_timestamp = 20150101000000 where rc_timestamp > 20150108115205;


Einsortiert unter:administration Tagged: mediawiki

Syndicated 2015-01-08 14:54:57 from waffel's Weblog

find and remove dead links

I asked myself the question, what would be the best way under linux to find and remove dead links?

Here is the short answer (only tested on bash):


find . -type l -exec sh -c "file -b {} | grep -q ^broken" \; -print | tr "\n" "" | xargs -0 rm


Einsortiert unter:administration Tagged: linux

Syndicated 2015-01-08 11:17:00 from waffel's Weblog

no running imapd / slapd under gentoo

Today, I discovered that my mailserver was down on a root server (running gentoo). I tried to search why and whats the problem.

  1. I see error messages, that some processes cannot connect to ldap
  2. I tried to use phpldapadmin to check whats wrong. Here I got the next error: Fatal error: Cannot redeclare password_hash()
  3. I changed the used php version from php-5.5 to php-5.4 … phpldapadmin again works, but I cannot login
  4. I see imapd segmentation faults in dmesg in libwrappers …so I guess there is a problem with sys-apps/tcp-wrappers
  5. I rebuild tcp-wrappers, restarting nearly all processed from /etc/init.d without success
  6. I get deeper into the logfiles of my server (needed to take a look into the live logfiles (which logs all into one file, which is heavy under a root server with many hosted domains)
  7. I see an error, that some processes (one was also slapd) cannot read /etc/hosts.deny
  8. I see, that only root has the permission to read /etc/hosts.deny
  9. I change the permission to get all a read of this file
  10. Restarting slapd and all stuff works again … what a pain

Feels like one of my living years are gone … sometimes I love, but sometimes I hate gentoo.

I do not know who has changed the permissions on this file … but if I found he/it … *g*


Einsortiert unter:administration, webmaster

Syndicated 2014-03-13 12:46:59 from waffel's Weblog

no CSS in mediawiki anymore

After upgrading my gentoo system, I discovered a problem with one of my new mediawiki installations:

No CSS anymore!

That’s frustrating. Looking with my browser tools, I see, that the load.php from mediawiki returns nothing. Searching around and found only one place which helped:

https://bugs.php.net/bug.php?id=64836 <– the bug entry on php.

Now I tried to downgrade my gentoo package sys-apps/file back to 5.11 and restarting my apache … viola … it works.

emerge =sys-apps/file-5.11

Now the load.php works again and it looks like, that this has nothing to do with mediawiki itself.


Einsortiert unter:administration, webmaster Tagged: bug, css, gentoo, mediawiki

Syndicated 2013-09-07 15:22:00 from waffel's Weblog

testing REST interface with Spring 3.2 and a session scoped bean

There are some nice articles around the “spring 3.2 testing capabilities” like the spring documentation itself, this blog and this blog.

I wanted to not only test one request/response action against my REST interface. I wanted to simulate and test more of a conversation as it typical happens in the UI.

Following REST interface I wanted to create and test:

@RequestMapping("/customer")
public interface RESTCustomer {

@RequestMapping(
method = RequestMethod.POST)
@ResponseBody
Customer create(@RequestParam("firstname") final String firstname,
@RequestParam("lastname") final String lastname);

@RequestMapping(
method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.OK)
void delete(@RequestParam("id") final String... customerIds);

@RequestMapping(
produces = MediaType.APPLICATION_JSON_VALUE,
method = RequestMethod.GET)
@ResponseBody
Collection<Customer> getAll();

@RequestMapping(
value = "/update",
method = RequestMethod.POST)
@ResponseBody
Customer update(@RequestParam("id") final String id, @RequestParam("firstname") final String firstname);

}

Following test steps I had in mind, to test the create method:

  1. Get a list of all customers and remember the count
  2. Create a new customer
  3. Check, that the ID of the returning Customer was updated
  4. Get again a list of all customers
  5. Check the size of the customer list before and after creation … they should differ between one entry/li>

The new Spring Framework version 3.2 introduced some nice feature to do REST testing with minimal effort.

To test such conversion, you need beside the WebApplicationContext a MockHttpSession which has to be used between different mockMvc calls, on one test case.

The following base test structure is required:

@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@ContextConfiguration(
  classes = {
    MyConfig.class,
  })
public class RESTCustomerTest {
  
@Autowired
  private WebApplicationContext wac;

  @Autowired
  MockHttpSession session;

  MockMvc mockMvc;

  ObjectMapper jsonObjectMapper;

  @Before
  public void setup() {
    mockMvc = MockMvcBuilders.webAppContextSetup(wac).build();
    jsonObjectMapper = new ObjectMapper();
  }

  @Test
  public void testCreate() throws Exception {
    ....
  }
}

Let assume, there is an implementation of the RESTCustomer service interface like this:


@Component
public class CustomerResource implements RESTCustomer {

  private final PlatformService service;

  @Autowired
  public CustomerResource(final PlatformService service) {
    this.service = service;
  }

  @Override
  public Customer create(final String firstname, final String lastname) {
    ...
    return service.createCustomer(firstname, lastname);
  }

  @Override
  public Collection<Customer> getAll() {
    ...
    return service.getAllCustomers();
  }

}

Assume also, that the autowired PlatformService is a Session scoped bean (somewhere configured inside the spring configuration).

Now our testing method can be like this:


  int countCustomers() throws Exception {
    final MvcResult mvcResult = mockMvc.perform(get("/customer").session(session).accept(MediaType.APPLICATION_JSON))
        .andReturn();
    final Collection<Customer> customers = getRawObjects(mvcResult);
    return customers.size();
  }

Collection<Customer> getRawObjects(final MvcResult mvcResult) throws Exception {
    return jsonObjectMapper.readValue(mvcResult.getResponse().getContentAsString(),
        new TypeReference<Collection<Customer>() {
        });
  }

Customer getRawObject(final MvcResult mvcResult) throws Exception {
    return jsonObjectMapper.readValue(mvcResult.getResponse().getContentAsString(),
        new TypeReference<Customer>() {
        });
  }

  @Test
  public void testCreate() throws Exception {
    // get default customer list and count
    final int originalCustomerSize = countCustomers();

    // create new customer
    final MvcResult mvcResult = mockMvc
        .perform(
            post("/customer/?firstname={firstname}&lastname={lastname}","testFirstname", "testLastName").session(session).accept(
                MediaType.APPLICATION_JSON)).andExpect(status().isOk()).andReturn();
    final Customer customerObject = getRawObject(mvcResult);
    assertNotNull("id of new customer should not empty", customerObject.get("id"));
    assertEquals("newly firstname should match", "testFirstname", customerObject.get("firstname");

    // again get list of all customers and check, if one more is available
    assertEquals("after new customer was created, the size should be one more", originalCustomerSize + 1, countCustomers());
  }

To get such conversation to work, you need to pass the session with .session(session) between the mockMvc calls. Else, every new mockMvc call creates a new session and your test fail.

REMEMBER: The trick is to pass the autowired MockHttpSession between the mock MVC requests.


Einsortiert unter:java, spring Tagged: base test, conversation, language java, mvc, REST, scope, session, spring, spring framework, test

Syndicated 2013-02-27 18:00:24 from waffel's Weblog

38 older entries...

 

waffel certified others as follows:

  • waffel certified ensonic as Master
  • waffel certified waffel as Journeyer

Others have certified waffel as follows:

  • ensonic certified waffel as Journeyer
  • cdfrey certified waffel as Journeyer
  • waffel certified waffel as Journeyer

[ Certification disabled because you're not logged in. ]

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!

X
Share this page