You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@isis.apache.org by ch...@wipro.com on 2014/06/19 09:18:37 UTC

identifier 'com.wipro.wess.ods.munit.MUnitPK_#01' contains a '#' symbol

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:75)


Why this character be excluded in the identifier.

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

RE: identifier 'com.wipro.wess.ods.munit.MUnitPK_#01' contains a '#' symbol

Posted by ch...@wipro.com.
I am not complaining about the class name. But the value of primary key of a domain Object instance.

-----Original Message-----
From: Rade, Joerg / Kuehne + Nagel / Ham GI-PS [mailto:Joerg.Rade@Kuehne-Nagel.com] 
Sent: Thursday, June 19, 2014 1:24 PM
To: users@isis.apache.org
Subject: AW: identifier 'com.wipro.wess.ods.munit.MUnitPK_#01' contains a '#' symbol

Hi,

this is not specific to apache isis. According to http://docs.oracle.com/javase/specs/jls/se7/html/jls-3.html#jls-3.8 # does not belong to the allowed characters for class names.

I'm using eclipse which does not even allow me to create such a class.

Best regards
Jörg

Kühne + Nagel (AG & Co.) KG
Rechtsform: Kommanditgesellschaft, Bremen HRA 21928, USt-IdNr.: DE 812773878.
Geschäftsleitung Kühne + Nagel (AG & Co.) KG: Reiner Heiken (Vors.), Dirk Blesius, Martin Brinkmann, Holger Ketz, Jan-Hendrik Köstergarten, Christian Marnetté, Christian Solf, Jens Wollesen.
Persönlich haftende Gesellschafterin: Kühne & Nagel A.G., Rechtsform: Aktiengesellschaft nach luxemburgischem Recht, HR-Nr.: B 18745, Geschäftsführendes Verwaltungsratsmitglied: Karl Gernandt.
Geschäftsleitung Region Westeuropa: Yngve Ruud (Vors.), Hans-Georg Brinkmann (Stellv.), Richard Huhn, Björn Johansson, Bruno Mang, Stefan Paul, Tim Scharwath, Dominic Edmonds, Peder Winther.

Wir arbeiten ausschließlich auf Grundlage der Allgemeinen Deutschen Spediteursbedingungen (ADSp), jeweils neuester Fassung. Wir verweisen insbesondere auf die vom Gesetz abweichenden Haftungsbeschränkungen von Ziffer 23 und 24 ADSp. Den vollständigen Text der ADSp übersenden wir Ihnen gerne auf Anfrage und können Sie auch unter http://www.kuehne-nagel.com einsehen. Ergänzend wird vereinbart, dass (1) Ziffer 27 ADSp im Rahmen internationaler Übereinkommen weder unsere Haftung noch die Zurechnung des Verschuldens von Leuten und sonstigen Dritten zu Gunsten des Auftraggebers erweitert, und (2) wir in den im deutschen Seehandelsrecht aufgeführten Fällen des nautischen Verschuldens oder Feuer an Bord nur für eigenes Verschulden und (3) im Sinne der CMNI genannten Voraussetzungen nicht für nautisches Verschulden, Feuer an Bord oder Mängel des Schiffes haften.

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

AW: identifier 'com.wipro.wess.ods.munit.MUnitPK_#01' contains a '#' symbol

Posted by "Rade, Joerg / Kuehne + Nagel / Ham GI-PS" <Jo...@Kuehne-Nagel.com>.
Hi,

this is not specific to apache isis. According to http://docs.oracle.com/javase/specs/jls/se7/html/jls-3.html#jls-3.8 # does not belong to the allowed characters for class names.

I'm using eclipse which does not even allow me to create such a class.

Best regards
Jörg

Kühne + Nagel (AG & Co.) KG
Rechtsform: Kommanditgesellschaft, Bremen HRA 21928, USt-IdNr.: DE 812773878.
Geschäftsleitung Kühne + Nagel (AG & Co.) KG: Reiner Heiken (Vors.), Dirk Blesius, Martin Brinkmann, Holger Ketz, Jan-Hendrik Köstergarten, Christian Marnetté, Christian Solf, Jens Wollesen.
Persönlich haftende Gesellschafterin: Kühne & Nagel A.G., Rechtsform: Aktiengesellschaft nach luxemburgischem Recht, HR-Nr.: B 18745, Geschäftsführendes Verwaltungsratsmitglied: Karl Gernandt.
Geschäftsleitung Region Westeuropa: Yngve Ruud (Vors.), Hans-Georg Brinkmann (Stellv.), Richard Huhn, Björn Johansson, Bruno Mang, Stefan Paul, Tim Scharwath, Dominic Edmonds, Peder Winther.

