AnsweredAssumed Answered

Access Denied when creating content from a scheduled task

Question asked by mark.smithson on Aug 29, 2007
Latest reply on Aug 29, 2007 by mark.smithson
We have a scheduled task which imports news from an xml feed into a WCM sandbox.

This works fine on a windows Alfresco instance, but throws an Access Denied error when on our test server (linux). Access Denied.  You do not have the appropriate permissions to perform this operation.
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
   at org.alfresco.repo.audit.AuditComponentImpl.auditImpl(
   at org.alfresco.repo.audit.AuditComponentImpl.audit(
   at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
   at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(
   at $Proxy15.addAspect(Unknown Source)

The code used to create the content is as follows:

String path = AVMUtil.buildSandboxRootPath(sandbox) + "/ROOT/WEB-INF/resources/content/" + contentPath ;

      createFile(path, name, edit);
    String filePath = path + '/' + name;
    NodeRef fileNodeRef = AVMNodeConverter.ToNodeRef(-1, filePath);
    // apply the titled aspect - title and description
    Map<QName, Serializable> titledProps = new HashMap<QName, Serializable>(2, 1.0f);
    titledProps.put(ContentModel.PROP_TITLE, name);
    titledProps.put(ContentModel.PROP_DESCRIPTION, "Imported from News Feed");
    this.nodeService.addAspect(fileNodeRef, ContentModel.ASPECT_TITLED, titledProps);
    // attach the form is supplied
    if (StringUtils.isNotEmpty(this.formName)){
       Map<QName, Serializable> formProps = new HashMap<QName, Serializable>(2, 1.0f);
       formProps.put(WCMAppModel.PROP_PARENT_FORM_NAME, this.formName);
       formProps.put(WCMAppModel.PROP_ORIGINAL_PARENT_PATH, path);
       this.nodeService.addAspect(fileNodeRef, WCMAppModel.ASPECT_FORM_INSTANCE_DATA, titledProps);
    // get a writer for the content and put the file
    ContentWriter writer = this.contentService.getWriter(fileNodeRef, ContentModel.PROP_CONTENT, true);

createFile is as follows

private void createFile(String path, String name, boolean edit) {
      try {
         this.avmService.createFile(path, name);
      catch (AVMExistsException e){
         if (!edit){
            createFile(path, randomise(name), edit);

the calling code does a login using this code

this.authenticationService.authenticate(username, password.toCharArray());

The exception stacktrace originates from this line

this.nodeService.addAspect(fileNodeRef, ContentModel.ASPECT_TITLED, titledProps);

The user is configured as a content contributor on the web project and the sandbox we are importing to is the sandbox for the user.

Is there anything else we should be checking, or doing?