|
| 1 | +/***************************************************************** |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | + * or more contributor license agreements. See the NOTICE file |
| 4 | + * distributed with this work for additional information |
| 5 | + * regarding copyright ownership. The ASF licenses this file |
| 6 | + * to you under the Apache License, Version 2.0 (the |
| 7 | + * "License"); you may not use this file except in compliance |
| 8 | + * with the License. You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + ****************************************************************/ |
| 19 | + |
| 20 | +package org.apache.cayenne.project.upgrade.handlers; |
| 21 | + |
| 22 | +import org.apache.cayenne.configuration.DataChannelDescriptor; |
| 23 | +import org.apache.cayenne.project.upgrade.UpgradeUnit; |
| 24 | +import org.w3c.dom.Element; |
| 25 | + |
| 26 | +/** |
| 27 | + * Upgrade handler for the project version "10" introduced by 4.1.M1 release. |
| 28 | + * Changes highlight: |
| 29 | + * - strict schema for domain (e.g. main project document) |
| 30 | + * - new schema for data map allowing usage of additional elements (e.g. XML extensions) |
| 31 | + * |
| 32 | + * @since 4.1 |
| 33 | + */ |
| 34 | +public class UpgradeHandler_V11 implements UpgradeHandler { |
| 35 | + |
| 36 | + @Override |
| 37 | + public String getVersion() { |
| 38 | + return "11"; |
| 39 | + } |
| 40 | + |
| 41 | + @Override |
| 42 | + public void processProjectDom(UpgradeUnit upgradeUnit) { |
| 43 | + Element domain = upgradeUnit.getDocument().getDocumentElement(); |
| 44 | + // introduce xml namespace and schema for domain |
| 45 | + domain.setAttribute("xmlns","http://cayenne.apache.org/schema/11/domain"); |
| 46 | + domain.setAttribute("xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance"); |
| 47 | + domain.setAttribute("xsi:schemaLocation", "http://cayenne.apache.org/schema/11/domain " + |
| 48 | + "https://cayenne.apache.org/schema/11/domain.xsd"); |
| 49 | + // update version |
| 50 | + domain.setAttribute("project-version", getVersion()); |
| 51 | + } |
| 52 | + |
| 53 | + @Override |
| 54 | + public void processDataMapDom(UpgradeUnit upgradeUnit) { |
| 55 | + // noop |
| 56 | + } |
| 57 | + |
| 58 | + @Override |
| 59 | + public void processModel(DataChannelDescriptor dataChannelDescriptor) { |
| 60 | + // noop |
| 61 | + } |
| 62 | +} |
0 commit comments