public void putAllTyped(Map<String, Object> attrs) { for (Map.Entry<String, Object> entry : attrs.entrySet()) { Object value = entry.getValue(); String key = entry.getKey(); putTyped(key, value); } }
public void putAllTyped(Map<String, Object> attrs) { for (Map.Entry<String, Object> entry : attrs.entrySet()) { Object value = entry.getValue(); String key = entry.getKey(); putTyped(key, value); } }
public void putAllTyped(Map<String, Object> attrs) { for (Map.Entry<String, Object> entry : attrs.entrySet()) { Object value = entry.getValue(); String key = entry.getKey(); putTyped(key, value); } }
public void putAllTyped(Map<String, Object> attrs) { for (Map.Entry<String, Object> entry : attrs.entrySet()) { Object value = entry.getValue(); String key = entry.getKey(); putTyped(key, value); } }
public void putAllTyped(Map<String,Object> attrs) { for (Map.Entry<String,Object> entry : attrs.entrySet()) { Object value = entry.getValue(); String key = entry.getKey(); putTyped(key, value); } }
public void putAllTyped(Map<String,Object> attrs) { for (Map.Entry<String,Object> entry : attrs.entrySet()) { Object value = entry.getValue(); String key = entry.getKey(); putTyped(key, value); } }
private Attrs getAttributes(Annotation a, String... ignores) { Attrs attrs = new Attrs(); outer: for (Entry<String, Object> entry : a.entrySet()) { String key = entry.getKey(); for (String ignore : ignores) { if (key.equals(ignore)) continue outer; } attrs.putTyped(key, entry.getValue()); } return attrs; }
private Attrs getAttributes(Annotation a, String... ignores) { Attrs attrs = new Attrs(); outer: for (Entry<String, Object> entry : a.entrySet()) { String key = entry.getKey(); for (String ignore : ignores) { if (key.equals(ignore)) continue outer; } attrs.putTyped(key, entry.getValue()); } return attrs; }
public Attrs toAttrs() { Attrs attrs = new Attrs(); if (attributes != null) { for (Entry<String, Object> e : attributes.entrySet()) { Object value = e.getValue(); if (e.getKey() .equals("version") || value instanceof Version) value = toBndVersions(value); attrs.putTyped(e.getKey(), value); } } if (directives != null) for (Entry<String, String> e : directives.entrySet()) { attrs.put(e.getKey() + ":", e.getValue()); } return attrs; }
public Attrs toAttrs() { Attrs attrs = new Attrs(); if (attributes != null) { for (Entry<String, Object> e : attributes.entrySet()) { Object value = e.getValue(); if (e.getKey() .equals("version") || value instanceof Version) value = toBndVersions(value); attrs.putTyped(e.getKey(), value); } } if (directives != null) for (Entry<String, String> e : directives.entrySet()) { attrs.put(e.getKey() + ":", e.getValue()); } return attrs; }
private void handleAttributeOrDirective(Annotation a) { Object o = annotation.get(lastMethodSeen); if (o != null) { String attributeName = a.get("value"); if (attributeName == null) { attributeName = lastMethodSeen; } if (STD_DIRECTIVE.equals(a.getName() .getFQN())) { attributeName += ":"; } if (!attributesAndDirectives.containsKey(attributeName)) { attributesAndDirectives.putTyped(attributeName, o); } } }
private void directivesAndVersion(Attrs attrs, String... directives) { for (String directive : directives) { String s = attrs.remove(directive); if (s != null) { attrs.put(directive + ":", s); } } String remove = attrs.remove(Constants.VERSION_ATTRIBUTE); if (remove != null) { attrs.putTyped("version", Version.parseVersion(remove)); } }
private void directivesAndVersion(Attrs attrs, String... directives) { for (String directive : directives) { String s = attrs.remove(directive); if (s != null) { attrs.put(directive + ":", s); } } String remove = attrs.remove(Constants.VERSION_ATTRIBUTE); if (remove != null) { attrs.putTyped("version", Version.parseVersion(remove)); } }
private void handleAttributeOrDirective(Annotation a) { Object o = annotation.get(lastMethodSeen); if (o != null) { String attributeName = a.get("value"); if (attributeName == null) { attributeName = lastMethodSeen; } if (STD_DIRECTIVE.equals(a.getName() .getFQN())) { attributeName += ":"; } if (!attributesAndDirectives.containsKey(attributeName)) { attributesAndDirectives.putTyped(attributeName, o); } } }
private Promise<Resource> parseFile(File file) { Promise<Resource> resource = promiseFactory.submit(() -> { if (!file.isFile()) { return null; } ResourceBuilder rb = new ResourceBuilder(); try (JarFile jar = new JarFile(file)) { Domain manifest = Domain.domain(jar.getManifest()); boolean hasIdentity = rb.addManifest(manifest); if (!hasIdentity) { return null; } } catch (Exception f) { return null; } logger.debug("{}: parsing {}", getName(), file); Attrs attrs = new Attrs(); attrs.put(ContentNamespace.CAPABILITY_URL_ATTRIBUTE, file.toURI() .toString()); attrs.putTyped(ContentNamespace.CAPABILITY_SIZE_ATTRIBUTE, file.length()); attrs.put(ContentNamespace.CONTENT_NAMESPACE, SHA256.digest(file) .asHex()); rb.addCapability(CapReqBuilder.createCapReqBuilder(ContentNamespace.CONTENT_NAMESPACE, attrs)); return rb.build(); }); if (logger.isDebugEnabled()) { resource.onFailure(failure -> logger.debug("{}: failed to parse {}", getName(), file, failure)); } return resource; }
private Promise<Resource> parseFile(File file) { Promise<Resource> resource = promiseFactory.submit(() -> { if (!file.isFile()) { return null; } ResourceBuilder rb = new ResourceBuilder(); try (JarFile jar = new JarFile(file)) { Domain manifest = Domain.domain(jar.getManifest()); boolean hasIdentity = rb.addManifest(manifest); if (!hasIdentity) { return null; } } catch (Exception f) { return null; } logger.debug("{}: parsing {}", getName(), file); Attrs attrs = new Attrs(); attrs.put(ContentNamespace.CAPABILITY_URL_ATTRIBUTE, file.toURI() .toString()); attrs.putTyped(ContentNamespace.CAPABILITY_SIZE_ATTRIBUTE, file.length()); attrs.put(ContentNamespace.CONTENT_NAMESPACE, SHA256.digest(file) .asHex()); rb.addCapability(CapReqBuilder.createCapReqBuilder(ContentNamespace.CONTENT_NAMESPACE, attrs)); return rb.build(); }); if (logger.isDebugEnabled()) { resource.onFailure(failure -> logger.debug("{}: failed to parse {}", getName(), file, failure)); } return resource; }
public WorkspaceResourcesRepository(Workspace workspace) throws Exception { for (Project p : workspace.getAllProjects()) { File[] files = p.getBuildFiles(false); if (files != null) { for (File file : files) { Domain manifest = Domain.domain(file); ResourceBuilder rb = new ResourceBuilder(); rb.addManifest(manifest); Attrs attrs = new Attrs(); attrs.put(ContentNamespace.CAPABILITY_URL_ATTRIBUTE, file.toURI() .toString()); attrs.putTyped(ContentNamespace.CAPABILITY_SIZE_ATTRIBUTE, file.length()); attrs.put(ContentNamespace.CONTENT_NAMESPACE, SHA256.digest(file) .asHex()); rb.addCapability(CapReqBuilder.createCapReqBuilder(ContentNamespace.CONTENT_NAMESPACE, attrs)); // Add a capability specific to the workspace so that we can // identify this fact later during resource processing. attrs = new Attrs(); attrs.put(WORKSPACE_NAMESPACE, p.getName()); rb.addCapability(CapReqBuilder.createCapReqBuilder(WORKSPACE_NAMESPACE, attrs)); add(rb.build()); } } } }
public WorkspaceResourcesRepository(Workspace workspace) throws Exception { for (Project p : workspace.getAllProjects()) { File[] files = p.getBuildFiles(false); if (files != null) { for (File file : files) { Domain manifest = Domain.domain(file); ResourceBuilder rb = new ResourceBuilder(); rb.addManifest(manifest); Attrs attrs = new Attrs(); attrs.put(ContentNamespace.CAPABILITY_URL_ATTRIBUTE, file.toURI() .toString()); attrs.putTyped(ContentNamespace.CAPABILITY_SIZE_ATTRIBUTE, file.length()); attrs.put(ContentNamespace.CONTENT_NAMESPACE, SHA256.digest(file) .asHex()); rb.addCapability(CapReqBuilder.createCapReqBuilder(ContentNamespace.CONTENT_NAMESPACE, attrs)); // Add a capability specific to the workspace so that we can // identify this fact later during resource processing. attrs = new Attrs(); attrs.put(WORKSPACE_NAMESPACE, p.getName()); rb.addCapability(CapReqBuilder.createCapReqBuilder(WORKSPACE_NAMESPACE, attrs)); add(rb.build()); } } } }