REST api - Unable to create new version of existing content in different language
dotCMS throws an error when adding a new language version to an existing piece of content (where that content does not have a version in the new language yet).
On starter, using the "About Quest" content (which has identifier: 767509b1-2392-4661-a16b-e0e31ce27719) 1) add a new version of About Quest using rest:
curl -v -u [email protected]:admin -XPUT http://localhost:8080/api/content/publish/1 -H "Content-Type:application/json" -d '{
identifier: "767509b1-2392-4661-a16b-e0e31ce27719",
stInode:"2a3e91e4-fbbf-4876-8c5b-2233c1739b05",
languageId:1,
title:"ABOUT QUEST - Ver. 2",
contentHost:"demo.dotcms.com",
body:"hellow"
}'
2) Adding a Spanish version of the same content fails:
curl -v -u [email protected]:admin -XPUT http://localhost:8080/api/content/publish/1 -H "Content-Type:application/json" -d '{
identifier: "767509b1-2392-4661-a16b-e0e31ce27719",
stInode:"2a3e91e4-fbbf-4876-8c5b-2233c1739b05",
languageId:2,
title:"ABOUT QUEST en espanol",
contentHost:"demo.dotcms.com",
body:"Hola, esto es mi cuerpo"
}'
Here is the log for the error:
WARN 2016-03-22 08:35:26,044 com.dotcms.enterprise.rules.RulesAPIImpl:warn(195): Actionlet with name 'VisitorTagsActionlet' already registered.
WARN 2016-03-22 08:35:26,044 com.dotcms.enterprise.rules.RulesAPIImpl:warn(195): Actionlet with name 'SendRedirectActionlet' already registered.
INFO 2016-03-22 08:35:26,062 com.dotmarketing.business.cache.provider.guava.GuavaCache:info(62): *** Building Cache : rulescache, size:1000,Concurrency:32
WARN 2016-03-22 08:43:46,546 com.dotcms.rest.ContentResource:warn(195): COOKIES are not in the REQUEST
ERROR 2016-03-22 08:43:46,553 com.dotcms.rest.ContentResource:error(134): Error processing Stream
java.lang.RuntimeException: can't get existing content for ident 767509b1-2392-4661-a16b-e0e31ce27719 lang 2
at com.dotcms.rest.ContentResource.processMap(ContentResource.java:1097) ~[ContentResource.class:?]
at com.dotcms.rest.ContentResource.processJSON(ContentResource.java:1213) ~[ContentResource.class:?]
at com.dotcms.rest.ContentResource.singlePUTandPOST(ContentResource.java:789) [ContentResource.class:?]
at com.dotcms.rest.ContentResource.singlePUT(ContentResource.java:770) [ContentResource.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_51]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_51]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_51]
at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_51]
at com.dotcms.repackage.org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81) [dot.jersey-server-2.22.1_1.jar:?]
at com.dotcms.repackage.org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144) [dot.jersey-server-2.22.1_1.jar:?]
at com.dotcms.repackage.org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161) [dot.jersey-server-2.22.1_1.jar:?]
at com.dotcms.repackage.org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:160) [dot.jersey-server-2.22.1_1.jar:?]
at com.dotcms.repackage.org.glassfish.jersey.server.model.in
I like the fix @wezell
PR: https://github.com/dotCMS/core/pull/9153
Passed QA. Fix is working in spanish. Added a third language (french) and is working as well Tested locally in: master-3.6 // Mac OS 10.10 // MySQL 5.6.23 // Firefox