Example usage for java.time ZoneOffset UTC

List of usage examples for java.time ZoneOffset UTC

Introduction

In this page you can find the example usage for java.time ZoneOffset UTC.

Prototype

ZoneOffset UTC

To view the source code for java.time ZoneOffset UTC.

Click Source Link

Document

The time-zone offset for UTC, with an ID of 'Z'.

Usage

From source file:serposcope.controllers.google.GoogleSearchController.java

public Result urlRanks(Context context, @PathParam("searchId") Integer searchId, @Param("url") String url,
        @Param("startDate") String startDateStr, @Param("endDate") String endDateStr) {
    Group group = (Group) context.getAttribute("group");

    GoogleSearch search = getSearch(context, searchId);
    if (search == null) {
        context.getFlashScope().error("error.invalidSearch");
        return Results.redirect(
                router.getReverseRoute(GoogleGroupController.class, "view", "groupId", group.getId()));
    }/* w  ww. ja  v a2 s. co m*/

    LocalDate startDate = null;
    if (startDateStr != null) {
        try {
            startDate = LocalDate.parse(startDateStr);
        } catch (Exception ex) {
        }
    }
    LocalDate endDate = null;
    if (endDateStr != null) {
        try {
            endDate = LocalDate.parse(endDateStr);
        } catch (Exception ex) {
        }
    }

    Run firstRun = baseDB.run.findFirst(Module.GOOGLE, STATUSES_DONE, startDate);
    Run lastRun = baseDB.run.findLast(Module.GOOGLE, STATUSES_DONE, endDate);

    if (url == null || firstRun == null || lastRun == null) {
        return Results.badRequest().text();
    }

    StringBuilder builder = new StringBuilder("{");
    googleDB.serp.stream(firstRun.getId(), lastRun.getId(), search.getId(), (GoogleSerp t) -> {
        int position = 0;
        for (int i = 0; i < t.getEntries().size(); i++) {
            if (t.getEntries().get(i).getUrl().equals(url)) {
                position = i + 1;
                break;
            }
        }

        builder.append("\"").append(t.getRunDay().toEpochSecond(ZoneOffset.UTC) * 1000l).append("\":")
                .append(position).append(",");
    });

    if (builder.charAt(builder.length() - 1) == ',') {
        builder.setCharAt(builder.length() - 1, '}');
    } else {
        builder.append('}');
    }

    return Results.ok().text().render(builder.toString());
}

From source file:io.mandrel.metrics.impl.MongoMetricsRepository.java

@Override
public Timeserie serie(String name) {
    Set<Data> results = StreamSupport.stream(timeseries.find(Filters.eq("type", name))
            .sort(Sorts.ascending("timestamp_hour")).limit(3).map(doc -> {
                LocalDateTime hour = LocalDateTime
                        .ofEpochSecond(((Date) doc.get("timestamp_hour")).getTime() / 1000, 0, ZoneOffset.UTC);
                Map<String, Long> values = (Map<String, Long>) doc.get("values");

                List<Data> mapped = values.entrySet().stream()
                        .map(elt -> Data.of(hour.plusMinutes(Long.valueOf(elt.getKey())), elt.getValue()))
                        .collect(Collectors.toList());
                return mapped;
            }).spliterator(), true).flatMap(elts -> elts.stream())
            .collect(TreeSet::new, Set::add, (left, right) -> {
                left.addAll(right);/*w  w  w  . jav  a 2 s.c  o  m*/
            });

    Timeserie timeserie = new Timeserie();
    timeserie.addAll(results);
    return timeserie;
}

From source file:ddf.catalog.registry.federationadmin.service.impl.FederationAdminServiceImpl.java

