/**
  * Import XML
  *
  * @param
  * @return
  */
 function importXmlRepresentation($a_entity, $a_id, $a_xml, $a_mapping)
 {
     include_once './Modules/Folder/classes/class.ilObjFolder.php';
     if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_id)) {
         $this->link = ilObjectFactory::getInstanceByObjId($new_id, false);
     } else {
         include_once './Modules/WebResource/classes/class.ilObjLinkResource.php';
         $this->link = new ilObjLinkResource();
         $this->link->setType('webr');
         $this->link->create(true);
     }
     try {
         include_once './Modules/WebResource/classes/class.ilWebLinkXmlParser.php';
         $parser = new ilWebLinkXmlParser($this->link, $a_xml);
         $parser->setMode(ilWebLinkXmlParser::MODE_CREATE);
         $parser->start();
         $a_mapping->addMapping('Modules/WebResource', 'webr', $a_id, $this->link->getId());
     } catch (ilSaxParserException $e) {
         $GLOBALS['ilLog']->write(__METHOD__ . ': Parsing failed with message, "' . $e->getMessage() . '".');
     } catch (ilWebLinkXMLParserException $e) {
         $GLOBALS['ilLog']->write(__METHOD__ . ': Parsing failed with message, "' . $e->getMessage() . '".');
     }
 }
 /**
  * update a weblink with id.
  *
  * @param string $session_id    current session
  * @param int $ref_id   refid id of weblink in repository
  * @param string $weblink_xml  xml description
  *
  * @return boolean true, if update successful, false otherwise
  */
 function updateWebLink($sid, $ref_id, $weblink_xml)
 {
     $this->initAuth($sid);
     $this->initIlias();
     if (!$this->__checkSession($sid)) {
         return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
     }
     global $rbacsystem, $tree, $ilLog;
     if (ilObject::_isInTrash($ref_id)) {
         return $this->__raiseError('Cannot perform update since weblink has been deleted.', 'CLIENT_OBJECT_DELETED');
     }
     // get obj_id
     if (!($obj_id = ilObject::_lookupObjectId($ref_id))) {
         return $this->__raiseError('No weblink found for id: ' . $ref_id, 'CLIENT_OBJECT_NOT_FOUND');
     }
     // Check access
     $permission_ok = false;
     foreach ($ref_ids = ilObject::_getAllReferences($obj_id) as $ref_id) {
         if ($rbacsystem->checkAccess('edit', $ref_id)) {
             $permission_ok = true;
             break;
         }
     }
     if (!$permission_ok) {
         return $this->__raiseError('No permission to edit the weblink with id: ' . $ref_id, 'Server');
     }
     $webl = ilObjectFactory::getInstanceByObjId($obj_id, false);
     if (!is_object($webl) or $webl->getType() != "webr") {
         return $this->__raiseError('Wrong obj id or type for weblink with id ' . $ref_id, 'Client');
     }
     try {
         include_once './Modules/WebResource/classes/class.ilWebLinkXmlParser.php';
         $parser = new ilWebLinkXmlParser($webl, $weblink_xml);
         $parser->setMode(ilWebLinkXmlParser::MODE_UPDATE);
         $parser->start();
     } catch (ilSaxParserException $e) {
         return $this->__raiseError($e->getMessage(), 'Client');
     } catch (ilWebLinkXMLParserException $e) {
         return $this->__raiseError($e->getMessage(), 'Client');
     }
     // Check if required
     return true;
 }