Use maven plugins from AAI-2198 to do batch reformat of aai-utils
to consistent code style.
Change-Id: Ia67b73b69427799bfb3198f1cded820840e9ee6d
Issue-ID: AAI-1523
Signed-off-by: Keong Lim <keong.lim@huawei.com>
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* limitations under the License.
* ============LICENSE_END=========================================================
*/
* limitations under the License.
* ============LICENSE_END=========================================================
*/
package org.onap.aaiutils.oxm;
import java.io.File;
package org.onap.aaiutils.oxm;
import java.io.File;
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.xml.bind.JAXBException;
import javax.xml.bind.JAXBException;
import org.eclipse.persistence.jaxb.JAXBContextProperties;
import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContextFactory;
import org.eclipse.persistence.jaxb.JAXBContextProperties;
import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContextFactory;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;
public class OxmModelLoader {
private static final Pattern AAI_OXM_FILE_PATTERN = Pattern.compile("aai_oxm_(.*).xml");
private static Map<String, DynamicJAXBContext> versionContextMap = new ConcurrentHashMap<>();
public class OxmModelLoader {
private static final Pattern AAI_OXM_FILE_PATTERN = Pattern.compile("aai_oxm_(.*).xml");
private static Map<String, DynamicJAXBContext> versionContextMap = new ConcurrentHashMap<>();
- private static final Logger LOGGER = LoggerFactory.getInstance()
- .getLogger(OxmModelLoader.class.getName());
+ private static final Logger LOGGER = LoggerFactory.getInstance().getLogger(OxmModelLoader.class.getName());
public synchronized static void loadModels() throws Exception {
OxmModelLoader.loadModels("classpath*:/oxm/aai_oxm*.xml", AAI_OXM_FILE_PATTERN);
public synchronized static void loadModels() throws Exception {
OxmModelLoader.loadModels("classpath*:/oxm/aai_oxm*.xml", AAI_OXM_FILE_PATTERN);
try {
OxmModelLoader.loadModel(matcher.group(1), resource);
} catch (Exception e) {
try {
OxmModelLoader.loadModel(matcher.group(1), resource);
} catch (Exception e) {
- LOGGER.error(OxmModelLoaderMsgs.OXM_LOAD_ERROR, "Failed to load " + resource.getFilename()
- + ": " + e.getMessage());
+ LOGGER.error(OxmModelLoaderMsgs.OXM_LOAD_ERROR,
+ "Failed to load " + resource.getFilename() + ": " + e.getMessage());
throw new Exception("Failed to load schema");
}
}
throw new Exception("Failed to load schema");
}
}
}
public static DynamicJAXBContext getContextForVersion(String version) throws Exception {
}
public static DynamicJAXBContext getContextForVersion(String version) throws Exception {
loadModel(version, file.getName(), inputStream);
}
loadModel(version, file.getName(), inputStream);
}
- private synchronized static void loadModel(String version, Resource resource)
- throws JAXBException, IOException {
+ private synchronized static void loadModel(String version, Resource resource) throws JAXBException, IOException {
InputStream inputStream = resource.getInputStream();
loadModel(version, resource.getFilename(), inputStream);
}
private synchronized static void loadModel(String version, String resourceName, InputStream inputStream)
InputStream inputStream = resource.getInputStream();
loadModel(version, resource.getFilename(), inputStream);
}
private synchronized static void loadModel(String version, String resourceName, InputStream inputStream)
- throws JAXBException, IOException {
+ throws JAXBException, IOException {
Map<String, Object> properties = new HashMap<>();
properties.put(JAXBContextProperties.OXM_METADATA_SOURCE, inputStream);
final DynamicJAXBContext jaxbContext = DynamicJAXBContextFactory
Map<String, Object> properties = new HashMap<>();
properties.put(JAXBContextProperties.OXM_METADATA_SOURCE, inputStream);
final DynamicJAXBContext jaxbContext = DynamicJAXBContextFactory
- .createContextFromOXM(Thread.currentThread().getContextClassLoader(), properties);
+ .createContextFromOXM(Thread.currentThread().getContextClassLoader(), properties);
versionContextMap.put(version, jaxbContext);
versionContextMap.put(version, jaxbContext);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* limitations under the License.
* ============LICENSE_END=========================================================
*/
* limitations under the License.
* ============LICENSE_END=========================================================
*/
package org.onap.aaiutils.oxm;
public class OxmModelLoaderConstants {
package org.onap.aaiutils.oxm;
public class OxmModelLoaderConstants {
- public static final String AaiUtils_FILESEP = (System.getProperty ( "file.separator" ) == null) ? "/"
- : System.getProperty ( "file.separator" );
+ public static final String AaiUtils_FILESEP =
+ (System.getProperty("file.separator") == null) ? "/" : System.getProperty("file.separator");
- public static final String AaiUtils_SPECIFIC_CONFIG = System.getProperty ( "CONFIG_HOME" ) + AaiUtils_FILESEP;
+ public static final String AaiUtils_SPECIFIC_CONFIG =
+ System.getProperty("CONFIG_HOME") + AaiUtils_FILESEP;
- public static final String AaiUtils_HOME_MODEL = AaiUtils_SPECIFIC_CONFIG + "model" + AaiUtils_FILESEP;
+ public static final String AaiUtils_HOME_MODEL =
+ AaiUtils_SPECIFIC_CONFIG + "model" + AaiUtils_FILESEP;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* limitations under the License.
* ============LICENSE_END=========================================================
*/
* limitations under the License.
* ============LICENSE_END=========================================================
*/
package org.onap.aaiutils.oxm;
import com.att.eelf.i18n.EELFResourceManager;
package org.onap.aaiutils.oxm;
import com.att.eelf.i18n.EELFResourceManager;
import org.onap.aai.cl.eelf.LogMessageEnum;
public enum OxmModelLoaderMsgs implements LogMessageEnum {
import org.onap.aai.cl.eelf.LogMessageEnum;
public enum OxmModelLoaderMsgs implements LogMessageEnum {
/**
* Invalid Model File
* Arguments:
/**
* Invalid Model File
* Arguments:
- INVALID_OXM_FILE,
- INVALID_OXM_DIR,
+ INVALID_OXM_FILE, INVALID_OXM_DIR,
/**
* Unable to load OXM schema: {0}
*
/**
* Unable to load OXM schema: {0}
*
* {0} = error
*/
OXM_LOAD_ERROR,
* {0} = error
*/
OXM_LOAD_ERROR,
/**
* Successfully loaded schema: {0}
*
/**
* Successfully loaded schema: {0}
*
* {0} = oxm filename
*/
LOADED_OXM_FILE;
* {0} = oxm filename
*/
LOADED_OXM_FILE;
* limitations under the License.
* ============LICENSE_END=========================================================
*/
* limitations under the License.
* ============LICENSE_END=========================================================
*/
package org.onap.aaiutils.oxm;
import java.util.regex.Pattern;
package org.onap.aaiutils.oxm;
import java.util.regex.Pattern;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
thrown.expect(Exception.class);
thrown.expectMessage("Failed to load schema");
thrown.expect(Exception.class);
thrown.expectMessage("Failed to load schema");
- OxmModelLoader.loadModels("classpath*:non_existing_aai_oxm*.xml", Pattern.compile("non_existing_aai_oxm_(.*).xml"));
+ OxmModelLoader.loadModels("classpath*:non_existing_aai_oxm*.xml",
+ Pattern.compile("non_existing_aai_oxm_(.*).xml"));
-}
\ No newline at end of file