Wir arbeiten ausschließlich auf Grundlage der Allgemeinen Deutschen Spediteursbedingungen (ADSp), jeweils neuester Fassung. Wir verweisen insbesondere auf die vom Gesetz abweichenden Haftungsbeschränkungen von Ziffer 23 und 24 ADSp. Den vollständigen Text der ADSp übersenden wir Ihnen gerne auf Anfrage und können Sie auch unter http://www.kuehne-nagel.com einsehen. Ergänzend wird vereinbart, dass (1) Ziffer 27 ADSp im Rahmen internationaler Übereinkommen weder unsere Haftung noch die Zurechnung des Verschuldens von Leuten und sonstigen Dritten zu Gunsten des Auftraggebers erweitert, und (2) wir in den im deutschen Seehandelsrecht aufgeführten Fällen des nautischen Verschuldens oder Feuer an Bord nur für eigenes Verschulden und (3) im Sinne der CMNI genannten Voraussetzungen nicht für nautisches Verschulden, Feuer an Bord oder Mängel des Schiffes haften.

RE: identifier 'com.wipro.wess.ods.munit.MUnitPK_#01' contains a '#' symbol

Posted by ch...@wipro.com.
ISIS-820 is created.

-----Original Message-----
From: Dan Haywood [mailto:dan@haywood-associates.co.uk] 
Sent: Tuesday, June 24, 2014 8:38 PM
To: users
Subject: Re: identifier 'com.wipro.wess.ods.munit.MUnitPK_#01' contains a '#' symbol

On 24 June 2014 14:06, <ch...@wipro.com> wrote:

> Hi Dan,
> Thanks for the options. It is resolved.
> What I did is:


[snip]


> I think it's better to have this encode/decode in OidMarshaller rather 
> than enforcing domain object. What's your opinion?
>
>
I think so too.

Glad you're resolved for now, but would you like to raise a ticket for me referencing this thread so we can solve this in the framework rather than require hacky domain logic/boilerplate?

thanks
Dan




