/*
getWsagObject receives in serializedData the object information in xml
must returns a eu.atos.sla.parser.data.wsag.Agreement
705
@Override
    public Agreement getWsagObject(String serializedData) throws ParserException{
        Agreement agreementXML = null;
        try{
            logger.info("Will parse {}", serializedData);
            JAXBContext jaxbContext = JAXBContext.newInstance(Agreement.class);
            Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
            jaxbUnmarshaller.setEventHandler(new ValidationHandler());
            agreementXML = (Agreement)jaxbUnmarshaller.unmarshal(new StringReader(serializedData));
            logger.info("Agreement parsed {}", agreementXML);
        }catch(JAXBException e){
            throw new ParserException(e);
        }
        return agreementXML;
    }
1166697
function unserializeContentObjectAttribute( $package, $objectAttribute, $attributeNode )
    {
        $userNode = $attributeNode->getElementsByTagName( 'account' )->item( 0 );
        if ( is_object( $userNode ) )
        {
            $userID = $objectAttribute->attribute( 'contentobject_id' );
            $user = eZUser::fetch( $userID );
            if ( !is_object( $user ) )
            {
                $user = eZUser::create( $userID );
            }
            $user->setAttribute( 'login', $userNode->getAttribute( 'login' ) );
            $user->setAttribute( 'email', $userNode->getAttribute( 'email' ) );
            $user->setAttribute( 'password_hash', $userNode->getAttribute( 'password_hash' ) );
            $user->setAttribute( 'password_hash_type', eZUser::passwordHashTypeID( $userNode->getAttribute( 'password_hash_type' ) ) );
            $user->store();
        }
    }
273358
function getValueFromPayloadPiece(payloadPiece) {
  if (isObject(payloadPiece) && !payloadPiece.id && Object.keys(payloadPiece).length === 1) {
    return Object.values(payloadPiece)[0];
  }

  return payloadPiece;
}
526992
function parseGoogleNewsRSSData(fileData) {
    // sanity check that this is valid google news RSS
    if (fileData.indexOf('news-feedback@google.com') != -1) {
        // set an empty array of news story objects
        var allGoogleNewsData = [ ];
        var params = {normalizeWhitespace: true, xmlMode: true};
        // load the html into the cheerio doc
        var cheerio = require("cheerio");
        var fullDoc = cheerio.load(fileData, params);    
        // iterate through movies and strip useful parts, add each to return object
        fullDoc('item').each(function(i, elem) {
            // load current item
            var itemDoc = cheerio.load(fullDoc(this).html(), params);
            // break out parts of interest
            // some sections need cleaning so do that as well
            var fullTitleLine = itemDoc('title').text().trim();
            var fullTitleSplitIndex = fullTitleLine.lastIndexOf(' - ');
            var titlePart = fullTitleLine.substring(0, fullTitleSplitIndex);
            var sourcePart = fullTitleLine.substring(fullTitleSplitIndex + 3, fullTitleSplitIndex.length);
            var fullURLPart = itemDoc('link').html().trim();
            var cleanURLPart = fullURLPart.split(';url=')[1];
            var categoryPart = itemDoc('category').html();
            if (categoryPart != null)
                categoryPart = categoryPart.trim();
            var pubDatePart = itemDoc('pubDate').html().trim();
            var fullDescriptionPart = itemDoc('description').text().trim();
            var descriptionStart = fullDescriptionPart.indexOf('</font><br><font size="-1">');
            var descriptionEnd = fullDescriptionPart.indexOf('</font>', descriptionStart + 1);
            var cleanDescriptionPart = fullDescriptionPart.substring(descriptionStart, descriptionEnd);
            var cleanDescriptionPart = cleanDescriptionPart.replace('</font><br><font size="-1">', '');
            var cleanDescriptionPart = cleanDescriptionPart.replace('<b>...</b>', '...');
            // build final object for the current news story
            var fullObject = {  title: titlePart
                                , source: sourcePart
                                , category: categoryPart
                                , pubDate: pubDatePart
                                , fullURL: fullURLPart
                                , cleanURL: cleanURLPart
                                , fullDescription: fullDescriptionPart
                                , cleanDescription: cleanDescriptionPart
                             };                           
            // add thew news story obejct to the array
            allGoogleNewsData.push(fullObject);            
        });
        // return no error state and the collected news story objects
        return {error: false, data: allGoogleNewsData};
    }
    // if sanity check failed, return true error state and an error message
    return {error: errorFlag, errorMessage: 'Fetched RSS data does not contain expected content.', data: null};
}
751072
public org.w3c.dom.Node getMessageBody(Object rawData, boolean bReturnCopy)
    {
        SOAPMessage message = (SOAPMessage)rawData;
        try {
            SOAPPart sp = message.getSOAPPart();

            if (bReturnCopy)
            {
                // We need to do the following steps to add the document to this soap body:
                // 1. Transform this SOAPPart to DOM
                // 2. Add this document to the SOAPBody.
                // 3. Put it back in the SOAP object
    
                // 1. Transform this SOAPPart to DOM
                TransformerFactory tFact = TransformerFactory.newInstance();
                Transformer transformer = tFact.newTransformer();
                Source src = sp.getContent();
    
                DocumentBuilder db = Utility.getDocumentBuilder();
                DocumentFragment docFrag = null;
                synchronized (db)
                {
                    Document doc = this.getScratchDocument(db);
                    docFrag = doc.createDocumentFragment();
                    Result result = new DOMResult(docFrag);
                    transformer.transform(src, result);
                }
    
                // 2. Add this document to the SOAPBody.
                org.w3c.dom.Element el = (org.w3c.dom.Element)docFrag.getFirstChild();
    
                NodeList nodeList = null;
    
                nodeList = el.getChildNodes();
                org.w3c.dom.Element elBody = null;
                for (int i = 0; i < nodeList.getLength(); i++)
                {
                    if ("Body".equalsIgnoreCase(nodeList.item(i).getLocalName()))
                    {
                        elBody = (org.w3c.dom.Element)nodeList.item(i);
                        break;
                    }
                }
                org.w3c.dom.Element elDoc = null;
                nodeList = elBody.getChildNodes();
                for (int i = 0; i < nodeList.getLength(); i++)
                {
                    String strName = nodeList.item(i).getLocalName();
                    if ((strName != null) && (strName.length() > 0))
                    {       // First item in the body is the OTA message
                        elDoc = (org.w3c.dom.Element)nodeList.item(i);
                        break;
                    }
                }
    
                return elDoc;
            }
            else
            {
                // Retrieve the envelope from the soap part to start building
                // the soap message.
                SOAPEnvelope envelope = sp.getEnvelope();
                
                // Create a soap header from the envelope.
                //?SOAPHeader header = envelope.getHeader();
                
                // Create a soap body from the envelope.
                SOAPBody body = envelope.getBody();

                Iterator<?> iterator = body.getChildElements();
                while (iterator.hasNext())
                {
                    Object nextNode = iterator.next();
                    if (!(nextNode instanceof Element))
                        continue;
                    Element node = (Element)nextNode;
                
                    if (node instanceof SOAPElement)    // The one and only
                        return node;
                }
            }
        } catch(Throwable ex) {
            ex.printStackTrace();
        }
        return null;
    }
321204
@SneakyThrows
    public <T extends SOAPObject> T newSoapObject(final Class<T> objectType) {
        val qName = getSamlObjectQName(objectType);
        val builder = (SOAPObjectBuilder<T>)
            XMLObjectProviderRegistrySupport.getBuilderFactory().getBuilder(qName);
        if (builder == null) {
            throw new IllegalStateException("No SAML object builder is registered for class " + objectType.getName());
        }
        return objectType.cast(builder.buildObject(qName));
    }
232619
function unserializeContentObjectAttribute( $package, $objectAttribute, $attributeNode )
    {
        /* For all links found in the XML, do the following:
         * Search for url specified in 'href' link attribute (in ezurl table).
         * If the url not found then create a new one.
         * Then associate the found (or created) URL with the object attribute by creating new url-object link.
         * After that, remove "href" attribute, add new "id" attribute.
         * This new 'id' will always refer to the existing url object.
         */
        $linkNodes = $attributeNode->getElementsByTagName( 'link' );

        foreach ( $linkNodes as $linkNode )
        {
            $href = $linkNode->getAttribute( 'href' );
            if ( !$href )
                continue;
            $urlObj = eZURL::urlByURL( $href );

            if ( !$urlObj )
            {
                $urlObj = eZURL::create( $href );
                $urlObj->store();
            }

            $linkNode->removeAttribute( 'href' );
            $linkNode->setAttribute( 'url_id', $urlObj->attribute( 'id' ) );
            $urlObjectLink = eZURLObjectLink::create( $urlObj->attribute( 'id' ),
                                                      $objectAttribute->attribute( 'id' ),
                                                      $objectAttribute->attribute( 'version' ) );
            $urlObjectLink->store();
        }

        foreach ( $attributeNode->childNodes as $childNode )
        {
            if ( $childNode->nodeType == XML_ELEMENT_NODE )
            {
                $xmlString = $childNode->ownerDocument->saveXML( $childNode );
                $objectAttribute->setAttribute( 'data_text', $xmlString );
                break;
            }
        }
    }
