Hi Dan,
Thanks for the options. It is resolved.
What I did is:
Instead of removing check in RootOidDefault and adding base32 encode and
decoing in OidMarshaller, I have added this base32 encoding and decoding in
Domain Object PK class toString() and constructor respectively as below:
public MUnitPK(String key){
this.unitId =
BaseEncoding.base32().encode(key.getBytes(Charset.forName("UTF-8")));
}
@Override
public String toString() {
return new String(BaseEncoding.base32().decode(str),
Charset.forName("UTF-8"));
}
I think it's better to have this encode/decode in OidMarshaller rather than
enforcing domain object. What's your opinion?
-----Original Message-----
From: Dan Haywood [mailto:[email protected]]
Sent: Tuesday, June 24, 2014 5:51 PM
To: users
Subject: Re: identifier 'com.wipro.wess.ods.munit.MUnitPK_#01' contains a '#'
symbol
On 24 June 2014 09:28, <[email protected]> wrote:
> Hi Dan,
> it is not limitation of OidMarshaller, but of RootOidDefault:
>
> Ensure.ensureThatArg(identifier, is(not(IsisMatchers.contains("#"))),
> "identifier '" + identifier + "' contains a '#' symbol");
>
>
>
Sounds about right.
>
>
>
> Please find below bit more of the stack trace:
>
> Thanks for providing this; it helps.
We can't just remove this constraint, however... as I said, the Oid is
serialized as part of the URL, and # is not allowable. So what we need to do
instead is provide a mechanism whereby your existing PK string can be encoded
(eg base64 encoded).
Options are:
- that the RootOidDefault automatically makes itself "safe"
- that the JdoObjectIdSerializer utility class (that converts from a JDO Id to
an Isis identifier) makes the id safe
- that the OidMarshaller - general purpose serialization of oids to strings, as
used by the wicket viewer, restful objects, bookmarks etc - makes the oid
string "safe".
I think I like the third option best, because this is really a "presentation"
constraint, not something that should be intrinsic to the domain
(RootOidDefault) or the persistence layer (JDO).
Whatever, I think this will need a new feature/improvement... there isn't
something that can just be configured right now.
For now, I think you'll need to recompile Isis from source, and try:
- removing the check in RootOidDefault
- adding in base64 encode/decode stuff in OidMarshaller#marshall and
#'unmarshall.
If it works for you, I'll use that as the basis for a proper ticket.
Sorry it's not better news...
Dan
> Caused by: java.lang.RuntimeException: java.lang.IllegalArgumentException:
> identifier 'com.wipro.wess.ods.munit.MUnitPK_#01' contains a '#' symbol
> at
> org.apache.isis.objectstore.jdo.datanucleus.persistence.FrameworkSynchronizer.withLogging(FrameworkSynchronizer.java:273)
> at
> org.apache.isis.objectstore.jdo.datanucleus.persistence.FrameworkSynchronizer.withLogging(FrameworkSynchronizer.java:282)
> at
> org.apache.isis.objectstore.jdo.datanucleus.persistence.FrameworkSynchronizer.postLoadProcessingFor(FrameworkSynchronizer.java:69)
> at
> org.apache.isis.objectstore.jdo.datanucleus.persistence.IsisLifecycleListener$1.doRun(IsisLifecycleListener.java:80)
> at
> org.apache.isis.objectstore.jdo.datanucleus.persistence.IsisLifecycleListener$RunnableAbstract.run(IsisLifecycleListener.java:201)
> at
> org.apache.isis.objectstore.jdo.datanucleus.persistence.IsisLifecycleListener.withLogging(IsisLifecycleListener.java:180)
> at
> org.apache.isis.objectstore.jdo.datanucleus.persistence.IsisLifecycleListener.postLoad(IsisLifecycleListener.java:76)
> at
> org.datanucleus.api.jdo.JDOCallbackHandler.postLoad(JDOCallbackHandler.java:304)
> at
> org.datanucleus.state.JDOStateManager.postLoad(JDOStateManager.java:4877)
> at
> org.datanucleus.state.JDOStateManager.loadFieldValues(JDOStateManager.java:2544)
> at
> org.datanucleus.state.JDOStateManager.initialiseForHollow(JDOStateManager.java:282)
> at
> org.apache.isis.objectstore.jdo.datanucleus.JDOStateManagerForIsis.initialiseForHollow(JDOStateManagerForIsis.java:60)
> at
> org.datanucleus.state.ObjectProviderFactoryImpl.newForHollow(ObjectProviderFactoryImpl.java:119)
> at
> org.datanucleus.ExecutionContextImpl.newObjectProviderForHollowPopulated(ExecutionContextImpl.java:1335)
> at
> org.datanucleus.ExecutionContextImpl.findObject(ExecutionContextImpl.java:3186)
> at
> org.datanucleus.store.rdbms.query.PersistentClassROF.getObjectForApplicationId(PersistentClassROF.java:480)
> at
> org.datanucleus.store.rdbms.query.PersistentClassROF.getObject(PersistentClassROF.java:375)
> at
> org.datanucleus.store.rdbms.query.ForwardQueryResult.nextResultSetElement(ForwardQueryResult.java:175)
> at
> org.datanucleus.store.rdbms.query.ForwardQueryResult$QueryResultIterator.next(ForwardQueryResult.java:379)
> at
> org.apache.isis.objectstore.jdo.datanucleus.persistence.queries.PersistenceQueryProcessorAbstract.loadAdapters(PersistenceQueryProcessorAbstract.java:79)
> at
> org.apache.isis.objectstore.jdo.datanucleus.persistence.queries.PersistenceQueryFindAllInstancesProcessor.process(PersistenceQueryFindAllInstancesProcessor.java:54)
> at
> org.apache.isis.objectstore.jdo.datanucleus.persistence.queries.PersistenceQueryFindAllInstancesProcessor.process(PersistenceQueryFindAllInstancesProcessor.java:34)
> at
> org.apache.isis.objectstore.jdo.datanucleus.DataNucleusObjectStore.processPersistenceQuery(DataNucleusObjectStore.java:542)
> at
> org.apache.isis.objectstore.jdo.datanucleus.DataNucleusObjectStore.loadInstancesAndAdapt(DataNucleusObjectStore.java:537)
> at
> org.apache.isis.core.runtime.system.persistence.PersistenceSession$1.execute(PersistenceSession.java:461)
> at
> org.apache.isis.core.runtime.system.persistence.PersistenceSession$1.execute(PersistenceSession.java:458)
> at
> org.apache.isis.core.runtime.system.transaction.IsisTransactionManager.executeWithinTransaction(IsisTransactionManager.java:217)
> at
> org.apache.isis.core.runtime.system.persistence.PersistenceSession.getInstancesFromPersistenceLayer(PersistenceSession.java:458)
> at
> org.apache.isis.core.runtime.system.persistence.PersistenceSession.getInstances(PersistenceSession.java:454)
> at
> org.apache.isis.core.runtime.system.persistence.PersistenceSession.findInstances(PersistenceSession.java:391)
> at
> org.apache.isis.core.runtime.system.persistence.PersistenceSession.findInstances(PersistenceSession.java:386)
> at
> org.apache.isis.core.runtime.persistence.internal.RuntimeContextFromSession$8.allMatchingQuery(RuntimeContextFromSession.java:260)
> at
> org.apache.isis.core.metamodel.services.container.DomainObjectContainerDefault.allMatches(DomainObjectContainerDefault.java:400)
> at
> org.apache.isis.core.metamodel.services.container.DomainObjectContainerDefault.allInstances(DomainObjectContainerDefault.java:361)
> at
> org.apache.isis.applib.AbstractContainedObject.allInstances(AbstractContainedObject.java:125)
> at
> com.wipro.wess.ods.uom.UOMMeasurementService.listAllMeasurementUnits(UOMMeasurementService.java:99)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:606)
> at
> org.apache.isis.core.progmodel.facets.actions.invoke.ActionInvocationFacetViaMethod.invoke(ActionInvocationFacetViaMethod.java:111)
> at
> org.apache.isis.core.runtime.transaction.facets.ActionInvocationFacetWrapTransaction$1.execute(ActionInvocationFacetWrapTransaction.java:56)
> at
> org.apache.isis.core.runtime.transaction.facets.ActionInvocationFacetWrapTransaction$1.execute(ActionInvocationFacetWrapTransaction.java:53)
> at
> org.apache.isis.core.runtime.system.transaction.IsisTransactionManager.executeWithinTransaction(IsisTransactionManager.java:217)
> at
> org.apache.isis.core.runtime.transaction.facets.ActionInvocationFacetWrapTransaction.invoke(ActionInvocationFacetWrapTransaction.java:53)
> at
> org.apache.isis.core.metamodel.specloader.specimpl.ObjectActionImpl.execute(ObjectActionImpl.java:345)
> at
> org.apache.isis.viewer.wicket.model.models.ActionModel.executeAction(ActionModel.java:434)
> at
> org.apache.isis.viewer.wicket.model.models.ActionModel.load(ActionModel.java:419)
> at
> org.apache.isis.viewer.wicket.model.models.ActionModel.load(ActionModel.java:59)
> at
> org.apache.wicket.model.LoadableDetachableModel.getObject(LoadableDetachableModel.java:121)
> at
> org.apache.isis.viewer.wicket.ui.components.actions.ActionPanel.executeActionHandlingApplicationExceptions(ActionPanel.java:287)
> at
> org.apache.isis.viewer.wicket.ui.components.actions.ActionPanel.executeActionOnTargetAndProcessResults(ActionPanel.java:206)
> at
> org.apache.isis.viewer.wicket.ui.components.actions.ActionPanel.executeActionAndProcessResults(ActionPanel.java:165)
> at
> org.apache.isis.viewer.wicket.ui.components.actions.ActionPanel.buildGui(ActionPanel.java:102)
> at
> org.apache.isis.viewer.wicket.ui.components.actions.ActionPanel.<init>(ActionPanel.java:95)
> at
> org.apache.isis.viewer.wicket.ui.components.actions.ActionPanelFactory.createComponent(ActionPanelFactory.java:49)
> at
> org.apache.isis.viewer.wicket.ui.ComponentFactoryAbstract.createComponent(ComponentFactoryAbstract.java:82)
> at
> org.apache.isis.viewer.wicket.viewer.registries.components.ComponentFactoryRegistryDefault.createComponent(ComponentFactoryRegistryDefault.java:120)
> at
> org.apache.isis.viewer.wicket.viewer.registries.components.ComponentFactoryRegistryDefault.addOrReplaceComponent(ComponentFactoryRegistryDefault.java:105)
> at
> org.apache.isis.viewer.wicket.ui.pages.PageAbstract.addComponent(PageAbstract.java:281)
> at
> org.apache.isis.viewer.wicket.ui.pages.PageAbstract.addChildComponents(PageAbstract.java:276)
> at
> org.apache.isis.viewer.wicket.ui.pages.action.ActionPage.<init>(ActionPage.java:54)
> ... 46 more
> Caused by: java.lang.IllegalArgumentException: identifier
> 'com.wipro.wess.ods.munit.MUnitPK_#01' contains a '#' symbol
> at
> org.apache.isis.core.commons.ensure.Ensure.ensureThatArg(Ensure.java:75)
> at
> org.apache.isis.core.metamodel.adapter.oid.RootOidDefault.<init>(RootOidDefault.java:127)
> at
> org.apache.isis.core.metamodel.adapter.oid.RootOidDefault.<init>(RootOidDefault.java:96)
> at
> org.apache.isis.core.runtime.system.persistence.OidGenerator.createPersistentOrViewModelOid(OidGenerator.java:106)
> at
> org.apache.isis.objectstore.jdo.datanucleus.persistence.FrameworkSynchronizer$1.run(FrameworkSynchronizer.java:108)
> at
> org.apache.isis.objectstore.jdo.datanucleus.persistence.FrameworkSynchronizer$7.call(FrameworkSynchronizer.java:286)
> at
> org.apache.isis.objectstore.jdo.datanucleus.persistence.FrameworkSynchronizer$7.call(FrameworkSynchronizer.java:282)
> at
> org.apache.isis.objectstore.jdo.datanucleus.persistence.FrameworkSynchronizer.withLogging(FrameworkSynchronizer.java:271)
> ... 107 more
>
>
> Actually it is Legacy data which is master data with pre-filled data.
> And its required that this Domain object need to have special symbols
> and # is one of them.
>
> So how to deal with this issue then. Please help.
>
> -----Original Message-----
> From: Dan Haywood [mailto:[email protected]]
> Sent: Thursday, June 19, 2014 6:37 PM
> To: users
> Subject: Re: identifier 'com.wipro.wess.ods.munit.MUnitPK_#01'
> contains a '#' symbol
>
> On 19 June 2014 08:18, <[email protected]> wrote:
>
> > Hi,
> >
> > When a domain object has "#" symbol in its Primary key(of String
> > type) and try to query it, following exception is thrown:
> > Caused by: java.lang.IllegalArgumentException: identifier
> > 'com.wipro.wess.ods.munit.MUnitPK_#01' contains a '#' symbol
> > at
> > org.apache.isis.core.commons.ensure.Ensure.ensureThatArg(Ensure.java
> > :7
> > 5)
> >
> >
> >
> A bit more of the stacktrace would be useful....
>
>
>
>
> > Why this character be excluded in the identifier.
> >
> >
> ... but I can make a guess.
>
> My first guess (turns out to be wrong) is that this is a reserved
> character for the string form of OIDs. (As you probably know) Isis
> creates an Oid as its internal identifier, holding both the object's
> type and Id; this is then present in the URL of the Wicket viewer and
> the Restful Objects viewer.
>
> If you look at the OidMarshaller class [1] you can see that there's a
> bunch of characters that have special meanings, and so cannot be used
> in the primary key of your string.
>
>
> That said, if you look at that list, it doesn't include the '#'
> symbol, so in this case it isn't a limitation in the OidMarshaller.
> So my second guess is that we don't allow '#' because - as I mentioned
> just above - OIDs appear in the URLs of the Wicket and RO viewer. The
> '#' symbol is used as an anchor in URLs, so is disallowed for URLs.
> (Not sure where we actually enforce that rule, but I guess we are somewhere).
>
> HTH
> Dan
>
>
> [1]
>
> https://github.com/apache/isis/blob/98fa9f2d9204166c1b9168d1f0839dd161
> d0e61e/core/metamodel/src/test/java/org/apache/isis/core/metamodel/ada
> pter/oid/OidMarshallerTest_unmarshal.java
>
>
>
>
>
> > Please help.
> >
> > BR
> > Ranganath Varma
> >
> > The information contained in this electronic message and any
> > attachments to this message are intended for the exclusive use of
> > the
> > addressee(s) and may contain proprietary, confidential or privileged
> > information. If you are not the intended recipient, you should not
> > disseminate, distribute or copy this e-mail. Please notify the
> > sender immediately and destroy all copies of this message and any
> > attachments.
> >
> > WARNING: Computer viruses can be transmitted via email. The
> > recipient should check this email and any attachments for the presence of
> > viruses.
> > The company accepts no liability for any damage caused by any virus
> > transmitted by this email.
> >
> > www.wipro.com
> >
>
> The information contained in this electronic message and any
> attachments to this message are intended for the exclusive use of the
> addressee(s) and may contain proprietary, confidential or privileged
> information. If you are not the intended recipient, you should not
> disseminate, distribute or copy this e-mail. Please notify the sender
> immediately and destroy all copies of this message and any attachments.
>
> WARNING: Computer viruses can be transmitted via email. The recipient
> should check this email and any attachments for the presence of viruses.
> The company accepts no liability for any damage caused by any virus
> transmitted by this email.
>
> www.wipro.com
>
The information contained in this electronic message and any attachments to
this message are intended for the exclusive use of the addressee(s) and may
contain proprietary, confidential or privileged information. If you are not the
intended recipient, you should not disseminate, distribute or copy this e-mail.
Please notify the sender immediately and destroy all copies of this message and
any attachments.
WARNING: Computer viruses can be transmitted via email. The recipient should
check this email and any attachments for the presence of viruses. The company
accepts no liability for any damage caused by any virus transmitted by this
email.
www.wipro.com