001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.autoupdate.updateprovider;
043:
044: import org.netbeans.modules.autoupdate.services.*;
045: import java.net.URL;
046: import java.text.ParseException;
047: import java.util.Date;
048: import java.util.jar.Manifest;
049: import java.util.logging.Level;
050: import java.util.logging.Logger;
051: import org.netbeans.Module;
052: import org.openide.modules.ModuleInfo;
053:
054: /**
055: *
056: * @author Jiri Rechtacek
057: */
058: public class ModuleItem extends UpdateItemImpl {
059:
060: private String codeName;
061: private String specificationVersion;
062: private ModuleInfo info;
063: private String author;
064: private String downloadSize;
065: private String homepage;
066: private String category;
067: private Date publishDate;
068: private boolean isEager;
069: private boolean isAutoload;
070: private String moduleNotification = null;
071:
072: private URL distribution;
073: private Manifest manifest;
074:
075: private UpdateItemDeploymentImpl deployImpl;
076: private UpdateLicenseImpl licenseImpl;
077:
078: protected ModuleItem() {
079: }
080:
081: public ModuleItem(String codeName, String specificationVersion,
082: URL distribution, String author, String publishDateString,
083: String downloadSize, String homepage, String category,
084: Manifest manifest, Boolean isEager, Boolean isAutoload,
085: Boolean needsRestart, Boolean isGlobal,
086: String targetCluster, UpdateLicenseImpl licenseImpl) {
087: this .codeName = codeName;
088: this .specificationVersion = specificationVersion;
089: this .distribution = distribution;
090: this .manifest = manifest;
091: this .deployImpl = new UpdateItemDeploymentImpl(needsRestart,
092: isGlobal, targetCluster, null, null);
093: if (publishDateString != null && publishDateString.length() > 0) {
094: try {
095: this .publishDate = Utilities
096: .parseDate(publishDateString);
097: } catch (ParseException pe) {
098: Logger.getLogger(ModuleItem.class.getName()).log(
099: Level.INFO,
100: "Parsing \"" + publishDateString + "\" of "
101: + codeName + " throws "
102: + pe.getMessage(), pe);
103: } catch (RuntimeException re) {
104: Logger.getLogger(ModuleItem.class.getName()).log(
105: Level.INFO,
106: "Parsing \"" + publishDateString + "\" of "
107: + codeName + " throws "
108: + re.getMessage(), re);
109: }
110: }
111: this .licenseImpl = licenseImpl;
112: this .author = author;
113: this .downloadSize = downloadSize;
114: this .homepage = homepage;
115: this .category = category;
116: this .isEager = isEager;
117: this .isAutoload = isAutoload;
118: }
119:
120: public String getCodeName() {
121: return codeName;
122: }
123:
124: public String getSpecificationVersion() {
125: return specificationVersion;
126: }
127:
128: public URL getDistribution() {
129: return this .distribution;
130: }
131:
132: public String getAuthor() {
133: return author;
134: }
135:
136: public String getHomepage() {
137: return homepage;
138: }
139:
140: public int getDownloadSize() {
141: return Integer.parseInt(downloadSize);
142: }
143:
144: public UpdateItemDeploymentImpl getUpdateItemDeploymentImpl() {
145: return this .deployImpl;
146: }
147:
148: public UpdateLicenseImpl getUpdateLicenseImpl() {
149: return this .licenseImpl;
150: }
151:
152: public ModuleInfo getModuleInfo() {
153: if (info == null) {
154: Module m = Utilities.toModule(codeName,
155: specificationVersion);
156: info = (m != null) ? m : new DummyModuleInfo(manifest
157: .getMainAttributes());
158: }
159: return info;
160: }
161:
162: public String getAgreement() {
163: return getUpdateLicenseImpl().getAgreement();
164: }
165:
166: public String getCategory() {
167: return category;
168: }
169:
170: public String getDate() {
171: return publishDate == null ? null : Utilities
172: .formatDate(publishDate);
173: }
174:
175: public boolean isAutoload() {
176: return isAutoload;
177: }
178:
179: public boolean isEager() {
180: return isEager;
181: }
182:
183: public String getModuleNotification() {
184: return moduleNotification;
185: }
186:
187: void setModuleNotification(String notification) {
188: this.moduleNotification = notification;
189: }
190:
191: }
|