1362998
private void getWSDL(String api, String requestURL, PrintWriter out) throws IOException,
            ServletException {

        String wsdlPath = (String) _WSDL_PATHS.get(api);
        if (wsdlPath != null) {

            File schemaFile = new File(_serverDir, _XSD_PATH);
            File sourceWSDL = new File(_serverDir, wsdlPath);

            String baseURL = getFedoraBaseURL(requestURL);
            String svcPath = (String) _SERVICE_PATHS.get(api);

            RuntimeWSDL wsdl =
                    new RuntimeWSDL(schemaFile, sourceWSDL, baseURL + "/"
                            + svcPath);

            wsdl.serialize(out);

        } else {
            throw new ServletException("No such api: '" + api + "'");
        }
    }
336313
@Override
    protected void DecodeFromCBORObject(CBORObject obj) throws CoseException {
        if (obj.size() != 4) throw new CoseException("Invalid SignMessage structure");
        
        if (obj.get(0).getType() == CBORType.ByteString) {
            rgbProtected = obj.get(0).GetByteString();
            if (obj.get(0).GetByteString().length == 0) {
                objProtected = CBORObject.NewMap();
            }
            else {
                objProtected = CBORObject.DecodeFromBytes(rgbProtected);
                if (objProtected.size() == 0) rgbProtected = new byte[0];
            }
        }
        else throw new CoseException("Invalid SignMessage structure");
        
        if (obj.get(1).getType() == CBORType.Map) {
            objUnprotected = obj.get(1);
        }
        else throw new CoseException("Invalid SignMessage structure");
        
        if (obj.get(2).getType() == CBORType.ByteString) rgbContent = obj.get(2).GetByteString();
        else if (!obj.get(2).isNull()) throw new CoseException("Invalid SignMessage structure");
        
        if (obj.get(3).getType() == CBORType.Array) {
            for (int i=0; i<obj.get(3).size(); i++) {
                Signer signer = new Signer();
                signer.DecodeFromCBORObject(obj.get(3).get(i));
                signerList.add(signer);
            }
        }
        else throw new CoseException("Invalid SignMessage structure");
    }
