Expand my Community achievements bar.

SOLVED

Curl to update a single property on Publisher results in 500

Avatar

Community Advisor

Hi,

Tried updating a property on a page in CQ5.6.1 and received an Internal server error. Surprisingly this is only happening in the Publishers. Authors are happily happily updating properties.

Script: import groovyx.net.http.HTTPBuilder import java.text.SimpleDateFormat import static groovyx.net.http.ContentType.JSON final def cmsAuth = 'http://publisher:4503' final def http = new HTTPBuilder(cmsAuth) http.auth.basic('lmp','*') final def httpArtContent = new HTTPBuilder(cmsAuth) httpArtContent.auth.basic('lmp','*') http.get( path: '/bin/querybuilder.json', contentType: JSON, query : [ type: 'cq:PageContent', property: 'cq:template', 'property.value': '/apps/proj/templates/article-page', 'p.limit': -1]) { resp, reader -> println(reader.hits.size()) for (newsArticle in reader['hits']) { Date date = Date.parse("yyyy-MM-dd hh:mm:ss" , newsArticle.created) SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.242+01:00"); try { def postData = [ articlePublicationDate: dateFormat.format(date) ] httpArtContent.post( path: newsArticle.path, contentType: JSON, body: postData) { resp1, reader1-> println('Updated prop for : ' + newsArticle.path + ' updated property : ' + postData) } } catch(Exception e){ println("Error on path: " + newsArticle.path) println(e) } } } println('----------------------------------') Exception:
ERROR 2014-01-16 18:14:32,633 [10.144.199.93 [1389896072626] POST /content/euro-slides-as-court-hearing-continues/jcr:content HTTP/1.1] (org.apache.sling.servlets.post.impl.operations.ModifyOperation) - Exception during response processing. javax.jcr.RepositoryException: org.apache.sling.api.resource.PersistenceException: Resource at '/content/euro-slides-as-court-hearing-continues/jcr:content' is not modifiable.at org.apache.sling.servlets.post.impl.operations.ModifyOperation.doRun(ModifyOperation.java:113)at org.apache.sling.servlets.post.AbstractPostOperation.run(AbstractPostOperation.java:92)at org.apache.sling.servlets.post.impl.SlingPostServlet.doPost(SlingPostServlet.java:202)at org.apache.sling.api.servlets.SlingAllMethodsServlet.mayService(SlingAllMethodsServlet.java:148)at org.apache.sling.api.servlets.SlingSafeMethodsServlet.service(SlingSafeMethodsServlet.java:344)at org.apache.sling.api.servlets.SlingSafeMethodsServlet.service(SlingSafeMethodsServlet.java:375)at org.apache.sling.engine.impl.request.RequestData.service(RequestData.java:508)at org.apache.sling.engine.impl.filter.SlingComponentFilterChain.render(SlingComponentFilterChain.java:45)at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:64)at com.day.cq.wcm.core.impl.WCMDebugFilter.doFilterWithErrorHandling(WCMDebugFilter.java:182)at com.day.cq.wcm.core.impl.WCMDebugFilter.doFilter(WCMDebugFilter.java:149)Caused by: org.apache.sling.api.resource.PersistenceException: Resource at '/content/euro-slides-as-court-hearing-continues/jcr:content' is not modifiable.at org.apache.sling.servlets.post.impl.helper.SlingPropertyValueHandler.setProperty(SlingPropertyValueHandler.java:153)at org.apache.sling.servlets.post.impl.operations.ModifyOperation.writeContent(ModifyOperation.java:411)at org.apache.sling.servlets.post.impl.operations.ModifyOperation.doRun(ModifyOperation.java:101)... 96 more

Probs I am missing something simple,

Help appreciated,

Peter

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

actually it's groovy auth running in pre-emptive mode.

 

By changing the mode .e.g adding

 

httpArtContent.client.addRequestInterceptor(new HttpRequestInterceptor() { void process(HttpRequest httpRequest, HttpContext httpContext) { httpRequest.addHeader('Authorization', 'Basic ' + 'lmp:*'.bytes.encodeBase64().toString()) } })

Props are added !

View solution in original post

2 Replies

Avatar

Level 10

According to the log file -- it is saying that the resource at that location cannot be modified:

Resource at '/content/euro-slides-as-court-hearing-continues/jcr:content' is not modifiable

Check the permissions. 

Avatar

Correct answer by
Community Advisor

actually it's groovy auth running in pre-emptive mode.

 

By changing the mode .e.g adding

 

httpArtContent.client.addRequestInterceptor(new HttpRequestInterceptor() { void process(HttpRequest httpRequest, HttpContext httpContext) { httpRequest.addHeader('Authorization', 'Basic ' + 'lmp:*'.bytes.encodeBase64().toString()) } })

Props are added !