>
> -----Original Message-----
> From: Dan Haywood [mailto:dan@haywood-associates.co.uk]
> 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, <ch...@wipro.com> 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.FrameworkSynch
> ronizer.withLogging(FrameworkSynchronizer.java:273)
> >         at
> >
> org.apache.isis.objectstore.jdo.datanucleus.persistence.FrameworkSynch
> ronizer.withLogging(FrameworkSynchronizer.java:282)
> >         at
> >
> org.apache.isis.objectstore.jdo.datanucleus.persistence.FrameworkSynch
> ronizer.postLoadProcessingFor(FrameworkSynchronizer.java:69)
> >         at
> >
> org.apache.isis.objectstore.jdo.datanucleus.persistence.IsisLifecycleL
> istener$1.doRun(IsisLifecycleListener.java:80)
> >         at
> >
> org.apache.isis.objectstore.jdo.datanucleus.persistence.IsisLifecycleL
> istener$RunnableAbstract.run(IsisLifecycleListener.java:201)
> >         at
> >
> org.apache.isis.objectstore.jdo.datanucleus.persistence.IsisLifecycleL
> istener.withLogging(IsisLifecycleListener.java:180)
> >         at
> >
> org.apache.isis.objectstore.jdo.datanucleus.persistence.IsisLifecycleL
> istener.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(JDOStateMana
> ger.java:282)
> >         at
> >
> org.apache.isis.objectstore.jdo.datanucleus.JDOStateManagerForIsis.ini
> tialiseForHollow(JDOStateManagerForIsis.java:60)
> >         at
> >
> org.datanucleus.state.ObjectProviderFactoryImpl.newForHollow(ObjectPro
> viderFactoryImpl.java:119)
> >         at
> >
> org.datanucleus.ExecutionContextImpl.newObjectProviderForHollowPopulat
> ed(ExecutionContextImpl.java:1335)
> >         at
> >
> org.datanucleus.ExecutionContextImpl.findObject(ExecutionContextImpl.j
> ava:3186)
> >         at
> >
> org.datanucleus.store.rdbms.query.PersistentClassROF.getObjectForAppli
> cationId(PersistentClassROF.java:480)
> >         at
> >
> org.datanucleus.store.rdbms.query.PersistentClassROF.getObject(Persist
> entClassROF.java:375)
> >         at
> >
> org.datanucleus.store.rdbms.query.ForwardQueryResult.nextResultSetElem
> ent(ForwardQueryResult.java:175)
> >         at
> >
> org.datanucleus.store.rdbms.query.ForwardQueryResult$QueryResultIterat
> or.next(ForwardQueryResult.java:379)
> >         at
> >
> org.apache.isis.objectstore.jdo.datanucleus.persistence.queries.Persis
> tenceQueryProcessorAbstract.loadAdapters(PersistenceQueryProcessorAbst
> ract.java:79)
> >         at
> >
> org.apache.isis.objectstore.jdo.datanucleus.persistence.queries.Persis
> tenceQueryFindAllInstancesProcessor.process(PersistenceQueryFindAllIns
> tancesProcessor.java:54)
> >         at
> >
> org.apache.isis.objectstore.jdo.datanucleus.persistence.queries.Persis
> tenceQueryFindAllInstancesProcessor.process(PersistenceQueryFindAllIns
> tancesProcessor.java:34)
> >         at
> >
> org.apache.isis.objectstore.jdo.datanucleus.DataNucleusObjectStore.pro
> cessPersistenceQuery(DataNucleusObjectStore.java:542)
> >         at
> >
> org.apache.isis.objectstore.jdo.datanucleus.DataNucleusObjectStore.loa
> dInstancesAndAdapt(DataNucleusObjectStore.java:537)
> >         at
> >
> org.apache.isis.core.runtime.system.persistence.PersistenceSession$1.e
> xecute(PersistenceSession.java:461)
> >         at
> >
> org.apache.isis.core.runtime.system.persistence.PersistenceSession$1.e
> xecute(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.get
> InstancesFromPersistenceLayer(PersistenceSession.java:458)
> >         at
> >
> org.apache.isis.core.runtime.system.persistence.PersistenceSession.get
> Instances(PersistenceSession.java:454)
> >         at
> >
> org.apache.isis.core.runtime.system.persistence.PersistenceSession.fin
> dInstances(PersistenceSession.java:391)
> >         at
> >
> org.apache.isis.core.runtime.system.persistence.PersistenceSession.fin
> dInstances(PersistenceSession.java:386)
> >         at
> >
> org.apache.isis.core.runtime.persistence.internal.RuntimeContextFromSe
> ssion$8.allMatchingQuery(RuntimeContextFromSession.java:260)
> >         at
> >
> org.apache.isis.core.metamodel.services.container.DomainObjectContaine
> rDefault.allMatches(DomainObjectContainerDefault.java:400)
> >         at
> >
> org.apache.isis.core.metamodel.services.container.DomainObjectContaine
> rDefault.allInstances(DomainObjectContainerDefault.java:361)
> >         at
> >
> org.apache.isis.applib.AbstractContainedObject.allInstances(AbstractCo
> ntainedObject.java:125)
> >         at
> >
> com.wipro.wess.ods.uom.UOMMeasurementService.listAllMeasurementUnits(U
> OMMeasurementService.java:99)
> >         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >         at
> >
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.j
> ava:57)
> >         at
> >
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
> orImpl.java:43)
> >         at java.lang.reflect.Method.invoke(Method.java:606)
> >         at
> >
> org.apache.isis.core.progmodel.facets.actions.invoke.ActionInvocationF
> acetViaMethod.invoke(ActionInvocationFacetViaMethod.java:111)
> >         at
> >
> org.apache.isis.core.runtime.transaction.facets.ActionInvocationFacetW
> rapTransaction$1.execute(ActionInvocationFacetWrapTransaction.java:56)
> >         at
> >
> org.apache.isis.core.runtime.transaction.facets.ActionInvocationFacetW
> rapTransaction$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.ActionInvocationFacetW
> rapTransaction.invoke(ActionInvocationFacetWrapTransaction.java:53)
> >         at
> >
> org.apache.isis.core.metamodel.specloader.specimpl.ObjectActionImpl.ex
> ecute(ObjectActionImpl.java:345)
> >         at
> >
> org.apache.isis.viewer.wicket.model.models.ActionModel.executeAction(A
> ctionModel.java:434)
> >         at
> >
> org.apache.isis.viewer.wicket.model.models.ActionModel.load(ActionMode
> l.java:419)
> >         at
> >
> org.apache.isis.viewer.wicket.model.models.ActionModel.load(ActionMode
> l.java:59)
> >         at
> >
> org.apache.wicket.model.LoadableDetachableModel.getObject(LoadableDeta
> chableModel.java:121)
> >         at
> >
> org.apache.isis.viewer.wicket.ui.components.actions.ActionPanel.execut
> eActionHandlingApplicationExceptions(ActionPanel.java:287)
> >         at
> >
> org.apache.isis.viewer.wicket.ui.components.actions.ActionPanel.execut
> eActionOnTargetAndProcessResults(ActionPanel.java:206)
> >         at
> >
> org.apache.isis.viewer.wicket.ui.components.actions.ActionPanel.execut
> eActionAndProcessResults(ActionPanel.java:165)
> >         at
> >
> org.apache.isis.viewer.wicket.ui.components.actions.ActionPanel.buildG
> ui(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.createCompon
> ent(ComponentFactoryAbstract.java:82)
> >         at
> >
> org.apache.isis.viewer.wicket.viewer.registries.components.ComponentFa
> ctoryRegistryDefault.createComponent(ComponentFactoryRegistryDefault.j
> ava:120)
> >         at
> >
> org.apache.isis.viewer.wicket.viewer.registries.components.ComponentFa
> ctoryRegistryDefault.addOrReplaceComponent(ComponentFactoryRegistryDef
> ault.java:105)
> >         at
> >
> org.apache.isis.viewer.wicket.ui.pages.PageAbstract.addComponent(PageA
> bstract.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>(Action
> Page.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>(RootO
> idDefault.java:127)
> >         at
> >
> org.apache.isis.core.metamodel.adapter.oid.RootOidDefault.<init>(RootO
> idDefault.java:96)
> >         at
> >
> org.apache.isis.core.runtime.system.persistence.OidGenerator.createPer
> sistentOrViewModelOid(OidGenerator.java:106)
> >         at
> >
> org.apache.isis.objectstore.jdo.datanucleus.persistence.FrameworkSynch
> ronizer$1.run(FrameworkSynchronizer.java:108)
> >         at
> >
> org.apache.isis.objectstore.jdo.datanucleus.persistence.FrameworkSynch
> ronizer$7.call(FrameworkSynchronizer.java:286)
> >         at
> >
> org.apache.isis.objectstore.jdo.datanucleus.persistence.FrameworkSynch
> ronizer$7.call(FrameworkSynchronizer.java:282)
> >         at
> >
> org.apache.isis.objectstore.jdo.datanucleus.persistence.FrameworkSynch
> ronizer.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:dan@haywood-associates.co.uk]
> > 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, <ch...@wipro.com> 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.ja
> > > va
> > > :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/98fa9f2d9204166c1b9168d1f0839dd1
> > 61 
> > d0e61e/core/metamodel/src/test/java/org/apache/isis/core/metamodel/a
> > da 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
>

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

Re: identifier 'com.wipro.wess.ods.munit.MUnitPK_#01' contains a '#' symbol

Posted by Dan Haywood <da...@haywood-associates.co.uk>.
On 24 June 2014 14:06, <ch...@wipro.com> wrote:

> Hi Dan,
> Thanks for the options. It is resolved.
> What I did is:


[snip]


> I think it's better to have this encode/decode in OidMarshaller rather
> than enforcing domain object. What's your opinion?
>
>
I think so too.

Glad you're resolved for now, but would you like to raise a ticket for me
referencing this thread so we can solve this in the framework rather than
require hacky domain logic/boilerplate?

thanks
Dan




>
> -----Original Message-----
> From: Dan Haywood [mailto:dan@haywood-associates.co.uk]
> 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, <ch...@wipro.com> 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:dan@haywood-associates.co.uk]
> > 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, <ch...@wipro.com> 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
>

RE: identifier 'com.wipro.wess.ods.munit.MUnitPK_#01' contains a '#' symbol

Posted by ch...@wipro.com.
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:dan@haywood-associates.co.uk] 
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, <ch...@wipro.com> 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:dan@haywood-associates.co.uk]
> 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, <ch...@wipro.com> 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

