List of usage examples for java.util.jar Attributes getValue
public String getValue(Name name)
From source file:org.cleverbus.core.common.version.impl.ManifestVersionInfoSource.java
private VersionInfo createVersionInfo(Manifest manifest) { Attributes attrs = manifest.getMainAttributes(); return new VersionInfo(getTitle(attrs), getVendorId(attrs), getVersion(attrs), attrs.getValue(ATTR_REVISION), attrs.getValue(ATTR_TIMESTAMP)); }
From source file:org.alfresco.web.scripts.ShareManifest.java
/** * Retrieve attribute value from the main section of a manifest. * /*from www . j a v a 2s . c o m*/ * @param key The name of the attribute to fetch. * @return The attribute value. */ public String mainAttributeValue(String key) { String value = null; Attributes attributes = manifest.getMainAttributes(); if (attributes != null) { value = attributes.getValue(key); } return value; }
From source file:org.alfresco.web.scripts.ShareManifest.java
/** * Retrieve an attribute value by name from the specific named section of a manifest. * //from w ww . j a v a2s . co m * @param section Section name. * @param key Attribute name. * @return The attribute value. */ public String attributeValue(String section, String key) { String value = null; Attributes attributes = manifest.getAttributes(section); if (attributes != null) { value = attributes.getValue(key); } return value; }
From source file:org.pepstock.jem.gwt.server.listeners.StartUp.java
/** * Set the jem Version//w w w.j a v a2 s. c o m * * @param contextPath */ private void setJemVersion(ServletContext context) { // reads manifest file for searching version of JEM InputStream fis = null; try { fis = context.getResourceAsStream(MANIFEST_FILE); if (fis == null) { throw new FileNotFoundException(MANIFEST_FILE); } Manifest manifest = new Manifest(fis); // gets JEM vrsion Attributes at = manifest.getAttributes(ConfigKeys.JEM_MANIFEST_SECTION); String jemVersion = at.getValue(ConfigKeys.JEM_MANIFEST_VERSION); // saves JEM version if (jemVersion != null) { SharedObjects.getInstance().setJemVersion(jemVersion); } } catch (FileNotFoundException e) { // to ignore stack trace LogAppl.getInstance().ignore(e.getMessage(), e); LogAppl.getInstance().emit(NodeMessage.JEMC184W); } catch (IOException e) { // to ignore stack trace LogAppl.getInstance().ignore(e.getMessage(), e); LogAppl.getInstance().emit(NodeMessage.JEMC184W); } finally { if (fis != null) { try { fis.close(); } catch (Exception e) { LogAppl.getInstance().ignore(e.getMessage(), e); } } } }
From source file:com.sketchy.server.UpgradeUploadServlet.java
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { JSONServletResult jsonServletResult = new JSONServletResult(Status.SUCCESS); try {//from www.ja v a 2s . c om boolean isMultipart = ServletFileUpload.isMultipartContent(request); if (isMultipart) { DiskFileItemFactory factory = new DiskFileItemFactory(); factory.setRepository(FileUtils.getTempDirectory()); factory.setSizeThreshold(MAX_SIZE); ServletFileUpload servletFileUpload = new ServletFileUpload(factory); List<FileItem> files = servletFileUpload.parseRequest(request); String version = ""; for (FileItem fileItem : files) { String uploadFileName = fileItem.getName(); if (StringUtils.isNotBlank(uploadFileName)) { JarInputStream jarInputStream = null; try { // check to make sure it's a Sketchy File with a Manifest File jarInputStream = new JarInputStream(fileItem.getInputStream(), true); Manifest manifest = jarInputStream.getManifest(); if (manifest == null) { throw new Exception("Invalid Upgrade File!"); } Attributes titleAttributes = manifest.getMainAttributes(); if ((titleAttributes == null) || (!StringUtils.containsIgnoreCase( titleAttributes.getValue("Implementation-Title"), "Sketchy"))) { throw new Exception("Invalid Upgrade File!"); } version = titleAttributes.getValue("Implementation-Version"); } catch (Exception e) { throw new Exception("Invalid Upgrade File!"); } finally { IOUtils.closeQuietly(jarInputStream); } // save new .jar file as "ready" fileItem.write(new File("Sketchy.jar.ready")); jsonServletResult.put("version", version); } } } } catch (Exception e) { jsonServletResult = new JSONServletResult(Status.ERROR, e.getMessage()); } response.setContentType("text/html"); response.setStatus(HttpServletResponse.SC_OK); response.getWriter().print(jsonServletResult.toJSONString()); }
From source file:hudson.plugins.simpleupdatesite.HPI.java
public List<Dependency> getDependencies(Attributes attributes) throws IOException { String deps = attributes.getValue("Plugin-Dependencies"); if (deps == null) { return Collections.emptyList(); }//from w ww . j ava 2 s. c o m List<Dependency> result = new ArrayList<Dependency>(); for (String token : deps.split(",")) { result.add(new Dependency(token)); } return result; }
From source file:org.bndtools.rt.repository.server.RepositoryResourceComponent.java
@POST @Path("bundles") @Consumes({ MediaType.APPLICATION_OCTET_STREAM, ProvisioningService.MIME_BUNDLE }) public Response uploadBundle(@Context UriInfo uriInfo, InputStream stream) throws Exception { if (!repo.canWrite()) return Response.status(Status.BAD_REQUEST).entity("Repository is not writeable").build(); InputStream bufferedStream = stream.markSupported() ? stream : new BufferedInputStream(stream); Manifest manifest = readManifest(bufferedStream); Attributes mainAttribs = manifest.getMainAttributes(); String bsn = mainAttribs.getValue(Constants.BUNDLE_SYMBOLICNAME); if (bsn == null) return Response.status(Status.BAD_REQUEST).entity("not a bundle").build(); String versionStr = mainAttribs.getValue(Constants.BUNDLE_VERSION); Version version = versionStr != null ? new Version(versionStr) : Version.emptyVersion; URI bundleLocation = uriInfo.getAbsolutePathBuilder().path("{bsn}/{version}").build(bsn, version); repo.put(bufferedStream, RepositoryPlugin.DEFAULTOPTIONS); return Response.created(bundleLocation).build(); }
From source file:hudson.plugins.simpleupdatesite.HPI.java
public List<Developer> getDevelopers(Attributes attributes) throws IOException { String devs = attributes.getValue("Plugin-Developers"); if (devs == null || devs.trim().length() == 0) { return Collections.emptyList(); }// w ww. j a v a 2s .c o m List<Developer> result = new ArrayList<Developer>(); Matcher matcher = this.developersPattern.matcher(devs); int totalMatched = 0; while (matcher.find()) { result.add(new Developer(StringUtils.trimToEmpty(matcher.group(1)), StringUtils.trimToEmpty(matcher.group(2)), StringUtils.trimToEmpty(matcher.group(3)))); totalMatched += matcher.end() - matcher.start(); } if (totalMatched < devs.length()) { // ignore and move on System.err.println("Unparsable developer info: '" + devs.substring(totalMatched) + "'"); } return result; }
From source file:at.gv.egiz.bku.spring.ConfigurationFactoryBean.java
protected Configuration getVersionConfiguration() throws IOException { Map<String, Object> map = new HashMap<String, Object>(); map.put(MOCCA_IMPLEMENTATIONNAME_PROPERTY, "MOCCA"); // implementation version String version = null;/* w w w . j a v a 2 s. c o m*/ try { Resource resource = resourceLoader.getResource("META-INF/MANIFEST.MF"); Manifest properties = new Manifest(resource.getInputStream()); Attributes attributes = properties.getMainAttributes(); // TODO: replace by Implementation-Version ? version = attributes.getValue("Implementation-Build"); } catch (Exception e) { log.warn("Failed to get implemenation version from manifest. {}", e.getMessage()); } if (version == null) { version = "UNKNOWN"; } map.put(MOCCA_IMPLEMENTATIONVERSION_PROPERTY, version); // signature layout try { String classContainer = JarLocation.get(CreateXMLSignatureCommandImpl.class); URL manifestUrl = new URL("jar:" + classContainer + "!/META-INF/MANIFEST.MF"); log.debug(manifestUrl.toString()); Manifest manifest = new Manifest(manifestUrl.openStream()); Attributes attributes = manifest.getMainAttributes(); String signatureLayout = attributes.getValue("SignatureLayout"); if (signatureLayout != null) { map.put(SIGNATURE_LAYOUT_PROPERTY, signatureLayout); } } catch (Exception e) { log.warn("Failed to get signature layout from manifest.", e); } return new MapConfiguration(map); }
From source file:org.sonarsource.sonarlint.core.plugin.PluginManifest.java
private void loadManifest(Manifest manifest) { Attributes attributes = manifest.getMainAttributes(); this.key = PluginKeyUtils.sanitize(attributes.getValue(KEY_ATTRIBUTE)); this.mainClass = attributes.getValue(MAIN_CLASS_ATTRIBUTE); this.name = attributes.getValue(NAME_ATTRIBUTE); this.version = attributes.getValue(VERSION_ATTRIBUTE); this.sonarVersion = attributes.getValue(SONAR_VERSION_ATTRIBUTE); this.useChildFirstClassLoader = StringUtils .equalsIgnoreCase(attributes.getValue(USE_CHILD_FIRST_CLASSLOADER), "true"); String slSupported = attributes.getValue(SONARLINT_SUPPORTED); this.sonarLintSupported = slSupported != null ? StringUtils.equalsIgnoreCase(slSupported, "true") : null; this.basePlugin = attributes.getValue(BASE_PLUGIN); this.implementationBuild = attributes.getValue(IMPLEMENTATION_BUILD); String deps = attributes.getValue(DEPENDENCIES_ATTRIBUTE); this.dependencies = StringUtils.split(StringUtils.defaultString(deps), ' '); String requires = attributes.getValue(REQUIRE_PLUGINS_ATTRIBUTE); this.requirePlugins = StringUtils.split(StringUtils.defaultString(requires), ','); }