private void createIdentityNode() throws SourceUnavailableException, IngestException {

    String registryPackageId = UUID.randomUUID().toString().replaceAll("-", "");
    RegistryPackageType registryPackage = RIM_FACTORY.createRegistryPackageType();
    registryPackage.setId(registryPackageId);
    registryPackage.setObjectType(RegistryConstants.REGISTRY_NODE_OBJECT_TYPE);

    ExtrinsicObjectType extrinsicObject = RIM_FACTORY.createExtrinsicObjectType();
    extrinsicObject.setObjectType(RegistryConstants.REGISTRY_NODE_OBJECT_TYPE);

    String extrinsicObjectId = UUID.randomUUID().toString().replaceAll("-", "");
    extrinsicObject.setId(extrinsicObjectId);

    String siteName = SystemInfo.getSiteName();
    if (StringUtils.isNotBlank(siteName)) {
        extrinsicObject.setName(getInternationalStringTypeFromString(siteName));
    }/*from  www. j  a  va 2s .co m*/

    String home = SystemBaseUrl.getBaseUrl();
    if (StringUtils.isNotBlank(home)) {
        extrinsicObject.setHome(home);
    }

    String version = SystemInfo.getVersion();
    if (StringUtils.isNotBlank(version)) {
        VersionInfoType versionInfo = RIM_FACTORY.createVersionInfoType();
        versionInfo.setVersionName(version);

        extrinsicObject.setVersionInfo(versionInfo);
    }

    OffsetDateTime now = OffsetDateTime.now(ZoneId.of(ZoneOffset.UTC.toString()));
    String rightNow = now.toString();
    ValueListType valueList = RIM_FACTORY.createValueListType();
    valueList.getValue().add(rightNow);

    SlotType1 lastUpdated = RIM_FACTORY.createSlotType1();
    lastUpdated.setValueList(RIM_FACTORY.createValueList(valueList));
    lastUpdated.setSlotType(DatatypeConstants.DATETIME.toString());
    lastUpdated.setName(RegistryConstants.XML_LAST_UPDATED_NAME);
    extrinsicObject.getSlot().add(lastUpdated);

    SlotType1 liveDate = RIM_FACTORY.createSlotType1();
    liveDate.setValueList(RIM_FACTORY.createValueList(valueList));
    liveDate.setSlotType(DatatypeConstants.DATETIME.toString());
    liveDate.setName(RegistryConstants.XML_LIVE_DATE_NAME);
    extrinsicObject.getSlot().add(liveDate);

    if (registryPackage.getRegistryObjectList() == null) {
        registryPackage.setRegistryObjectList(RIM_FACTORY.createRegistryObjectListType());
    }

    registryPackage.getRegistryObjectList().getIdentifiable()
            .add(RIM_FACTORY.createIdentifiable(extrinsicObject));

    Metacard identityMetacard = jaxbToMetacard(registryPackage);
    if (identityMetacard != null) {
        Attribute registryNodeAttribute = new AttributeImpl(RegistryObjectMetacardType.REGISTRY_IDENTITY_NODE,
                true);
        identityMetacard.setAttribute(registryNodeAttribute);

        addLocalEntry(identityMetacard);
    }
}

From source file:org.fcrepo.integration.http.api.FedoraVersioningIT.java

@Test
public void testGetTimeMapResponseMultipleMementos() throws Exception {
    createVersionedContainer(id);/* w  w w .ja  va  2 s.  c om*/
    final String memento1 = RFC_1123_DATE_TIME
            .format(LocalDateTime.of(2000, 1, 1, 00, 00, 00).atOffset(ZoneOffset.UTC));
    final String memento2 = RFC_1123_DATE_TIME
            .format(LocalDateTime.of(2015, 8, 13, 18, 30, 0).atOffset(ZoneOffset.UTC));
    final String memento3 = RFC_1123_DATE_TIME
            .format(LocalDateTime.of(1980, 5, 31, 9, 15, 30).atOffset(ZoneOffset.UTC));
    createContainerMementoWithBody(subjectUri, memento1);
    createContainerMementoWithBody(subjectUri, memento2);
    createContainerMementoWithBody(subjectUri, memento3);
    final String[] mementos = { memento1, memento2, memento3 };
    verifyTimemapResponse(subjectUri, id, mementos, memento3, memento2);
}