Re: identifier 'com.wipro.wess.ods.munit.MUnitPK_#01' contains a '#' symbol

Posted by Dan Haywood <da...@haywood-associates.co.uk>.
On 24 June 2014 09:28, <ch...@wipro.com> 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:dan@haywood-associates.co.uk]
> 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, <ch...@wipro.com> 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/98fa9f2d9204166c1b9168d1f0839dd161d0e61e/core/metamodel/src/test/java/org/apache/isis/core/metamodel/adapter/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
>

RE: identifier 'com.wipro.wess.ods.munit.MUnitPK_#01' contains a '#' symbol

Posted by ch...@wipro.com.
Hi Dan, 
it is not limitation of OidMarshaller, but of RootOidDefault:

Ensure.ensureThatArg(identifier, is(not(IsisMatchers.contains("#"))), "identifier '" + identifier + "' contains a '#' symbol");





Please find below bit more of the stack trace:

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:dan@haywood-associates.co.uk] 
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, <ch...@wipro.com> 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/98fa9f2d9204166c1b9168d1f0839dd161d0e61e/core/metamodel/src/test/java/org/apache/isis/core/metamodel/adapter/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

Re: identifier 'com.wipro.wess.ods.munit.MUnitPK_#01' contains a '#' symbol

Posted by Dan Haywood <da...@haywood-associates.co.uk>.
On 19 June 2014 08:18, <ch...@wipro.com> 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:75)
>
>
>
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/98fa9f2d9204166c1b9168d1f0839dd161d0e61e/core/metamodel/src/test/java/org/apache/isis/core/metamodel/adapter/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
>