private CompiledModel createUpdateModel(final String modelFileName, final M2Model m2Model, final boolean activate, String errMsgId, boolean requiresNewTx) { // Validate model CompiledModel compiledModel = compileModel(m2Model); // Validate properties default values validatePropsDefaultValues(compiledModel); ByteArrayOutputStream xml = new ByteArrayOutputStream(); m2Model.toXML(xml); final InputStream modelStream = new ByteArrayInputStream(xml.toByteArray()); // Create the model node NodeRef nodeRef = doInTransaction(errMsgId, requiresNewTx, new RetryingTransactionCallback<NodeRef>() { public NodeRef execute() throws Exception { return repoAdminService.deployModel(modelStream, modelFileName, activate); } }); if (!nodeService.hasAspect(nodeRef, ASPECT_CUSTOM_MODEL)) { // Add the 'customModelManagement' marker aspect, to // indicate that this model has been created dynamically by this service nodeService.addAspect(nodeRef, ASPECT_CUSTOM_MODEL, null); } // Add hidden aspect if (!hiddenAspect.hasHiddenAspect(nodeRef)) { hiddenAspect.hideNode(nodeRef, false, false, false); } return compiledModel; }
private CompiledModel createUpdateModel(final String modelFileName, final M2Model m2Model, final boolean activate, String errMsgId, boolean requiresNewTx) { // Validate model CompiledModel compiledModel = compileModel(m2Model); // Validate properties default values validatePropsDefaultValues(compiledModel); ByteArrayOutputStream xml = new ByteArrayOutputStream(); m2Model.toXML(xml); final InputStream modelStream = new ByteArrayInputStream(xml.toByteArray()); // Create the model node NodeRef nodeRef = doInTransaction(errMsgId, requiresNewTx, new RetryingTransactionCallback<NodeRef>() { public NodeRef execute() throws Exception { return repoAdminService.deployModel(modelStream, modelFileName, activate); } }); if (!nodeService.hasAspect(nodeRef, ASPECT_CUSTOM_MODEL)) { // Add the 'customModelManagement' marker aspect, to // indicate that this model has been created dynamically by this service nodeService.addAspect(nodeRef, ASPECT_CUSTOM_MODEL, null); } // Add hidden aspect if (!hiddenAspect.hasHiddenAspect(nodeRef)) { hiddenAspect.hideNode(nodeRef, false, false, false); } return compiledModel; }