From f1b44f62a8a26c41fc371beac1214ce4f55edc25 Mon Sep 17 00:00:00 2001 From: Chris Wilper Date: Thu, 17 Dec 2009 14:13:20 +0000 Subject: [PATCH] version/build-date/build-number cleanup: + client and server get version info from associated properties file, which is filtered during the build to include the version declared in the pom + changed client's About screen "Release Date" to "Build Date" so this info can automatically come from Client.properties + client also now prints build number in the About screen + server now also logs the build date at startup minor admin gui change: + default size of fedora-admin window and object editor frame increased (but still fits within 1024x768 screens) misc: + got rid of old, unused MakePatch utility class --- fcrepo-client/fcrepo-client-admin/pom.xml | 9 - .../java/fedora/client/Administrator.java | 21 +- .../objecteditor/ObjectEditorFrame.java | 16 +- .../fedora/client/resources/Client.properties | 10 +- fcrepo-client/fcrepo-client-messaging/pom.xml | 14 - .../main/java/fedora/server/BasicServer.java | 15 +- .../src/main/java/fedora/server/Server.java | 12 +- .../fedora/server/access/DefaultAccess.java | 3 +- .../server/messaging/MessagingImpl.java | 3 +- .../main/java/fedora/utilities/MakePatch.java | 368 ------------------ pom.xml | 3 +- .../fedora/server/resources/Server.properties | 14 +- 12 files changed, 49 insertions(+), 439 deletions(-) delete mode 100755 fcrepo-server/src/main/java/fedora/utilities/MakePatch.java diff --git a/fcrepo-client/fcrepo-client-admin/pom.xml b/fcrepo-client/fcrepo-client-admin/pom.xml index 2ed8effd8..bf4d9a3fe 100644 --- a/fcrepo-client/fcrepo-client-admin/pom.xml +++ b/fcrepo-client/fcrepo-client-admin/pom.xml @@ -14,16 +14,7 @@ - - - ../resources/server - true - src/main/resources true diff --git a/fcrepo-client/fcrepo-client-admin/src/main/java/fedora/client/Administrator.java b/fcrepo-client/fcrepo-client-admin/src/main/java/fedora/client/Administrator.java index fd3984699..305bcded4 100755 --- a/fcrepo-client/fcrepo-client-admin/src/main/java/fedora/client/Administrator.java +++ b/fcrepo-client/fcrepo-client-admin/src/main/java/fedora/client/Administrator.java @@ -150,7 +150,9 @@ public class Administrator public static String VERSION = s_const.getString("version"); - public static String RELEASE_DATE = s_const.getString("releaseDate"); + public static String BUILD_DATE = s_const.getString("buildDate"); + + public static String BUILD_NUMBER = s_const.getString("buildNumber"); public static final void showErrorDialog(Component parent, String title, @@ -231,6 +233,7 @@ public Administrator(String protocol, m_aboutPic = new JLabel(aboutIcon); m_aboutText = new JLabel("" + + "

Copyright 2009, DuraSpace

" + "

Copyright 2008-2009, Fedora Commons, Inc.

" + "

Copyright 2002-2007, The Rector and Visitors of the

" + "

University of Virginia and Cornell University.

" @@ -243,13 +246,11 @@ public Administrator(String protocol, + "

basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.

" + "

See the License for the specific language governing rights and

" + "

limitations under the License.

" - + "

Version: " - + VERSION - + "

" - + "

Release Date: " - + RELEASE_DATE - + "

" - + "

See http://www.fedora-commons.org/ for more information.

"); + + "

Version: " + VERSION + "

" + + "

Build Date: " + BUILD_DATE + "

" + + "

Build Number: " + BUILD_NUMBER + "

" + + "

" + + "

See http://fedora-commons.org/ for more information.