1299276
private Object getObjectValue(XmlNode node, String fieldName) {
        // we have to take into account the fact that fieldName will be in the lower case
        if (node != null) {
            String name = node.getName();
            switch (node.getType()) {
                case XmlNode.ATTRIBUTE_NODE:
                    return name.equalsIgnoreCase(fieldName) ? node : null;
                case XmlNode.ELEMENT_NODE: {
                    if (name.equalsIgnoreCase(fieldName)) {
                        return new XmlNodeArray(node.getChildren());
                    } else {
                        Map<String, XmlNode> attributes = node.getAttributes();
                        for (Map.Entry<String, XmlNode> entry : attributes.entrySet()) {
                            String attributeName = entry.getKey();
                            if (attributeName.equalsIgnoreCase(fieldName)) {
                                return entry.getValue();
                            }
                        }
                        return null;
                    }
                }
                default:
                    return null;
            }
        }
        return null;
    }
1058638
function (aLibsData) {
				var oLibItem,
					iLen,
					i;

				// Find entity in loaded libs data
				for (i = 0, iLen = aLibsData.length; i < iLen; i++) {
					oLibItem = aLibsData[i];
					if (oLibItem.name === this._sTopicid) {
						// Check if we are allowed to display the requested symbol
						// BCP: 1870269087 item may not have visibility info at all. In this case we show the item
						if (oLibItem.visibility === undefined || this._aAllowedMembers.indexOf(oLibItem.visibility) >= 0) {
							return oLibItem;
						} else {
							// We found the requested symbol but we are not allowed to show it.
							return Promise.reject(this.NOT_FOUND);
						}
					}
				}

				// If we are here - the object does not exist so we reject the promise.
				return Promise.reject(this.NOT_FOUND);
			}
1303931
function unserializeContentObjectAttribute( $package, $objectAttribute, $attributeNode )
    {
        if ( $attributeNode->hasChildNodes() )
        {
            $contentObjectAttributeID = $objectAttribute->attribute( 'id' );
            $contentObjectAttributeVersion = $objectAttribute->attribute( 'version' );

            $enumNodes = $attributeNode->childNodes;
            foreach ( $enumNodes as $enumNode )
            {
                $eID      = $enumNode->getAttribute( 'id' );
                $eValue   = $enumNode->getAttribute( 'value' );
                $eElement = $enumNode->getAttribute( 'element' );

                eZEnum::storeObjectEnumeration( $contentObjectAttributeID,
                                                $contentObjectAttributeVersion,
                                                $eID,
                                                $eElement,
                                                $eValue );
            }
        }
        else
        {
            eZDebug::writeError( "Can't find attributes for enumeration", __METHOD__ );
        }
    }
216514
function unserializeContentObjectAttribute( $package, $objectAttribute, $attributeNode )
    {
        $timeNode = $attributeNode->getElementsByTagName( 'time' )->item( 0 );
        if ( is_object( $timeNode ) )
        {
            $timestamp = eZDateUtils::textToDate( $timeNode->textContent );
            $timeOfDay = null;
            if ( $timestamp >= 0 )
            {
                $time = new eZTime( $timestamp );
                $timeOfDay = $time->timeOfDay();
            }
            $objectAttribute->setAttribute( 'data_int', $timeOfDay );
        }
    }