From source file:org.codice.ddf.registry.federationadmin.service.impl.IdentityNodeInitialization.java

private void createIdentityNode() throws FederationAdminException {
    String registryPackageId = System.getProperty(RegistryConstants.REGISTRY_ID_PROPERTY);
    if (StringUtils.isEmpty(registryPackageId)) {
        registryPackageId = RegistryConstants.GUID_PREFIX + UUID.randomUUID().toString().replaceAll("-", "");
        setSystemRegistryId(registryPackageId);
    }//from ww w.j a v a 2 s.co m
    LOGGER.info("Creating registry identity node: {} {}", SystemInfo.getSiteName(), registryPackageId);
    RegistryPackageType registryPackage = RIM_FACTORY.createRegistryPackageType();
    registryPackage.setId(registryPackageId);
    registryPackage.setObjectType(RegistryConstants.REGISTRY_NODE_OBJECT_TYPE);

    ExtrinsicObjectType extrinsicObject = RIM_FACTORY.createExtrinsicObjectType();
    extrinsicObject.setObjectType(RegistryConstants.REGISTRY_NODE_OBJECT_TYPE);

    String extrinsicObjectId = RegistryConstants.GUID_PREFIX + UUID.randomUUID().toString().replaceAll("-", "");
    extrinsicObject.setId(extrinsicObjectId);

    String siteName = SystemInfo.getSiteName();
    if (StringUtils.isNotBlank(siteName)) {
        extrinsicObject.setName(internationalStringTypeHelper.create(siteName));
    } else {
        extrinsicObject.setName(internationalStringTypeHelper.create(UNKNOWN_SITE_NAME));
    }

    String home = SystemBaseUrl.EXTERNAL.getBaseUrl();
    extrinsicObject.setHome(home);

    String version = SystemInfo.getVersion();
    if (StringUtils.isNotBlank(version)) {
        VersionInfoType versionInfo = RIM_FACTORY.createVersionInfoType();
        versionInfo.setVersionName(version);

        extrinsicObject.setVersionInfo(versionInfo);
    }

    OffsetDateTime now = OffsetDateTime.now(ZoneId.of(ZoneOffset.UTC.toString()));
    String rightNow = now.toString();

    SlotType1 lastUpdated = slotTypeHelper.create(RegistryConstants.XML_LAST_UPDATED_NAME, rightNow, DATE_TIME);
    extrinsicObject.getSlot().add(lastUpdated);

    SlotType1 liveDate = slotTypeHelper.create(RegistryConstants.XML_LIVE_DATE_NAME, rightNow, DATE_TIME);
    extrinsicObject.getSlot().add(liveDate);

    if (registryPackage.getRegistryObjectList() == null) {
        registryPackage.setRegistryObjectList(RIM_FACTORY.createRegistryObjectListType());
    }

    registryPackage.getRegistryObjectList().getIdentifiable()
            .add(RIM_FACTORY.createIdentifiable(extrinsicObject));

    Metacard identityMetacard = getRegistryMetacardFromRegistryPackage(registryPackage);
    if (identityMetacard != null) {
        identityMetacard
                .setAttribute(new AttributeImpl(RegistryObjectMetacardType.REGISTRY_IDENTITY_NODE, true));
        identityMetacard.setAttribute(new AttributeImpl(RegistryObjectMetacardType.REGISTRY_LOCAL_NODE, true));
        federationAdminService.addRegistryEntry(identityMetacard);
    }
}

From source file:net.dv8tion.jda.core.EmbedBuilder.java

