Project

General

Profile

« Previous | Next » 

Revision b91fa795

Added by Cherian Mathew over 8 years ago

#5302 Add new jsp to provide general server info

View differences:

src/main/java/eu/etaxonomy/cdm/server/Bootloader.java
26 26
import java.io.File;
27 27
import java.io.FileNotFoundException;
28 28
import java.io.FileOutputStream;
29
import java.io.FilenameFilter;
29 30
import java.io.IOException;
30 31
import java.io.InputStream;
31 32
import java.io.InputStreamReader;
......
35 36
import java.util.ArrayList;
36 37
import java.util.List;
37 38
import java.util.Properties;
39
import java.util.jar.Attributes;
40
import java.util.jar.JarFile;
41
import java.util.jar.Manifest;
38 42
import java.util.regex.Pattern;
39 43

  
40 44
import org.apache.commons.cli.CommandLine;
......
135 139

  
136 140
    private boolean isRunningFromWarFile;
137 141

  
142
    private String cdmlibServicesVersion = "";
143
    private String cdmlibServicesLastModified = "";
144

  
138 145

  
139 146
    /* thread save singleton implementation */
140 147

  
......
241 248
            try {
242 249
                logger.info("Unpacking " + warFileName);
243 250
                warFile = unzip(warFile, warName);
251

  
252
                // get the 'Bundle-Version' and 'Bnd-LastModified' properties of the
253
                // manifest file in the cdmlib services jar
254
                if(warFile != null && warFile.isDirectory()) {
255
                    // generate the webapp lib dir path
256
                    String warLibDirAbsolutePath = warFile.getAbsolutePath() +
257
                            File.separator +
258
                            "WEB-INF" +
259
                            File.separator +
260
                            "lib";
261
                    File warLibDir = new File(warLibDirAbsolutePath);
262
                    if(warLibDir.exists()) {
263
                        // get the cdmlib-services jar
264
                        File [] files = warLibDir.listFiles(new FilenameFilter() {
265
                            @Override
266
                            public boolean accept(File dir, String name) {
267
                                return name.startsWith("cdmlib-services") && name.endsWith(".jar");
268
                            }
269
                        });
270
                        if(files != null && files.length > 0) {
271
                            // get the relevant info from the jar manifest
272
                            JarFile jarFile = new JarFile(files[0]);
273
                            Manifest manifest = jarFile.getManifest();
274
                            Attributes attributes = manifest.getMainAttributes();
275
                            // from the OSGI spec the LastModified value is " the number of milliseconds
276
                            // since midnight Jan. 1, 1970 UTC with the condition that a change must
277
                            // always result in a higher value than the previous last modified time
278
                            // of any bundle"
279
                            cdmlibServicesVersion = attributes.getValue("Bundle-Version");
280
                            logger.warn("cdmlib-services version : " + cdmlibServicesVersion);
281
                            cdmlibServicesLastModified = attributes.getValue("Bnd-LastModified");
282
                            logger.warn("cdmlib-services last modified timestamp : " + cdmlibServicesLastModified);
283

  
284
                            if(cdmlibServicesVersion == null || cdmlibServicesLastModified == null) {
285
                                throw new IllegalStateException("Invalid cdmlib-services manifest file");
286
                            }
287
                        } else {
288
                            throw new IllegalStateException("cdmlib-services jar not found ");
289
                        }
290
                    }
291
                }
244 292
            } catch (IOException e) {
245 293
                logger.error("extractWar() - Unziping of war file " + warFile + " failed. Will return the war file itself instead of the extracted folder.", e);
246 294
            }
......
250 298
    }
251 299

  
252 300

  
301
    public String getCdmlibServicesVersion() {
302
        return cdmlibServicesVersion;
303
    }
304

  
305
    public String getCdmlibServicesLastModified() {
306
        return cdmlibServicesLastModified;
307
    }
253 308
    /**
254 309
     * @param extractWar
255 310
     * @return

Also available in: Unified diff