Java Code Examples for org.alfresco.service.cmr.dictionary.ModelDefinition#XMLBindingType

The following examples show how to use org.alfresco.service.cmr.dictionary.ModelDefinition#XMLBindingType . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: M2Model.java    From alfresco-data-model with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void toXML(ModelDefinition.XMLBindingType bindingType, OutputStream xml)
{
    try
    {
    	if(bindingType == null)
    	{
    		bindingType = ModelDefinition.XMLBindingType.DEFAULT;
    	}

    	String bindingName = bindingType.toString();
        IBindingFactory factory = (bindingName != null) ? BindingDirectory.getFactory(bindingName, M2Model.class) :
        	BindingDirectory.getFactory("default", M2Model.class);
        IMarshallingContext context = factory.createMarshallingContext();
        context.setIndent(4);
        context.marshalDocument(this, "UTF-8", null, xml);
    }
    catch(JiBXException e)
    {
        throw new DictionaryException(ERR_CREATE_M2MODEL_FAILURE, e);
    }
}
 
Example 2
Source File: AlfrescoModelGet.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void handle(WebScriptRequest req, WebScriptResponse res) throws JSONException, IOException
{
    // create map of template vars
    String modelQName = req.getParameter("modelQName");
    if(modelQName == null)
    {
        throw new WebScriptException(
                Status.STATUS_BAD_REQUEST,
                "URL parameter 'modelQName' not provided.");
    }

    ModelDefinition.XMLBindingType bindingType = ModelDefinition.XMLBindingType.DEFAULT;
    AlfrescoModel model = solrTrackingComponent.getModel(QName.createQName(modelQName));
    res.setHeader("XAlfresco-modelChecksum", String.valueOf(model.getModelDef().getChecksum(bindingType)));
    model.getModelDef().toXML(bindingType, res.getOutputStream());
}
 
Example 3
Source File: M2Model.java    From alfresco-data-model with GNU Lesser General Public License v3.0 5 votes vote down vote up
public long getChecksum(ModelDefinition.XMLBindingType bindingType)
{
    final CRC32 crc = new CRC32();

    // construct the crc directly from the model's xml stream
    toXML(bindingType, new OutputStream() {
        public void write(int b) throws IOException
        {
            crc.update(b);
        }
    });

    return crc.getValue();
}