"); m_aboutText.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); JPanel splashPicAndText = new JPanel(); @@ -303,8 +304,8 @@ public void windowClosing(WindowEvent e) { splashScreen.setVisible(false); s_instance = this; - int xs = 850; - int ys = 655; + int xs = 1000; + int ys = 744; Dimension sz = getToolkit().getScreenSize(); int xl = sz.width / 2 - xs / 2; int yl = sz.height / 2 - ys / 2; diff --git a/fcrepo-client/fcrepo-client-admin/src/main/java/fedora/client/objecteditor/ObjectEditorFrame.java b/fcrepo-client/fcrepo-client-admin/src/main/java/fedora/client/objecteditor/ObjectEditorFrame.java index d4965c63b..fb5f20117 100755 --- a/fcrepo-client/fcrepo-client-admin/src/main/java/fedora/client/objecteditor/ObjectEditorFrame.java +++ b/fcrepo-client/fcrepo-client-admin/src/main/java/fedora/client/objecteditor/ObjectEditorFrame.java @@ -127,15 +127,15 @@ public ObjectEditorFrame(String pid, int startTab) //setFrameIcon(openIcon); pack(); Dimension dims = getSize(); - if (dims.height < 545) { - dims.height = 545; - } else if (dims.height > 580) { - dims.height = 580; + if (dims.height < 675) { + dims.height = 675; + } else if (dims.height > 700) { + dims.height = 700; } - if (dims.width < 740) { - dims.width = 740; - } else if (dims.width > 820) { - dims.width = 820; + if (dims.width < 925) { + dims.width = 925; + } else if (dims.width > 950) { + dims.width = 950; } setSize(dims); show(); diff --git a/fcrepo-client/fcrepo-client-admin/src/main/resources/fedora/client/resources/Client.properties b/fcrepo-client/fcrepo-client-admin/src/main/resources/fedora/client/resources/Client.properties index 92f7d79d0..dae9db922 100755 --- a/fcrepo-client/fcrepo-client-admin/src/main/resources/fedora/client/resources/Client.properties +++ b/fcrepo-client/fcrepo-client-admin/src/main/resources/fedora/client/resources/Client.properties @@ -1,4 +1,6 @@ -# Client properties. Values generated at build from Server.properties -version=@version@ -releaseDate=@releaseDate@ -compatibleServerVersions=2.2 2.2.1 2.2.2 2.2.3 2.2.4 3.0b1 3.0b2 3.0 3.1 3.2 3.2.1 @version@ +# Client properties + +version=${version} +buildDate=${timestamp} +buildNumber=${buildNumber} +compatibleServerVersions=2.2 2.2.1 2.2.2 2.2.3 2.2.4 3.0b1 3.0b2 3.0 3.1 3.2 3.2.1 ${version} diff --git a/fcrepo-client/fcrepo-client-messaging/pom.xml b/fcrepo-client/fcrepo-client-messaging/pom.xml index 9ea27a940..c455663d8 100644 --- a/fcrepo-client/fcrepo-client-messaging/pom.xml +++ b/fcrepo-client/fcrepo-client-messaging/pom.xml @@ -14,20 +14,6 @@ - - - **/resources diff --git a/fcrepo-server/src/main/java/fedora/server/BasicServer.java b/fcrepo-server/src/main/java/fedora/server/BasicServer.java index a47bd8430..f0dbf8b30 100755 --- a/fcrepo-server/src/main/java/fedora/server/BasicServer.java +++ b/fcrepo-server/src/main/java/fedora/server/BasicServer.java @@ -59,15 +59,18 @@ public void initServer() throws ServerInitializationException { + "not given, but it's required."); } - LOG.info("Fedora Version: " + VERSION_MAJOR + "." + VERSION_MINOR); - LOG.info("Fedora Build: " + BUILD_NUMBER); + LOG.info("Fedora Version: " + Server.VERSION); + LOG.info("Fedora Build Date: " + Server.BUILD_DATE); + LOG.info("Fedora Build Number: " + Server.BUILD_NUMBER); ServerStatusFile status = getStatusFile(); try { - status.append(ServerState.STARTING, "Fedora Version: " - + VERSION_MAJOR + "." + VERSION_MINOR); - status.append(ServerState.STARTING, "Fedora Build: " - + BUILD_NUMBER); + status.append(ServerState.STARTING, + "Fedora Version: " + Server.VERSION); + status.append(ServerState.STARTING, + "Fedora Build Date: " + Server.BUILD_DATE); + status.append(ServerState.STARTING, + "Fedora Build Number: " + Server.BUILD_NUMBER); status.append(ServerState.STARTING, "Server Host Name: " + fedoraServerHost); status.append(ServerState.STARTING, "Server Port: " diff --git a/fcrepo-server/src/main/java/fedora/server/Server.java b/fcrepo-server/src/main/java/fedora/server/Server.java index e571e04d5..1d1178063 100755 --- a/fcrepo-server/src/main/java/fedora/server/Server.java +++ b/fcrepo-server/src/main/java/fedora/server/Server.java @@ -82,15 +82,14 @@ public abstract class Server private static ResourceBundle s_const = ResourceBundle.getBundle("fedora.server.resources.Server"); - /** The major version of this release. */ - public static String VERSION_MAJOR = s_const.getString("version.major"); + /** The version of this release. */ + public static String VERSION = s_const.getString("version"); - /** The minor version of this release. */ - public static String VERSION_MINOR = s_const.getString("version.minor"); + /** The build date of this release. */ + public static String BUILD_DATE = s_const.getString("buildDate"); /** The build number of this release. */ - public static String BUILD_NUMBER = - s_const.getString("version.buildNumber"); + public static String BUILD_NUMBER = s_const.getString("buildNumber"); /** The name of the property that tells the server where it's based. */ public static String HOME_PROPERTY = s_const.getString("home.property"); @@ -123,7 +122,6 @@ public abstract class Server */ public static String NAMESPACE_PREFIX = MessageFormat.format(s_const.getString("namespace.prefix"), - //new Object[] {VERSION_MAJOR, VERSION_MINOR}); new Object[] {"1", "0"}); // so config namespace uses 1/0/ /** The configuration file elements' namespace. 0={namespace.prefix} */ diff --git a/fcrepo-server/src/main/java/fedora/server/access/DefaultAccess.java b/fcrepo-server/src/main/java/fedora/server/access/DefaultAccess.java index 9f8b14f9c..f49769205 100755 --- a/fcrepo-server/src/main/java/fedora/server/access/DefaultAccess.java +++ b/fcrepo-server/src/main/java/fedora/server/access/DefaultAccess.java @@ -701,8 +701,7 @@ public RepositoryInfo describeRepository(Context context) repositoryInfo.repositoryBaseURL = reposBaseURL + "/" + context.getEnvironmentValue(Constants.FEDORA_APP_CONTEXT_NAME); - repositoryInfo.repositoryVersion = - Server.VERSION_MAJOR + "." + Server.VERSION_MINOR; + repositoryInfo.repositoryVersion = Server.VERSION; Module domgr = getServer().getModule("fedora.server.storage.DOManager"); repositoryInfo.repositoryPIDNamespace = domgr.getParameter("pidNamespace"); diff --git a/fcrepo-server/src/main/java/fedora/server/messaging/MessagingImpl.java b/fcrepo-server/src/main/java/fedora/server/messaging/MessagingImpl.java index 59e0a1fdd..df6063581 100644 --- a/fcrepo-server/src/main/java/fedora/server/messaging/MessagingImpl.java +++ b/fcrepo-server/src/main/java/fedora/server/messaging/MessagingImpl.java @@ -34,7 +34,6 @@ public class MessagingImpl implements Messaging { private final Map> mdMap; private final JMSManager jmsMgr; private final String fedoraBaseUrl; - private final static String serverVersion = Server.VERSION_MAJOR + Server.VERSION_MINOR; private final static String messageFormat = Constants.ATOM_APIM1_0.uri; /** @@ -94,7 +93,7 @@ public void send(String destName, FedoraMethod method, FedoraMessage message) public void send(FedoraMethod method) throws MessagingException { if (Management.class == method.getMethod().getDeclaringClass()) { - APIMMessage message = new AtomAPIMMessage(method, fedoraBaseUrl, serverVersion, messageFormat); + APIMMessage message = new AtomAPIMMessage(method, fedoraBaseUrl, Server.VERSION, messageFormat); String methodName = method.getName(); if (methodName.startsWith("ingest") diff --git a/fcrepo-server/src/main/java/fedora/utilities/MakePatch.java b/fcrepo-server/src/main/java/fedora/utilities/MakePatch.java deleted file mode 100755 index 788518b91..000000000 --- a/fcrepo-server/src/main/java/fedora/utilities/MakePatch.java +++ /dev/null @@ -1,368 +0,0 @@ -/* The contents of this file are subject to the license and copyright terms - * detailed in the license directory at the root of the source tree (also - * available online at http://fedora-commons.org/license/). - */ -package fedora.utilities; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStreamReader; - -import java.util.ArrayList; -import java.util.List; -import java.util.Properties; -import java.util.jar.JarEntry; -import java.util.jar.JarOutputStream; - -import com.twmacinta.util.MD5; -import com.twmacinta.util.MD5InputStream; - -/** - * Makes a patch of Fedora client/server distribution. - * ----------------------------------------------------------------------------- - */ -public class MakePatch { - - private final boolean m_beVerbose; - - private boolean diffPrompt = false; - - private final BufferedReader br = - new BufferedReader(new InputStreamReader(System.in)); - - public MakePatch(File originBinDir, - File originSrcDir, - String originVer, - File targetBinDir, - File targetSrcDir, - String targetVer, - File destDir, - boolean beVerbose, - boolean diffPrompt) - throws Exception { - MD5.initNativeLibrary(true); // never check for native libs - m_beVerbose = beVerbose; - this.diffPrompt = diffPrompt; - print("Building patch..."); - print("File 1/3 - Client"); - ArrayList clientPatchList = new ArrayList(); - File targetClientDir = new File(targetBinDir, "client"); - getDiffs(new File(originBinDir, "client"), - targetClientDir, - clientPatchList, - ""); - makeJar(new File(destDir, "fedora-" + originVer + "-client-to-" - + targetVer + "-patch.jar"), targetClientDir, clientPatchList); - print("File 2/3 - Server"); - ArrayList serverPatchList = new ArrayList(); - File targetServerDir = new File(targetBinDir, "server"); - getDiffs(new File(originBinDir, "server"), - targetServerDir, - serverPatchList, - ""); - makeJar(new File(destDir, "fedora-" + originVer + "-server-to-" - + targetVer + "-patch.jar"), targetServerDir, serverPatchList); - print("File 3/3 - Source"); - ArrayList sourcePatchList = new ArrayList(); - getDiffs(originSrcDir, targetSrcDir, sourcePatchList, ""); - makeJar(new File(destDir, "fedora-" + originVer + "-src-to-" - + targetVer + "-patch.jar"), targetSrcDir, sourcePatchList); - print("Done."); - } - - public void makeJar(File outFile, File inDir, List fList) throws Exception { - JarOutputStream out = - new JarOutputStream(new FileOutputStream(outFile)); - byte[] buf = new byte[8192]; - for (int i = 0; i < fList.size(); i++) { - String name = (String) fList.get(i); - File f = new File(inDir, name); - JarEntry entry = new JarEntry(name); - entry.setSize(getSize(f)); - out.putNextEntry(entry); - FileInputStream in = new FileInputStream(f); - int len; - while ((len = in.read(buf)) != -1) { - out.write(buf, 0, len); - } - in.close(); - out.closeEntry(); - } - out.close(); - } - - public long getSize(File f) throws Exception { - long size = 0; - FileInputStream s = new FileInputStream(f); - byte[] buf = new byte[8192]; - int len; - while ((len = s.read(buf)) != -1) { - size += len; - } - s.close(); - return size; - } - - // Put list of filenames of files that are - // new or different in "to" into "out". - public void getDiffs(File from, File to, ArrayList out, String prependPath) - throws Exception { - verbose("Getting diffs for ./" + prependPath); - String[] toNames = to.list(); - boolean fromIsDir = from.isDirectory(); - for (String element : toNames) { - File toFile = new File(to, element); - if (toFile.isDirectory()) { - getDiffs(new File(from, element), toFile, out, prependPath - + element + "/"); - } else { - if (!fromIsDir) { - // all files must be added since its a new dir - String a = prependPath + element; - verbose("Adding file because its dir is new: " + a); - out.add(a); - } else { - // check for existence of each file - File fromFile = new File(from, element); - if (!fromFile.exists()) { - String a = prependPath + element; - verbose("Adding file because it is new: " + a); - out.add(a); - } else { - // both exist, so check for diffs - if (filesDiffer(fromFile, toFile)) { - String a = prependPath + element; - String r = null; - if (diffPrompt) { - System.out - .println("File " - + a - + " has changed. Include in patch? [y]es/no "); - r = br.readLine(); - } - if (!diffPrompt || r.equals("") - || r.toUpperCase().startsWith("y")) { - verbose("Adding file because it differs: " + a); - out.add(a); - } else { - verbose("Skipped " + a - + " even though it differs."); - } - } else { - /* - * String a=prependPath + toNames[i]; - * verbose("Unchanged, skipping: " + a); - */ - } - } - } - } - } - } - - public boolean filesDiffer(File a, File b) throws Exception { - return !getChecksum(a).equals(getChecksum(b)); - } - - public String getChecksum(File f) throws Exception { - MD5InputStream s = new MD5InputStream(new FileInputStream(f)); - byte[] buf = new byte[8192]; - int len; - while ((len = s.read(buf)) != -1) { - } - String out = MD5.asHex(s.hash()); - s.close(); - return out; - } - - public void verbose(String msg) { - if (m_beVerbose) { - System.out.println(msg); - } - } - - public void print(String msg) { - System.out.println(msg); - } - - public static String getFedoraVersion(File dir, boolean binDist) - throws Exception { - if (binDist) { - if (!dir.exists()) { - throw new IOException("Provided directory, " - + dir.getAbsolutePath() + " does not exist!"); - } - if (!dir.isDirectory()) { - throw new IOException("Provided directory, " - + dir.getAbsolutePath() + " is not a directory!"); - } - String[] dirNames = dir.list(); - boolean foundClient = false; - boolean foundServer = false; - for (String element : dirNames) { - if (element.equals("client")) { - foundClient = true; - } - if (element.equals("server")) { - foundServer = true; - } - } - if (!foundClient) { - throw new IOException("Cannot find client dir in " - + dir.getAbsolutePath()); - } - if (!foundServer) { - throw new IOException("Cannot find server dir in " - + dir.getAbsolutePath()); - } - } - Properties props = new Properties(); - if (binDist) { - props - .load(new FileInputStream(new File(dir, - "server/tomcat41/webapps/fedora/WEB-INF/classes/fedora/server/resources/Server.properties"))); - } else { - props - .load(new FileInputStream(new File(dir, - "server/src/main/resources/properties/server/fedora/server/resources/Server.properties"))); - } - String major = props.getProperty("version.major"); - String minor = props.getProperty("version.minor"); - return major + "." + minor; - } - - public static void main(String[] args) { - try { - System.out - .println("----------------------------------------------"); - System.out - .println("MakePatch - Build a Fedora distribution patch."); - System.out - .println("----------------------------------------------"); - System.out - .println("This program will create patch files to go from one complete"); - System.out.println("Fedora distribution to another.\n"); - System.out - .println("Before continuing, you should have two complete"); - System.out - .println("Fedora distributions (client, server, and full source for each)"); - System.out - .println("unpacked in directories that you can provide to this program.\n"); - System.out.println("Do you have this information? [y]es/no "); - BufferedReader br = - new BufferedReader(new InputStreamReader(System.in)); - String r = br.readLine(); - System.out.println(); - if (r.equals("") || r.toUpperCase().startsWith("Y")) { - // - // Get origin information - // - System.out - .println("Enter the FEDORA_HOME directory of the origin binary distribution."); - System.out - .println("(this is the directory with the client/ and server/ directories)"); - System.out.println("Origin Binary Distribution Directory: "); - File originBinDir = new File(br.readLine()); - String originBinVer = - MakePatch.getFedoraVersion(originBinDir, true); - System.out.println("Appears to be a Fedora v" + originBinVer - + " binary distribution, ok.\n"); - System.out - .println("Enter the installation directory of the origin source distribution."); - System.out - .println("(this is the directory with the build.xml file)"); - System.out.println("Origin Source Distribution Directory: "); - File originSrcDir = new File(br.readLine()); - String originSrcVer = - MakePatch.getFedoraVersion(originSrcDir, false); - if (!originSrcVer.equals(originBinVer)) { - throw new IOException("Origin binary version is " - + originBinVer + ", but origin source version is " - + originSrcVer); - } - System.out - .println("Origin source and binary distributions match, good.\n"); - // - // Get target information - // - System.out.println("Target Binary Distribution Directory: "); - File targetBinDir = new File(br.readLine()); - String targetBinVer = - MakePatch.getFedoraVersion(targetBinDir, true); - if (originBinVer.equals(targetBinVer)) { - throw new IOException("Target binary version can't be the same as origin binary version."); - } - System.out.println("Appears to be a Fedora v" + targetBinVer - + " binary distribution, ok.\n"); - System.out.println("Target Source Distribution Directory: "); - File targetSrcDir = new File(br.readLine()); - String targetSrcVer = - MakePatch.getFedoraVersion(targetSrcDir, false); - if (!targetSrcVer.equals(targetBinVer)) { - throw new IOException("Target binary version is " - + targetBinVer + ", but target source version is " - + targetSrcVer); - } - System.out - .println("Target source and binary distributions match, good.\n"); - // - // Get output dir - // - System.out - .println("Enter the directory where the patch files should be written."); - System.out.println("(if it doesn't exist, it will be created)"); - System.out.println("Output Directory: "); - File outputDir = new File(br.readLine()); - if (!outputDir.exists()) { - if (outputDir.mkdirs()) { - System.out.println("Created output directory " - + outputDir.getAbsolutePath()); - } else { - throw new IOException("Unable to create output directory."); - } - } - // - // Confirm and start - // - System.out.println("\nAbout to create patch files for Fedora v" - + originSrcVer + " to v" + targetSrcVer + " upgrade."); - System.out - .println("Want to be prompted before adding items that differ? [y]es/no "); - r = br.readLine(); - boolean doPrompt = false; - if (r.equals("") || r.toUpperCase().startsWith("Y")) { - doPrompt = true; - } - System.out.println("Want verbose output? [y]es/no/cancel "); - r = br.readLine(); - boolean beVerbose = false; - if (r.equals("") || r.toUpperCase().startsWith("Y")) { - beVerbose = true; - } - if (r.toUpperCase().startsWith("C")) { - System.out.println("Patch canceled."); - } else { - MakePatch p = - new MakePatch(originBinDir, - originSrcDir, - originSrcVer, - targetBinDir, - targetSrcDir, - targetSrcVer, - outputDir, - beVerbose, - doPrompt); - } - } else { - System.out - .println("Re-run this program when you have the information."); - } - } catch (Exception e) { - System.out.println("Error: " + e.getMessage()); - } - } - -} diff --git a/pom.xml b/pom.xml index d86effa83..627e6d688 100644 --- a/pom.xml +++ b/pom.xml @@ -429,8 +429,7 @@ ${version} - {0,date,yyyy-MM-dd - HH:mm:ss} + {0,date,yyyy-MM-dd HH:mm:ss 'UTC'Z} diff --git a/resources/server/fedora/server/resources/Server.properties b/resources/server/fedora/server/resources/Server.properties index 19a5b2132..fecdae1a0 100755 --- a/resources/server/fedora/server/resources/Server.properties +++ b/resources/server/fedora/server/resources/Server.properties @@ -1,12 +1,12 @@ -# The default property values for the Fedora reference implementation. -# See the javadoc for fedora.server.Server for descriptions of these properties. +# Server properties -# NON-LOCALIZABLE (Constants) +version=${version} +buildDate=${timestamp} +buildNumber=${buildNumber} + +# NOTE: Many of the constants below are either no longer used, or +# never expected to change, and used only by [Basic]Server.java. -version.major=3 -version.minor=3 -version.releaseDate=December 2009 -version.buildNumber=@buildNumber@ home.property=fedora.home format.storage=info:fedora/fedora-system:FOXML-1.1 config.dir=config