374866
function getImageData (canvasId, x, y, width, height, done) {
  wx.canvasGetImageData({
    canvasId,
    x,
    y,
    width,
    height,
    success (res) {
      done(res, null)
    },
    fail (res) {
      done(null, res)
    }
  })
}
982518
function () {
			var tempRules = [],
				rawLSData;

			try {
				rawLSData = localStorage.getItem(constants.LOCAL_STORAGE_TEMP_RULES_KEY);

				if (!rawLSData) {
					return null;
				}

				tempRules = JSON.parse(decode(rawLSData));

				tempRules = tempRules.map(function (tempRule) {
					return RuleSerializer.deserialize(tempRule, true);
				});
			} catch (oError) {
				// Swallow "Access Denied" exceptions in cross-origin scenarios.
			}

			return tempRules;
		}
1074126
function processGraph(data) {
  let dataset = {
    '@default': []
  };

  let subjects = data.subjects,
    htmlMapper = n => {
      let div = n.ownerDocument.createElement('div');
      div.appendChild(n.cloneNode(true));
      return div.innerHTML;
    };

  Object.keys(subjects).forEach(subject => {
    let predicates = subjects[subject].predicates;
    Object.keys(predicates).forEach(predicate => {
      // iterate over objects
      let objects = predicates[predicate].objects;
      for (let oi = 0; oi < objects.length; ++oi) {
        let object = objects[oi];

        // create RDF triple
        let triple = {};

        // add subject & predicate
        triple.subject = {
          type: subject.indexOf('_:') === 0 ? 'blank node' : 'IRI',
          value: subject
        };
        triple.predicate = {
          type: predicate.indexOf('_:') === 0 ? 'blank node' : 'IRI',
          value: predicate
        };
        triple.object = {};

        // serialize XML literal
        let value = object.value;
        // !!! TODO: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        // The below actually most likely does NOT work.
        // In most usage contexts this will be an HTML DOM, passing it to xmldom's XMLSerializer
        // will cause it to call .toString() on all the nodes it finds — this only works inside
        // xmldom.
        if (object.type === RDF_XML_LITERAL) {
          // initialize XMLSerializer
          let serializer = new XMLSerializer();
          value = Array.from(object.value)
            .map(n => serializer.serializeToString(n))
            .join('');
          triple.object.datatype = RDF_XML_LITERAL;
        }
        // serialise HTML literal
        else if (object.type === RDF_HTML_LITERAL) {
          value = Array.from(object.value)
            .map(htmlMapper)
            .join('');
          triple.object.datatype = RDF_HTML_LITERAL;
        }
        // object is an IRI
        else if (object.type === RDF_OBJECT) {
          if (object.value.indexOf('_:') === 0)
            triple.object.type = 'blank node';
          else triple.object.type = 'IRI';
        } else {
          // object is a literal
          triple.object.type = 'literal';
          if (object.type === RDF_PLAIN_LITERAL) {
            if (object.language) {
              triple.object.datatype = RDF_LANGSTRING;
              triple.object.language = object.language;
            } else {
              triple.object.datatype = XSD_STRING;
            }
          } else {
            triple.object.datatype = object.type;
          }
        }
        triple.object.value = value;

        // add triple to dataset in default graph
        dataset['@default'].push(triple);
      }
    });
  });

  return dataset;
}
790914
function _objectToRDF(item) {
  var object = {};

  // convert value object to RDF
  if(_isValue(item)) {
    object.type = 'literal';
    var value = item['@value'];
    var datatype = item['@type'] || null;

    // convert to XSD datatypes as appropriate
    if(_isBoolean(value)) {
      object.value = value.toString();
      object.datatype = datatype || XSD_BOOLEAN;
    }
    else if(_isDouble(value) || datatype === XSD_DOUBLE) {
      // canonical double representation
      object.value = value.toExponential(15).replace(/(\d)0*e\+?/, '$1E');
      object.datatype = datatype || XSD_DOUBLE;
    }
    else if(_isNumber(value)) {
      object.value = value.toFixed(0);
      object.datatype = datatype || XSD_INTEGER;
    }
    else if('@language' in item) {
      object.value = value;
      object.datatype = datatype || RDF_LANGSTRING;
      object.language = item['@language'];
    }
    else {
      object.value = value;
      object.datatype = datatype || XSD_STRING;
    }
  }
  // convert string/node object to RDF
  else {
    var id = _isObject(item) ? item['@id'] : item;
    object.type = (id.indexOf('_:') === 0) ? 'blank node' : 'IRI';
    object.value = id;
  }

  return object;
}