jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bram de Kruijff <Bram.deKrui...@gxwebmanager.com>
Subject Removing a corrupt reference value?
Date Fri, 10 Oct 2008 21:05:56 GMT
Hi list,



Does anyone know how to (force) remove a reference property value to a node that no longer
exists? I am using JackRabbit 1.3.3. I do not know how to reproduce it or how I got there
in the first place. Right now I just need to fix it.



My idea was simple. Find any (in my case multiple) property of type reference, check the uuids
that no longer exist, exclude them and reassign the sanitized value array (code below). This
approach seems to works until I hit save where I get a ReferentialIntegrityException on the
very UUID that I am trying to remove. It seems JR checks the references even when I just want
to delete them.



Any thoughts/tips/workaround?



Thanks,

Bram





Stacktrace:



javax.jcr.ReferentialIntegrityException: Target node 7ad67c91-fb52-481d-a3b=

3-f3708a390228 of REFERENCE property does not exist at org.apache.jackrabbit.core.state.SharedItemStateManager.checkReferential=

Integrity(SharedItemStateManager.java:1497)

at org.apache.jackrabbit.core.state.SharedItemStateManager$Update.begin(Sha=

redItemStateManager.java:594)

at org.apache.jackrabbit.core.state.SharedItemStateManager.beginUpdate(Shar=

edItemStateManager.java:904)

at org.apache.jackrabbit.core.state.SharedItemStateManager.update(SharedIte=

mStateManager.java:934)

at org.apache.jackrabbit.core.state.LocalItemStateManager.update(LocalItemS=

tateManager.java:326)

at org.apache.jackrabbit.core.state.XAItemStateManager.update(XAItemStateMa=

nager.java:313)

at org.apache.jackrabbit.core.state.LocalItemStateManager.update(LocalItemS=

tateManager.java:302)

at org.apache.jackrabbit.core.state.SessionItemStateManager.update(SessionI=

temStateManager.java:306)

at org.apache.jackrabbit.core.ItemImpl.save(ItemImpl.java:1400)

at org.apache.jackrabbit.core.SessionImpl.save(SessionImpl.java:849)





Snippet:



    // Check for corrupted references

    Value[] values =3D p.getValues();

    List<Value> corruptedValues =3D new ArrayList<Value>();

    for (Value v : values) {

        try {

            session.getNodeByUUID(v.getString());

        } catch (ItemNotFoundException e) {

            // Yep, we got one

            corruptedValues.add(v);

            LOG.log(Level.WARNING, "Corrupted reference found for node "

                    + n.getUUID().toString() + " property " + p.getName()

                    + " and value " + v.getString());

        }

    }

    if (corruptedValues.size() > 0) {



        // Exclude corrupted references

        List<Value> newValues =3D new ArrayList<Value>();

        for (Value v : values) {

            if (!corruptedValues.contains(v)) {

                newValues.add(v);

            }

        }

        Value[] result =3D newValues.toArray(new Value[newValues.size()]);



        // Re-Assign and save

        p.setValue(result);

    }




--
Bram de Kruijff
Product Architect

GX
open for business

t: +31(0)24 - 388 82 61
f: +31(0)24 - 388 86 21
e: Bram.deKruijff@gxwebmanager.com<mailto:Bram.deKruijff@gxwebmanager.com>

www.gxwebmanager.com<http://www.gxwebmanager.com>


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message