01: /*
02: * The contents of this file are subject to the terms of the Common Development
03: * and Distribution License (the License). You may not use this file except in
04: * compliance with the License.
05: *
06: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
07: * or http://www.netbeans.org/cddl.txt.
08: *
09: * When distributing Covered Code, include this CDDL Header Notice in each file
10: * and include the License file at http://www.netbeans.org/cddl.txt.
11: * If applicable, add the following below the CDDL Header, with the fields
12: * enclosed by brackets [] replaced by your own identifying information:
13: * "Portions Copyrighted [year] [name of copyright owner]"
14: *
15: * The Original Software is NetBeans. The Initial Developer of the Original
16: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17: * Microsystems, Inc. All Rights Reserved.
18: */
19: package org.netbeans.modules.xslt.project.anttasks;
20:
21: import java.io.File;
22: import java.util.logging.Level;
23: import java.util.logging.Logger;
24: import org.apache.tools.ant.BuildException;
25: import org.netbeans.modules.xml.wsdl.model.ReferenceableWSDLComponent;
26: import org.netbeans.modules.xml.xam.dom.NamedComponentReference;
27: import org.netbeans.modules.xslt.tmap.model.api.TMapModel;
28:
29: /**
30: *
31: * @author Vitaly Bychkov
32: */
33: public class IDEJBIGenerator extends AbstractJBIGenerator {
34: private Logger logger = Logger.getLogger(IDEJBIGenerator.class
35: .getName());
36:
37: public IDEJBIGenerator(String srcDir, String buildDir) {
38: super (srcDir, buildDir);
39: }
40:
41: @Override
42: protected <T extends ReferenceableWSDLComponent> T resolveReference(
43: NamedComponentReference<T> ref) {
44: if (ref == null) {
45: return null;
46: }
47: return ref.get();
48: }
49:
50: @Override
51: protected TMapModel getTMapModel() {
52: File transformmapFile = getTransformmapFile();
53: if (transformmapFile == null) {
54: logger.log(Level.SEVERE,
55: "Error encountered while processing transformmap file - "
56: + transformmapFile.getAbsolutePath());
57: throw new BuildException(
58: "Can't find transformation descriptor");
59: }
60: TMapModel tMapModel = null;
61: try {
62: tMapModel = IDETMapCatalogModel.getDefault().getTMapModel(
63: transformmapFile);
64: } catch (Exception ex) {
65: this .logger.log(java.util.logging.Level.SEVERE,
66: "Error while creating Tramsformap Model ", ex);
67: throw new RuntimeException(
68: "Error while creating Transformmap Model ", ex);
69: }
70:
71: if (tMapModel == null
72: || !TMapModel.State.VALID.equals(tMapModel.getState())) {
73: this .logger.log(java.util.logging.Level.SEVERE,
74: "Error while creating Transformmap Model - "
75: + (tMapModel == null ? " is null"
76: : " is not valid"));
77: throw new BuildException(
78: "Error while creating Transformmap Model ");
79: }
80: return tMapModel;
81: }
82:
83: }
|