/**
 * Sets the Timestamp of the embed./* w  w w .  j a  v  a  2  s.c  om*/
 *
 * <p><b><a href="http://i.imgur.com/YP4NiER.png">Example</a></b>
 *
 * <p><b>Hint:</b> You can get the current time using {@link java.time.Instant#now() Instant.now()} or convert time from a
 * millisecond representation by using {@link java.time.Instant#ofEpochMilli(long) Instant.ofEpochMilli(long)};
 *
 * @param  temporal
 *         the temporal accessor of the timestamp
 *
 * @return the builder after the timestamp has been set
 */
public EmbedBuilder setTimestamp(TemporalAccessor temporal) {
    if (temporal == null) {
        this.timestamp = null;
    } else if (temporal instanceof OffsetDateTime) {
        this.timestamp = (OffsetDateTime) temporal;
    } else {
        ZoneOffset offset;
        try {
            offset = ZoneOffset.from(temporal);
        } catch (DateTimeException ignore) {
            offset = ZoneOffset.UTC;
        }
        try {
            LocalDateTime ldt = LocalDateTime.from(temporal);
            this.timestamp = OffsetDateTime.of(ldt, offset);
        } catch (DateTimeException ignore) {
            try {
                Instant instant = Instant.from(temporal);
                this.timestamp = OffsetDateTime.ofInstant(instant, offset);
            } catch (DateTimeException ex) {
                throw new DateTimeException("Unable to obtain OffsetDateTime from TemporalAccessor: " + temporal
                        + " of type " + temporal.getClass().getName(), ex);
            }
        }
    }
    return this;
}

From source file:com.muk.services.security.DefaultUaaLoginService.java

private String httpCookieToString(HttpCookie cookie) {
    final OffsetDateTime now = OffsetDateTime.now(ZoneOffset.UTC).plusSeconds(cookie.getMaxAge());
    final String cookieExpires = DateTimeFormatter.RFC_1123_DATE_TIME.format(now);
    final StringBuilder cookieBuilder = new StringBuilder();
    cookieBuilder.append(cookie.getName()).append("=").append(cookie.getValue()).append(";path=")
            .append(cookie.getPath()).append(";max-age=").append(cookie.getMaxAge()).append(";expires=")
            .append(cookieExpires);//from w w  w . j a  va2s  .c  o m

    if (cookie.isHttpOnly()) {
        cookieBuilder.append(";HttpOnly");
    }

    return cookieBuilder.toString();
}

From source file:io.github.mikesaelim.arxivoaiharvester.xml.XMLParser.java

/**
 * Parse the response date.  The result will be in UTC.
 *//*from  ww w.  j ava 2s  .  c  o  m*/
@VisibleForTesting
ZonedDateTime parseResponseDate(XMLGregorianCalendar xmlGregorianCalendar) {
    return xmlGregorianCalendar.toGregorianCalendar().toZonedDateTime().withZoneSameInstant(ZoneOffset.UTC);
}

From source file:com.inqool.dcap.office.indexer.indexer.SolrBulkIndexer.java

private SolrInputDocument recursivelyIndex(final ModelTreeNode data) throws IOException {
    ZdoModel model;//from   w w  w.jav  a2 s  . c o m

    model = data.getModel();

    if (model == null) {
        return null;
    }

    //        if (!model.isIndexable()) {
    //            logger.debug("Resource: {} retrieved without indexable type.", uri);
    //            return null;
    //        }
    logger.debug("Resource: {} retrieved with indexable type.", store.removeTransactionFromUrl(model.getUrl()));

    if (!allowableTypes.contains(model.get(ZdoTerms.zdoType))) {
        return null;
    }

    if (!ZdoGroup.ZDO.name().equals(model.get(ZdoTerms.group))) {
        logger.info("Not indexing this document as it is not published.");
        return null;
    }

    final SolrInputDocument inputDoc = modelToSolrInputDoc(model);

    //        inputDoc.addField("datePublished", OffsetDateTime.now().withOffsetSameInstant(ZoneOffset.UTC).format(DateTimeFormatter.ISO_DATE_TIME));
    String datePublished = model.get(ZdoTerms.datePublished);
    if (datePublished != null) { //If reindexing, we just read data about when it was originally published from Fedora
        inputDoc.addField("datePublished", datePublished);
    } else {
        datePublished = LocalDateTime.now().atZone(ZoneOffset.systemDefault())
                .withZoneSameInstant(ZoneOffset.UTC).format(DateTimeFormatter.ISO_OFFSET_DATE_TIME);
        inputDoc.addField("datePublished", datePublished); //solr needs UTC time
        ZdoModel patchmodel = new ZdoModel();
        patchmodel.setUrl(model.getUrl());
        patchmodel.add(ZdoTerms.datePublished, datePublished);
        store.patchMetadata(patchmodel);
    }
    //Get all children's uris, parse them recursively, and add them to result
    //If we are an almost-leaf node, also search for children bound on the original object
    String originalObjectUrl = model.get(ZdoTerms.kdrObject);
    if (!ZdoType.isBranchEndCategory(model.get(ZdoTerms.zdoType))) {
        for (ModelTreeNode child : data.getChildren()) {
            SolrInputDocument childDoc = recursivelyIndex(child);
            if (childDoc != null) {
                inputDoc.addChildDocument(childDoc);
            }
        }
    } else { //we are end branch category
        //Treat born digital documents differently as they don't have pages but whole PDF
        if (ZdoType.bornDigital.name().equals(model.get(ZdoTerms.zdoType))) {
            //Retrieve the usercopy - PDF
            String queryString = "SELECT ?userCopy ?thumb WHERE {\n"
                    + "?userCopy <http://purl.org/dc/terms/isPartOf> <" + originalObjectUrl + ">.\n"
                    + "?userCopy <" + ZdoTerms.zdoType.getURI() + "> \"" + ZdoType.binary.name()
                    + "\"^^<http://www.w3.org/2001/XMLSchema#string>.\n" + "?userCopy <"
                    + ZdoTerms.fileType.getURI() + "> \"" + ZdoFileType.userCopy.name()
                    + "\"^^<http://www.w3.org/2001/XMLSchema#string>.\n" + "}";
            QueryExecution queryExecution = QueryExecutionFactory.sparqlService(SPARQL_ENDPOINT, queryString);
            ResultSet resultSet = queryExecution.execSelect();
            if (resultSet.hasNext()) {
                QuerySolution querySolution = resultSet.next();
                String userCopyUrl = querySolution.getResource("userCopy").getURI();
                inputDoc.addField("pdfId", store.getOnlyIdFromUrl(userCopyUrl));
            } else {
                throw new RuntimeException("Damn this pdf has no pdf or thumbnail.");
            }
        } else { //Other than born-digital branch end node
            //These are to sort pages based on their index
            SortedMap<Integer, String> imageMap = new TreeMap<>();
            SortedMap<Integer, String> thumbMap = new TreeMap<>();
            SortedMap<Integer, String> txtMap = new TreeMap<>();
            SortedMap<Integer, String> altoMap = new TreeMap<>();

            String videoUrl = null;

            //Retrieve image, thumbnail and ocr text info
            String queryString = "SELECT ?pageIndex ?userCopy ?ucMime ?thumb ?txt ?alto WHERE {\n" +
            //first find pages - children of the node
                    "?page <" + ZdoTerms.zdoType.getURI() + "> \"" + ZdoType.page.name()
                    + "\"^^<http://www.w3.org/2001/XMLSchema#string>.\n"
                    + "?page <http://purl.org/dc/terms/isPartOf> <" + originalObjectUrl + ">.\n" + "?page <"
                    + ZdoTerms.pageIndex.getURI() + "> ?pageIndex.\n" + "OPTIONAL {\n" +
                    //then children of those pages that are binary usercopy images
                    "?userCopy <http://purl.org/dc/terms/isPartOf> ?page.\n" + "?userCopy <"
                    + ZdoTerms.zdoType.getURI() + "> \"" + ZdoType.binary.name()
                    + "\"^^<http://www.w3.org/2001/XMLSchema#string>.\n" + "?userCopy <"
                    + ZdoTerms.fileType.getURI() + "> \"" + ZdoFileType.userCopy.name()
                    + "\"^^<http://www.w3.org/2001/XMLSchema#string>.\n" + "?userCopy <"
                    + ZdoTerms.mimeType.getURI() + "> ?ucMime.\n" + "}\nOPTIONAL {\n" +
                    //and their thumbnails
                    "?thumb <http://purl.org/dc/terms/isPartOf> ?page.\n" + "?thumb <"
                    + ZdoTerms.zdoType.getURI() + "> \"" + ZdoType.binary.name()
                    + "\"^^<http://www.w3.org/2001/XMLSchema#string>.\n" + "?thumb <"
                    + ZdoTerms.fileType.getURI() + "> \"" + ZdoFileType.thumb.name()
                    + "\"^^<http://www.w3.org/2001/XMLSchema#string>.\n" + "}\nOPTIONAL {\n" +
                    //and also children of those pages that are binary text
                    "?txt <http://purl.org/dc/terms/isPartOf> ?page.\n" + "?txt <" + ZdoTerms.zdoType.getURI()
                    + "> \"" + ZdoType.binary.name() + "\"^^<http://www.w3.org/2001/XMLSchema#string>.\n"
                    + "?txt <" + ZdoTerms.fileType.getURI() + "> \"" + ZdoFileType.txt.name()
                    + "\"^^<http://www.w3.org/2001/XMLSchema#string>.\n" + "}\nOPTIONAL {\n" +
                    //and also alto children with ocr text
                    "?alto <http://purl.org/dc/terms/isPartOf> ?page.\n" + "?alto <" + ZdoTerms.zdoType.getURI()
                    + "> \"" + ZdoType.binary.name() + "\"^^<http://www.w3.org/2001/XMLSchema#string>.\n"
                    + "?alto <" + ZdoTerms.fileType.getURI() + "> \"" + ZdoFileType.alto.name()
                    + "\"^^<http://www.w3.org/2001/XMLSchema#string>.\n" + "}\n}";
            QueryExecution queryExecution = QueryExecutionFactory.sparqlService(SPARQL_ENDPOINT, queryString);
            ResultSet resultSet = queryExecution.execSelect();
            while (resultSet.hasNext()) {
                QuerySolution querySolution = resultSet.next();
                Integer pageIndex = Integer.valueOf(querySolution.getLiteral("pageIndex").getString());
                Resource userCopyResource = querySolution.getResource("userCopy");
                if (userCopyResource != null) {
                    String userCopyUrl = userCopyResource.getURI();
                    if (userCopyUrl != null) {
                        if ("video/mp4".equals(querySolution.getLiteral("ucMime").getString())) {
                            if (videoUrl != null) {
                                logger.error(
                                        "More than one video per document encountered. There can only be one.");
                            }
                            videoUrl = userCopyUrl;
                        } else {
                            imageMap.put(pageIndex, userCopyUrl);
                        }
                    }
                }
                Resource thumbnailResource = querySolution.getResource("thumb");
                if (thumbnailResource != null) {
                    String thumbUrl = thumbnailResource.getURI();
                    if (thumbUrl != null) {
                        thumbMap.put(pageIndex, thumbUrl);
                    }
                }
                Resource txtResource = querySolution.getResource("txt");
                if (txtResource != null) {
                    String txtUrl = txtResource.getURI();
                    if (txtUrl != null) {
                        txtMap.put(pageIndex, txtUrl);
                    }
                }
                Resource altoResource = querySolution.getResource("alto");
                if (altoResource != null) {
                    String altoUrl = altoResource.getURI();
                    if (altoUrl != null) {
                        altoMap.put(pageIndex, altoUrl);
                    }
                }
            }

            if (videoUrl != null) {
                inputDoc.addField("videoId", store.getOnlyIdFromUrl(videoUrl));
            }

            List<String> imageIds = new ArrayList<>();
            if (!imageMap.isEmpty()) {
                for (String userCopyUrl : imageMap.values()) {
                    imageIds.add(store.getOnlyIdFromUrl(userCopyUrl));
                }
                inputDoc.addField("imageIds", imageIds);
            }

            if (!thumbMap.isEmpty()) {
                List<String> thumbIds = new ArrayList<>();
                for (String thumbUrl : thumbMap.values()) {
                    thumbIds.add(store.getOnlyIdFromUrl(thumbUrl));
                }
                inputDoc.addField("thumbIds", thumbIds);
            }

            List<String> txtIds = new ArrayList<>();
            if (!txtMap.isEmpty()) {
                String fulltext = "";
                for (String txtUrl : txtMap.values()) {
                    txtIds.add(store.getOnlyIdFromUrl(txtUrl));
                    InputStream in = new URL(txtUrl).openStream();
                    StringWriter writer = new StringWriter();
                    IOUtils.copy(in, writer, "utf-8");
                    String text = writer.toString();
                    fulltext += text + " ";
                }
                inputDoc.addField("fullText", fulltext.trim());
            }

            List<String> altoIds = new ArrayList<>();
            if (!altoMap.isEmpty()) {
                for (String altoUrl : altoMap.values()) {
                    altoIds.add(store.getOnlyIdFromUrl(altoUrl));
                }
            }

            ZdoModel kdrObject = store.get(model.get(ZdoTerms.kdrObject));
            String origPdfUrl = kdrObject.get(ZdoTerms.pdfUrl);
            String origEpubUrl = kdrObject.get(ZdoTerms.epubUrl);
            ZdoModel patchModel = new ZdoModel(); //Used to add new pdf and epub data to Fedora
            patchModel.setUrl(model.get(ZdoTerms.kdrObject));
            if ("true".equals(model.get(ZdoTerms.allowPdfExport)) && !imageIds.isEmpty()) {
                if (origPdfUrl == null) {
                    String pdfId = UUID.randomUUID().toString();
                    patchModel.add(ZdoTerms.pdfUrl, store.createUrl(pdfId));
                    String orgId = model.get(ZdoTerms.organization);

                    String watermarkId = null;
                    if ("true".equals(model.get(ZdoTerms.watermark))) {
                        watermarkId = organizationSettingsAccess.fetchOrgWatermark(orgId);
                        if (watermarkId == null) {
                            watermarkId = portalSettingsAccess.fetchPortalSettings().getWatermarkId();
                        }
                    }

                    PdfCreatorDto pdfCreatorDto = new PdfCreatorDto(pdfId, imageIds, altoIds, watermarkId,
                            model.get(ZdoTerms.watermarkPosition));
                    Response response = ClientBuilder.newClient().target(IP_ENDPOINT + "pdf").request()
                            .post(Entity.json(pdfCreatorDto));
                    if (response.getStatusInfo().getFamily() != Response.Status.Family.SUCCESSFUL) {
                        throw new RuntimeException("Failed to call pdf creator in image processing war.");
                    }
                    inputDoc.addField("pdfId", pdfId);
                } else { //When reindexing, pdf already exists
                    inputDoc.addField("pdfId", store.getOnlyIdFromUrl(origPdfUrl));
                }
            }
            if ("true".equals(model.get(ZdoTerms.allowEpubExport)) && !txtIds.isEmpty()) {
                if (origEpubUrl == null) {
                    String epubId = UUID.randomUUID().toString();
                    patchModel.add(ZdoTerms.epubUrl, store.createUrl(epubId));
                    epubCreator.createBook(epubId, model.get(DCTerms.title), model.get(DCTerms.creator),
                            txtIds);
                    inputDoc.addField("epubId", epubId);
                } else {
                    inputDoc.addField("epubId", store.getOnlyIdFromUrl(origEpubUrl));
                }
            }
            store.patchMetadata(patchModel); //warning, this does not go to triplestore
        }
    }

    logger.debug("Executing update of: {}...", store.removeTransactionFromUrl(model.getUrl()));

    return inputDoc;
}

From source file:com.thinkbiganalytics.nifi.v2.ingest.GetTableData.java

private static LocalDateTime toDateTime(Date date) {
    return date == null ? LocalDateTime.MIN
            : LocalDateTime.ofInstant(date.toInstant(), ZoneOffset.UTC.normalized());
}