I'm trying to implement a moveObject service using this API, but haven't had any luck so far. I've looked at the CMIS schema and I have it working in SoapUI, so I know I'm close.

The goal is to move an object (I'm trying with a workspace) from one parent to another.

Any hints on what the Alfresco Service URL might be? Right now I'm pointing to the children of the target parent and putting a ?removeFrom=[id] argument in the URL where [id] is the id of the source and supposed to be optional. This gives me back a 500 error.

function cmis_alfresco_cmisapi_moveObject($repositoryId, $objectId, $targetFolderId, $sourceFolderId = null) {
  module_load_include('utils.inc', 'cmis_alfresco');

    if($sourceFolderId != null){
  
	  $sourceId = cmis_alfresco_objectId($sourceFolderId);
  
    if (!is_array($sourceId) || !array_key_exists('noderef_url', $sourceId)) {
    drupal_set_message('Unable to find source folder: ' . $sourceFolderId, 'error');
    return false;
    }
  
  }
  
    if($targetFolderId != null){
	    drupal_set_message($targetId . " breaking in");
	  $targetId = cmis_alfresco_objectId($targetFolderId);
  
    if (!is_array($targetId) || !array_key_exists('noderef_url', $targetId)) {
    drupal_set_message('Unable to find target folder: ' . $targetFolderId, 'error');
    return false;
    }
  
  }
  
    if($objectId != null){
  
	  $objId = cmis_alfresco_objectId($objectId);
  
    if (!is_array($objId) || !array_key_exists('noderef_url', $objId)) {
    drupal_set_message('Unable to find object folder: ' . $objectId, 'error');
   	 return false;
    }
  
  }

  $postvars = '<?xml version="1.0" encoding="utf-8"?>' .
  '<entry xmlns="http://www.w3.org/2005/Atom" xmlns:ns="http://docs.oasis-open.org/ns/cmis/messaging/200901">' .
  '<ns:moveObject>'.
         '<ns:repositoryId>'.$repositoryId.'</ns:repositoryId>'.
         '<ns:objectId>'.$objId['noderef'].'</ns:objectId>'.
         '<ns:targetFolderId>'.$targetId['noderef'].'</ns:targetFolderId>'.
         '<ns:sourceFolderId>'.$sourceId['noderef'].'</ns:sourceFolderId>'.
      '</ns:moveObject>'.
  '</entry>';

  $header[] = 'Content-type: application/atom+xml;type=entry';
  $header[] = 'Content-length: ' . strlen($postvars);
  $header[] = 'MIME-Version: 1.0';

  $xml = cmis_alfresco_utils_invoke_service('/api/node/' . $targetId['noderef_url']. '/children?removeFrom=' . $sourceId['noderef'], 'ticket', $header, 'CUSTOM-POST', $postvars);
  

  $entry = cmis_utils_process_CMIS_xml($xml, '/D:entry');
  $entry = $entry[0][0];

  $objectId = cmis_alfresco_objectId((string)$entry->id);

  return $objectId['noderef'];

}

Any thoughts?

Comments

cbalan’s picture

Project: CMIS Alfresco » CMIS API
Version: 6.x-1.0 » 6.x-3.x-dev
Assigned: Unassigned » cbalan

Hello,

cmis_alfresco module is deprecated.
Moving this issue under CMIS api project.

Thank you,
Catalin Balan

IanNorton’s picture

Status: Active » Closed (won't fix)

Closing 6.x issues as documented in this post