com.jcabi.manifests.Manifests Java Examples

The following examples show how to use com.jcabi.manifests.Manifests. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SDKEntrypoint.java    From abstract-operator with Apache License 2.0 6 votes vote down vote up
private void printInfo() {
    String gitSha = "unknown";
    String version = "unknown";
    try {
        version = Optional.ofNullable(SDKEntrypoint.class.getPackage().getImplementationVersion()).orElse(version);
        gitSha = Optional.ofNullable(Manifests.read("Implementation-Build")).orElse(gitSha);
    } catch (Exception e) {
        // ignore, not critical
    }

    if(config.isMetrics()) {
        registerMetrics(gitSha, version);
    }

    log.info("\n{}Operator{} has started in version {}{}{}.\n", re(), xx(), gr(),
            version, xx());
    if (!gitSha.isEmpty()) {
        log.info("Git sha: {}{}{}", ye(), gitSha, xx());
    }
    log.info("==================\n");
}
 
Example #2
Source File: ManifestReader.java    From Image-Cipher with Apache License 2.0 6 votes vote down vote up
@Nullable
public static Date getBuildTime() {
  logger.info("Getting build time");
  DateFormat dateFormat = new SimpleDateFormat("yyyy.MM.dd");
  try {
    String time = Manifests.read("Build-Time");
    if (time == null || time.equals("")) {
      logger.warn("Build-Time is empty in MANIFEST");
      return null;
    }

    return dateFormat.parse(time);
  } catch (ParseException e) {
    logger.error(e);
  }

  return null;
}
 
Example #3
Source File: Dynamo.java    From jare with MIT License 6 votes vote down vote up
/**
 * Connect.
 * @return Region
 */
private static Region connect() {
    final String key = Manifests.read("Jare-DynamoKey");
    final Credentials creds = new Credentials.Simple(
        key, Manifests.read("Jare-DynamoSecret")
    );
    final Region region;
    if (key.startsWith("AAAAA")) {
        final int port = Integer.parseInt(
            System.getProperty("dynamo.port")
        );
        region = new Region.Simple(new Credentials.Direct(creds, port));
        Logger.warn(Dynamo.class, "test DynamoDB at port #%d", port);
    } else {
        region = new Region.Prefixed(
            new ReRegion(new Region.Simple(creds)),
            "jare-"
        );
    }
    Logger.info(Dynamo.class, "DynamoDB connected as %s", key);
    return region;
}
 
Example #4
Source File: Lizzie.java    From mylizzie with GNU General Public License v3.0 5 votes vote down vote up
public static String getLizzieVersion() {
    if (Manifests.exists("Lizzie-Version")) {
        return Manifests.read("Lizzie-Version");
    } else {
        return null;
    }
}
 
Example #5
Source File: VersionService.java    From syndesis with Apache License 2.0 5 votes vote down vote up
static void putManifestValueTo(final Map<String, String> detail, final String key, final String... attributes) {
    for (final String attribute : attributes) {
        if (Manifests.exists(attribute)) {
            detail.put(key, Manifests.read(attribute));
            break;
        }
    }
}
 
Example #6
Source File: Entrance.java    From jare with MIT License 5 votes vote down vote up
/**
 * Main entry point.
 * @param args Arguments
 * @throws IOException If fails
 */
public static void main(final String... args) throws IOException {
    Sentry.init(Manifests.read("Jare-SentryDsn"));
    final Base base = new CdBase(new DyBase());
    new Logs(
        base,
        new Region.Simple(
            Manifests.read("Jare-S3Key"),
            Manifests.read("Jare-S3Secret")
        ).bucket("logs.jare.io")
    );
    new FtCli(new TkApp(base), args).start(Exit.NEVER);
}
 
Example #7
Source File: AppInfo.java    From haven-platform with Apache License 2.0 5 votes vote down vote up
private static String getValue(String key) {
    try {
        // we expect error like IllegalArgumentException: Attribute 'dm-cluman-info-version' not found in MANIFEST.MF file(s) among 90 other attribute(s):
        // which appear anytime when we run app without jar file
        return Manifests.read(key);
    } catch (IllegalArgumentException e) {
        return "MANIFEST_WAS_NOT_FOUND";
    }
}
 
Example #8
Source File: TkAppAuth.java    From jare with MIT License 4 votes vote down vote up
/**
 * Authenticated.
 * @param take Takes
 * @return Authenticated takes
 */
private static Take make(final Take take) {
    return new TkAuth(
        new TkFork(
            new FkParams(
                PsByFlag.class.getSimpleName(),
                Pattern.compile(".+"),
                new TkRedirect()
            ),
            new FkFixed(take)
        ),
        new PsChain(
            new PsFake(
                Manifests.read("Jare-DynamoKey").startsWith("AAAA")
            ),
            new PsByFlag(
                new PsByFlag.Pair(
                    PsGithub.class.getSimpleName(),
                    new PsGithub(
                        Manifests.read("Jare-GithubId"),
                        Manifests.read("Jare-GithubSecret")
                    )
                ),
                new PsByFlag.Pair(
                    PsLogout.class.getSimpleName(),
                    new PsLogout()
                )
            ),
            new PsCookie(
                new CcSafe(
                    new CcHex(
                        new CcAes(
                            new CcSalted(new CcCompact()),
                            Manifests.read("Jare-SecurityKey")
                        )
                    )
                )
            )
        )
    );
}
 
Example #9
Source File: RsPage.java    From jare with MIT License 4 votes vote down vote up
/**
 * Make it.
 * @param xsl XSL
 * @param req Request
 * @param src Source
 * @return Response
 * @throws IOException If fails
 */
private static Response make(final String xsl, final Request req,
    final Iterable<XeSource> src) throws IOException {
    final Response raw = new RsXembly(
        new XeStylesheet(xsl),
        new XeAppend(
            "page",
            new XeMillis(false),
            new XeChain(src),
            new XeLinkHome(req),
            new XeLinkSelf(req),
            new XeMillis(true),
            new XeDate(),
            new XeSla(),
            new XeLocalhost(),
            new XeFlash(req),
            new XeWhen(
                new RqAuth(req).identity().equals(Identity.ANONYMOUS),
                new XeChain(
                    new XeGithubLink(req, Manifests.read("Jare-GithubId"))
                )
            ),
            new XeWhen(
                !new RqAuth(req).identity().equals(Identity.ANONYMOUS),
                new XeChain(
                    new XeIdentity(req),
                    new XeLogoutLink(req),
                    new XeLink("domains", "/domains")
                )
            ),
            new XeAppend(
                "version",
                new XeAppend("name", Manifests.read("Jare-Version")),
                new XeAppend("revision", Manifests.read("Jare-Revision")),
                new XeAppend("date", Manifests.read("Jare-Date")),
                new XeAppend("heroku", RsPage.heroku())
            )
        )
    );
    return new RsFork(
        req,
        new FkTypes(
            "application/xml,text/xml",
            new RsPrettyXml(new RsWithType(raw, "text/xml"))
        ),
        new FkTypes(
            "*/*",
            new RsXslt(new RsWithType(raw, "text/html"))
        )
    );
}
 
Example #10
Source File: RyaSinkConnector.java    From rya with Apache License 2.0 4 votes vote down vote up
@Override
public String version() {
    return Manifests.exists("Build-Version") ? Manifests.read("Build-Version") : "UNKNOWN";
}
 
Example #11
Source File: RyaSinkTask.java    From rya with Apache License 2.0 4 votes vote down vote up
@Override
public String version() {
    return Manifests.exists("Build-Version") ? Manifests.read("Build-Version"): "UNKNOWN";
}