method2testcases stringlengths 118 6.63k |
|---|
### Question:
Metadata implements Serializable { static String buildHierarchicalValue(String field, String value, Locale locale, String applicationUrl) { String[] valueSplit = value.split("[.]"); StringBuilder sbFullValue = new StringBuilder(); StringBuilder sbHierarchy = new StringBuilder(); for (String s : valueSplit... |
### Question:
Comment implements Comparable<Comment> { public boolean mayEdit(User user) { return owner.getId() != null && user != null && owner.getId() == user.getId(); } Comment(); Comment(String pi, int page, User owner, String text, Comment parent); @Override int compareTo(Comment o); static boolean sendEmailNotif... |
### Question:
Campaign implements CMSMediaHolder { public long getDaysLeft() { if (dateEnd == null) { return -1; } LocalDateTime now = LocalDate.now().atStartOfDay(); LocalDateTime end = DateTools.convertDateToLocalDateTimeViaInstant(dateEnd); return Math.max(0L, Duration.between(now, end).toDays()); } Campaign(); Cam... |
### Question:
TEITools { public static String getTeiFulltext(String tei) throws JDOMException, IOException { if (tei == null) { return null; } Document doc = XmlTools.getDocumentFromString(tei, StringTools.DEFAULT_ENCODING); if (doc == null) { return null; } if (doc.getRootElement() != null) { Element eleText = doc.get... |
### Question:
Campaign implements CMSMediaHolder { public long getDaysBeforeStart() { if (dateStart == null) { return -1; } LocalDateTime now = LocalDate.now().atStartOfDay(); LocalDateTime start = DateTools.convertDateToLocalDateTimeViaInstant(dateStart); return Math.max(0L, Duration.between(now, start).toDays()); } C... |
### Question:
Campaign implements CMSMediaHolder { public boolean isHasEnded() { if (dateEnd == null) { return false; } LocalDateTime now = LocalDateTime.now(); LocalDateTime end = DateTools.convertDateToLocalDateTimeViaInstant(dateEnd); return now.isAfter(end); } Campaign(); Campaign(Locale selectedLocale); @Override... |
### Question:
Campaign implements CMSMediaHolder { public boolean isHasStarted() { if (dateStart == null) { return true; } LocalDateTime now = LocalDateTime.now(); LocalDateTime start = DateTools.convertDateToLocalDateTimeViaInstant(dateStart); return now.isEqual(start) || now.isAfter(start); } Campaign(); Campaign(Lo... |
### Question:
ALTOTools { protected static Rectangle rotate(Rectangle rect, int rotation, Dimension imageSize) { double x1 = rect.getMinX(); double y1 = rect.getMinY(); double x2 = rect.getMaxX(); double y2 = rect.getMaxY(); double w = imageSize.getWidth(); double h = imageSize.getHeight(); double x1r = x1; double y1r ... |
### Question:
ALTOTools { public static String getFulltext(Path path, String encoding) throws IOException { String altoString = FileTools.getStringFromFile(path.toFile(), encoding); return getFullText(altoString, false, null); } static String getFulltext(Path path, String encoding); static String getFullText(String al... |
### Question:
CMSSidebarElement { protected static String cleanupHtmlTag(String tag) { Matcher m2 = patternHtmlAttribute.matcher(tag); while (m2.find()) { String attribute = m2.group(); tag = tag.replace(attribute, ""); } tag = tag.replace("</", "<").replace("/>", ">").replace(" ", ""); return tag; } CMSSidebarElement(... |
### Question:
FileTools { public static String getStringFromFile(File file, String encoding) throws FileNotFoundException, IOException { return getStringFromFile(file, encoding, null); } static String getStringFromFilePath(String filePath); static String getStringFromFile(File file, String encoding); static String get... |
### Question:
FileTools { public static String getStringFromFilePath(String filePath) throws FileNotFoundException, IOException { return getStringFromFile(new File(filePath), null); } static String getStringFromFilePath(String filePath); static String getStringFromFile(File file, String encoding); static String getStr... |
### Question:
FileTools { public static void compressGzipFile(File file, File gzipFile) throws FileNotFoundException, IOException { try (FileInputStream fis = new FileInputStream(file); FileOutputStream fos = new FileOutputStream(gzipFile); GZIPOutputStream gzipOS = new GZIPOutputStream(fos)) { byte[] buffer = new byte... |
### Question:
FileTools { public static void decompressGzipFile(File gzipFile, File newFile) throws FileNotFoundException, IOException { try (FileInputStream fis = new FileInputStream(gzipFile); GZIPInputStream gis = new GZIPInputStream(fis); FileOutputStream fos = new FileOutputStream(newFile)) { byte[] buffer = new b... |
### Question:
FileTools { public static File getFileFromString(String string, String filePath, String encoding, boolean append) throws IOException { if (string == null) { throw new IllegalArgumentException("string may not be null"); } if (encoding == null) { encoding = StringTools.DEFAULT_ENCODING; } File file = new Fi... |
### Question:
FileTools { public static String getCharset(InputStream input) throws IOException { CharsetDetector cd = new CharsetDetector(); try (BufferedInputStream bis = new BufferedInputStream(input)) { cd.setText(bis); CharsetMatch cm = cd.detect(); if (cm != null) { return cm.getName(); } } return null; } static... |
### Question:
FileTools { public static String getBottomFolderFromPathString(String pathString) { if (StringUtils.isBlank(pathString)) { return ""; } Path path = Paths.get(pathString); return path.getParent() != null ? path.getParent().getFileName().toString() : ""; } static String getStringFromFilePath(String filePat... |
### Question:
FileTools { public static String getFilenameFromPathString(String pathString) { if (StringUtils.isBlank(pathString)) { return ""; } Path path = getPathFromUrlString(pathString); return path.getFileName().toString(); } static String getStringFromFilePath(String filePath); static String getStringFromFile(F... |
### Question:
LanguageHelper { public Language getLanguage(String isoCode) { SubnodeConfiguration languageConfig = null; try { if (isoCode.length() == 3) { List<HierarchicalConfiguration> nodes = config.configurationsAt("language[iso_639-2=\"" + isoCode + "\"]"); if (nodes.isEmpty()) { nodes = config.configurationsAt("... |
### Question:
DataFileTools { public static String getSourceFilePath(String fileName, String format) throws PresentationException, IndexUnreachableException { String pi = FilenameUtils.getBaseName(fileName); String dataRepository = DataManager.getInstance().getSearchIndex().findDataRepositoryName(pi); return getSourceF... |
### Question:
DataFileTools { public static Path getDataFolder(String pi, String dataFolderName) throws PresentationException, IndexUnreachableException { if (pi == null) { throw new IllegalArgumentException("pi may not be null"); } String dataRepository = DataManager.getInstance().getSearchIndex().findDataRepositoryNa... |
### Question:
CMSSidebarElement { public boolean isValid() { if (hasHtml()) { Matcher m = patternHtmlTag.matcher(html); Set<String> disallowedTags = CMSSidebarManager.getInstance().getDisallowedHtmlTags(); while (m.find()) { String tag = m.group(); if (tag.startsWith("<!--")) { continue; } tag = cleanupHtmlTag(tag); lo... |
### Question:
DataFileTools { static String getDataRepositoryPath(String dataRepositoryPath) { if (StringUtils.isBlank(dataRepositoryPath)) { return DataManager.getInstance().getConfiguration().getViewerHome(); } if (Paths.get(FileTools.adaptPathForWindows(dataRepositoryPath)).isAbsolute()) { return dataRepositoryPath ... |
### Question:
DataFileTools { static String sanitizeFileName(String fileName) { if (StringUtils.isBlank(fileName)) { return fileName; } return Paths.get(fileName).getFileName().toString(); } static String getDataRepositoryPathForRecord(String pi); static Path getMediaFolder(String pi); static Map<String, Path> getData... |
### Question:
CMSStaticPage { public String getPageName() { return pageName; } CMSStaticPage(); CMSStaticPage(String name); @SuppressWarnings("deprecation") CMSStaticPage(CMSPage cmsPage); Optional<CMSPage> getCmsPageOptional(); CMSPage getCmsPage(); void setCmsPage(CMSPage cmsPage); Long getId(); String getPageName(... |
### Question:
DateTools { public static Date createDate(int year, int month, int dayofMonth, int hour, int minute) { return createDate(year, month, dayofMonth, hour, minute, false); } static List<Date> parseMultipleDatesFromString(String dateString); static LocalDateTime parseDateTimeFromString(String dateString, bool... |
### Question:
NetTools { protected static String parseMultipleIpAddresses(String address) { if (address == null) { throw new IllegalArgumentException("address may not be null"); } if (address.contains(",")) { String[] addressSplit = address.split(","); if (addressSplit.length > 0) { address = addressSplit[addressSplit.... |
### Question:
NetTools { public static String scrambleEmailAddress(String email) { if (StringUtils.isEmpty(email)) { return email; } StringBuilder sb = new StringBuilder(); for (int i = 0; i < email.length(); ++i) { if (i > 2 && i < email.length() - 3) { sb.append('*'); } else { sb.append(email.charAt(i)); } } return s... |
### Question:
NetTools { public static String scrambleIpAddress(String address) { if (StringUtils.isEmpty(address)) { return address; } String[] addressSplit = address.split("[.]"); if (addressSplit.length == 4) { return addressSplit[0] + "." + addressSplit[1] + ".X.X"; } return address; } static String[] callUrlGET(S... |
### Question:
IndexerTools { public static synchronized boolean deleteRecord(String pi, boolean createTraceDocument, Path hotfolderPath) throws IOException { if (pi == null) { throw new IllegalArgumentException("pi may not be null"); } if (hotfolderPath == null) { throw new IllegalArgumentException("hotfolderPath may n... |
### Question:
JsonTools { public static JSONObject getRecordJsonObject(SolrDocument doc, String rootUrl) throws ViewerConfigurationException { return getRecordJsonObject(doc, rootUrl, null); } static JSONArray getRecordJsonArray(SolrDocumentList result, Map<String, SolrDocumentList> expanded, HttpServletRequest reques... |
### Question:
JsonTools { public static String formatVersionString(String json) { final String notAvailableKey = "admin__dashboard_versions_not_available"; if (StringUtils.isEmpty(json)) { return notAvailableKey; } try { JSONObject jsonObj = new JSONObject(json); return jsonObj.getString("application") + " " + jsonObj.... |
### Question:
CMSStaticPage { public boolean isLanguageComplete(Locale locale) { if (getCmsPageOptional().isPresent()) { return cmsPage.get().isLanguageComplete(locale); } return false; } CMSStaticPage(); CMSStaticPage(String name); @SuppressWarnings("deprecation") CMSStaticPage(CMSPage cmsPage); Optional<CMSPage> ge... |
### Question:
JsonTools { public static String shortFormatVersionString(String json) { final String notAvailableKey = "admin__dashboard_versions_not_available"; if (StringUtils.isEmpty(json)) { return notAvailableKey; } try { JSONObject jsonObj = new JSONObject(json); return jsonObj.getString("version") + " (" + jsonOb... |
### Question:
StringTools { public static String escapeHtmlChars(String str) { return replaceCharacters(str, new String[] { "&", "\"", "<", ">" }, new String[] { "&", """, "<", ">" }); } static String encodeUrl(String string); static String decodeUrl(String string); static Optional<String> findFirstMatc... |
### Question:
StringTools { static String replaceCharacters(String str, String[] replace, String[] replaceWith) { if (str == null) { return null; } if (replace == null) { throw new IllegalArgumentException("replace may not be null"); } if (replaceWith == null) { throw new IllegalArgumentException("replaceWith may not b... |
### Question:
StringTools { public static String removeLineBreaks(String s, String replaceWith) { if (s == null) { throw new IllegalArgumentException("s may not be null"); } if (replaceWith == null) { replaceWith = ""; } return s.replace("\r\n", replaceWith) .replace("\n", replaceWith) .replaceAll("\r", replaceWith) .r... |
### Question:
StringTools { public static String stripJS(String s) { if (StringUtils.isBlank(s)) { return s; } return s.replaceAll("(?i)<script[\\s\\S]*<\\/script>", ""); } static String encodeUrl(String string); static String decodeUrl(String string); static Optional<String> findFirstMatch(String text, String regex, ... |
### Question:
StringTools { public static String escapeQuotes(String s) { if (s != null) { s = s.replaceAll("(?<!\\\\)'", "\\\\'"); s = s.replaceAll("(?<!\\\\)\"", "\\\\\""); } return s; } static String encodeUrl(String string); static String decodeUrl(String string); static Optional<String> findFirstMatch(String text... |
### Question:
StringTools { public static boolean isImageUrl(String url) { if (StringUtils.isEmpty(url)) { return false; } String extension = FilenameUtils.getExtension(url); if (StringUtils.isEmpty(extension)) { return false; } switch (extension.toLowerCase()) { case "tif": case "tiff": case "jpg": case "jpeg": case "... |
### Question:
CMSStaticPage { public boolean isHasCmsPage() { return getCmsPageId().isPresent(); } CMSStaticPage(); CMSStaticPage(String name); @SuppressWarnings("deprecation") CMSStaticPage(CMSPage cmsPage); Optional<CMSPage> getCmsPageOptional(); CMSPage getCmsPage(); void setCmsPage(CMSPage cmsPage); Long getId();... |
### Question:
StringTools { public static String renameIncompatibleCSSClasses(String html) { if (html == null) { return null; } Pattern p = Pattern.compile("\\.([0-9]+[A-Za-z]+) \\{.*\\}"); Matcher m = p.matcher(html); Map<String, String> replacements = new HashMap<>(); while (m.find()) { if (m.groupCount() > 0) { Stri... |
### Question:
StringTools { public static List<String> getHierarchyForCollection(String collection, String split) { if (StringUtils.isEmpty(collection) || StringUtils.isEmpty(split)) { return Collections.emptyList(); } String useSplit = '[' + split + ']'; String[] hierarchy = collection.contains(split) ? collection.spl... |
### Question:
StringTools { public static String normalizeWebAnnotationCoordinates(String coords) { if (coords == null) { return null; } if (!coords.startsWith("xywh=")) { return coords; } String ret = coords.substring(5); String[] rectSplit = ret.split(","); if (rectSplit.length == 4) { ret = rectSplit[0].trim() + ", ... |
### Question:
StringTools { public static String generateMD5(String myString) { String answer = ""; try { byte[] defaultBytes = myString.getBytes("UTF-8"); MessageDigest algorithm = MessageDigest.getInstance("MD5"); algorithm.reset(); algorithm.update(defaultBytes); byte messageDigest[] = algorithm.digest(); StringBuff... |
### Question:
BCrypt { public boolean checkpw(String plaintext, String hashed) { return (hashed.compareTo(hashpw(plaintext, hashed)) == 0); } static String hashpw(String password, String salt); static String gensalt(int log_rounds, SecureRandom random); static String gensalt(int log_rounds); static String gensalt(); b... |
### Question:
PasswordValidator implements Validator<String> { public static boolean validatePassword(String password) { if (StringUtils.isBlank(password)) { return false; } if (password.length() < 8) { return false; } return true; } @Override void validate(FacesContext context, UIComponent component, String value); s... |
### Question:
TileGridBuilder { protected static int countTags(ImageGalleryTile item, Collection<String> tags) { return CollectionUtils.intersection(item.getCategories().stream().map(c -> c.getName()).collect(Collectors.toList()), tags).size(); } TileGridBuilder(HttpServletRequest servletRequest); TileGridBuilder size(... |
### Question:
HtmlScriptValidator implements Validator<String> { @Override public void validate(FacesContext context, UIComponent component, String input) throws ValidatorException { if (!validate(input)) { FacesMessage msg = new FacesMessage(ViewerResourceBundle.getTranslation("validate_error_scriptTag", null), ""); m... |
### Question:
PIValidator implements Validator<String> { public static boolean validatePi(String pi) { if (StringUtils.isBlank(pi)) { return false; } return !StringUtils.containsAny(pi, ILLEGAL_CHARS); } @Override void validate(FacesContext context, UIComponent component, String value); static boolean validatePi(Strin... |
### Question:
HtmlTagValidator implements Validator<String> { @Override public void validate(FacesContext context, UIComponent component, String input) throws ValidatorException { if (!validate(input)) { FacesMessage msg = new FacesMessage(ViewerResourceBundle.getTranslation("validate_error_invalidTag", null), ""); msg... |
### Question:
EmailValidator implements Validator<String> { public static boolean validateEmailAddress(String email) { if (email == null) { return false; } Matcher m = PATTERN.matcher(email.toLowerCase()); return m.find(); } @Override void validate(FacesContext context, UIComponent component, String value); static boo... |
### Question:
TileGridBuilder { public TileGrid build(List<ImageGalleryTile> items) { if (!tags.isEmpty()) { items = filter(items, tags); } items = items.stream() .filter(item -> tags.isEmpty() || countTags(item, tags) > 0) .sorted(new SemiRandomOrderComparator<ImageGalleryTile>(tile -> tile.getDisplayOrder())) .collec... |
### Question:
AbstractApiUrlManager { static String replaceApiPathParams(String urlString, Object[] pathParams) { return ApiPathParams.replacePathParams(urlString, pathParams); } abstract String getApiUrl(); abstract String getApplicationUrl(); static String subPath(String url, String within); String parseParameter(St... |
### Question:
PdfRequestFilter implements ContainerRequestFilter { static int getNumAllowedPages(int percentage, int numTotalRecordPages) { if (percentage < 0) { throw new IllegalArgumentException("percentage may not be less than 0"); } if (numTotalRecordPages < 0) { throw new IllegalArgumentException("numTotalRecordPa... |
### Question:
RecordFileResource { @GET @javax.ws.rs.Path(RECORDS_FILES_ALTO) @Produces({ MediaType.TEXT_XML }) @Operation(tags = { "records" }, summary = "Get Alto fulltext for a single page") public String getAlto( @Parameter(description = "Filename of the alto document") @PathParam("filename") String filename) throw... |
### Question:
RecordFileResource { @GET @javax.ws.rs.Path(RECORDS_FILES_PLAINTEXT) @Produces({ MediaType.TEXT_PLAIN }) @Operation(tags = { "records" }, summary = "Get plaintext for a single page") public String getPlaintext( @Parameter(description = "Filename containing the text") @PathParam("filename") String filename... |
### Question:
RecordFileResource { @GET @javax.ws.rs.Path(RECORDS_FILES_TEI) @Produces({ MediaType.TEXT_XML }) @Operation(tags = { "records" }, summary = "Get fulltext for a single page in TEI format") public String getTEI( @Parameter(description = "Filename containing the text") @PathParam("filename") String filename)... |
### Question:
RecordFileResource { @GET @javax.ws.rs.Path(RECORDS_FILES_PDF) @Produces({ "application/pdf" }) @Operation(tags = { "records" }, summary = "Non-canonical URL to PDF file") public Response getPDF( @Parameter(description = "Filename containing the text") @PathParam("filename") String filename) throws Conten... |
### Question:
RecordFileResource { @GET @javax.ws.rs.Path(RECORDS_FILES_SOURCE) @Operation(tags = { "records" }, summary = "Get source files of record") @Produces(MediaType.APPLICATION_OCTET_STREAM) public StreamingOutput getSourceFile( @Parameter(description = "Source file name") @PathParam("filename") String filename... |
### Question:
SemiRandomOrderComparator implements Comparator<T> { @Override public int compare(T a, T b) { Integer nA = comparisonOperator.apply(a); Integer nB = comparisonOperator.apply(b); if (nA.equals(0)) { nA = Integer.MAX_VALUE; } if (nB.equals(0)) { nB = Integer.MAX_VALUE; } if (nA.equals(nB)) { return Integer.... |
### Question:
RecordSectionResource { @GET @javax.ws.rs.Path(RECORDS_SECTIONS_RIS_FILE) @Produces({ MediaType.TEXT_PLAIN }) @Operation(tags = { "records"}, summary = "Download ris as file") public String getRISAsFile() throws PresentationException, IndexUnreachableException, DAOException, ContentLibException { StructEl... |
### Question:
RecordSectionResource { @GET @javax.ws.rs.Path(RECORDS_SECTIONS_RIS_TEXT) @Produces({ MediaType.TEXT_PLAIN }) @Operation(tags = { "records"}, summary = "Get ris as text") public String getRISAsText() throws PresentationException, IndexUnreachableException, ContentNotFoundException, DAOException { StructEl... |
### Question:
RecordSectionResource { @GET @javax.ws.rs.Path(RECORDS_SECTIONS_RANGE) @Produces({ MediaType.APPLICATION_JSON }) @Operation(tags = {"records", "iiif"}, summary = "Get IIIF range for section") @IIIFPresentationBinding public IPresentationModelElement getRange() throws ContentNotFoundException, Presentation... |
### Question:
ViewerRecordPDFResource extends MetsPdfResource { @Override @GET @Path(ApiUrls.RECORDS_PDF) @Produces("application/pdf") @ContentServerPdfBinding @Operation(tags = { "records" }, summary = "Get PDF for entire record") public StreamingOutput getPdf() throws ContentLibException { logger.trace("getPdf: {}", ... |
### Question:
ViewerSectionPDFResource extends MetsPdfResource { @GET @Path(ApiUrls.RECORDS_SECTIONS_PDF) @Produces("application/pdf") @ContentServerPdfBinding @Operation(tags = { "records"}, summary = "Get PDF for section of record") public StreamingOutput getPdf() throws ContentLibException { response.addHeader("Cont... |
### Question:
CollectionsResource { @GET @Produces({ MediaType.APPLICATION_JSON }) @Operation(tags = { "iiif" }, summary = "Get all collections as IIIF presentation collection") @ApiResponse(responseCode="400", description="No collections available for field") public Collection getAllCollections( @Parameter(description... |
### Question:
CollectionsResource { @GET @javax.ws.rs.Path(COLLECTIONS_COLLECTION) @Produces({ MediaType.APPLICATION_JSON }) @Operation(tags = { "iiif" }, summary = "Get given collection as a IIIF presentation collection") @ApiResponse(responseCode="400", description="Invalid collection name or field") public Collectio... |
### Question:
TranslationResource { @GET @Path(ApiUrls.LOCALIZATION_TRANSLATIONS) @Produces({ MediaType.APPLICATION_JSON }) @Operation(tags= {"localization"}, summary = "Get translations for message keys", description = "Pass a list of message keys to get translations for all configured languages") @ApiResponse(respons... |
### Question:
ApplicationResource { @GET @Produces(MediaType.APPLICATION_JSON) public ApiInfo getApiInfo() { ApiInfo info = new ApiInfo(); info.name = "Goobi viewer REST API"; info.version = "v1"; info.specification = urls.getApiUrl() + "/openapi.json"; return info; } @GET @Produces(MediaType.APPLICATION_JSON) ApiInfo... |
### Question:
CampaignItemResource { @GET @Path("/{campaignId}/{pi}") @Produces({ MediaType.APPLICATION_JSON }) @CORSBinding public CampaignItem getItemForManifest(@PathParam("campaignId") Long campaignId, @PathParam("pi") String pi) throws URISyntaxException, DAOException, ContentNotFoundException { URI manifestURI = ... |
### Question:
CampaignItemResource { @PUT @Path("/{campaignId}/{pi}/") @Consumes({ MediaType.APPLICATION_JSON }) @CORSBinding public void setItemForManifest(CampaignItem item, @PathParam("campaignId") Long campaignId, @PathParam("pi") String pi) throws DAOException { CampaignRecordStatus status = item.getRecordStatus()... |
### Question:
CampaignItemResource { @GET @Path("/{campaignId}/{pi}/annotations") @Produces({ MediaType.APPLICATION_JSON }) @CORSBinding public List<WebAnnotation> getAnnotationsForManifest(@PathParam("campaignId") Long campaignId, @PathParam("pi") String pi) throws URISyntaxException, DAOException { Campaign campaign ... |
### Question:
CMSContentResource { @GET @Path("/content/{pageId}/{language}/{contentId}") @Produces({ MediaType.TEXT_HTML }) public String getContentHtml(@PathParam("pageId") Long pageId, @PathParam("language") String language, @PathParam("contentId") String contentId) throws IOException, DAOException, ServletException... |
### Question:
CMSContentResource { @GET @Path("/sidebar/{elementId}") @Produces({ MediaType.TEXT_PLAIN }) public String getSidebarElementHtml(@PathParam("elementId") Long elementId) throws IOException, DAOException, ServletException { String output = createResponseInThread(TargetType.SIDEBAR, elementId, null, null, REQ... |
### Question:
CMSContentResource { public static String getContentUrl(CMSContentItem item) { if (item != null) { StringBuilder urlBuilder = new StringBuilder(BeanUtils.getServletPathWithHostAsUrlFromJsfContext()); urlBuilder.append("/rest/cms/"); urlBuilder.append(TargetType.CONTENT.name().toLowerCase()); urlBuilder.ap... |
### Question:
CMSContentResource { public static String getSidebarElementUrl(CMSSidebarElement item) { if (item != null && item.hasHtml()) { StringBuilder urlBuilder = new StringBuilder(BeanUtils.getServletPathWithHostAsUrlFromJsfContext()); urlBuilder.append("/rest/cms/"); urlBuilder.append(TargetType.SIDEBAR.name().t... |
### Question:
ManifestResource extends AbstractResource { @GET @Path("/{pi}/manifest") @Produces({ MediaType.APPLICATION_JSON }) public IPresentationModelElement getManifest(@PathParam("pi") String pi) throws PresentationException, IndexUnreachableException, URISyntaxException, ViewerConfigurationException, DAOExceptio... |
### Question:
SessionResource { @GET @Path("/info") @Produces({ MediaType.TEXT_PLAIN }) @CORSBinding public String getSessionInfo() { if (servletRequest == null) { return "Servlet request not found"; } StringBuilder sb = new StringBuilder(); Map<String, String> sessionMap = DataManager.getInstance().getSessionMap().get... |
### Question:
NormdataResource { static JSONObject addNormDataValuesToJSON(NormData normData, Locale locale) { JSONObject jsonObj = new JSONObject(); String translation = ViewerResourceBundle.getTranslation(normData.getKey(), locale); String translatedKey = StringUtils.isNotEmpty(translation) ? translation : normData.g... |
### Question:
CMSPageTemplate implements Serializable { public static CMSPageTemplate loadFromXML(Path file) { if (file == null) { throw new IllegalArgumentException("file may not be null"); } Document doc; try { doc = XmlTools.readXmlFile(file); } catch (IOException | JDOMException e1) { logger.error(e1.toString(), e1... |
### Question:
SearchHitsNotificationResource { public List<SearchHit> getNewHits(Search search) throws PresentationException, IndexUnreachableException, DAOException, ViewerConfigurationException { Search tempSearch = new Search(search); SearchFacets facets = new SearchFacets(); facets.setCurrentFacetString(tempSearch.... |
### Question:
IdentifierResolver extends HttpServlet { static String constructUrl(SolrDocument targetDoc, boolean pageResolverUrl) { int order = 1; if (targetDoc.containsKey(SolrConstants.THUMBPAGENO)) { order = (int) targetDoc.getFieldValue(SolrConstants.THUMBPAGENO); } else if (targetDoc.containsKey(SolrConstants.ORD... |
### Question:
IdentifierResolver extends HttpServlet { static void parseFieldValueParameters(Map<String, String[]> parameterMap, Map<Integer, String> moreFields, Map<Integer, String> moreValues) { if (parameterMap == null || parameterMap.isEmpty()) { return; } for (String key : parameterMap.keySet()) { if (parameterMap... |
### Question:
JPAClassLoader extends ClassLoader { static Document scanPersistenceXML(URL masterFileUrl, List<URL> moduleUrls) throws IOException, JDOMException { logger.trace("scanPersistenceXML(): {}", masterFileUrl); Document docMerged = new Document(); Document docMaster = XmlTools.readXmlFile(masterFileUrl); Eleme... |
### Question:
ManifestBuilder extends AbstractBuilder { public IPresentationModelElement generateManifest(StructElement ele) throws URISyntaxException, PresentationException, IndexUnreachableException, ViewerConfigurationException, DAOException { final AbstractPresentationModelElement manifest; if (ele.isAnchor()) { ma... |
### Question:
GeoMapMarker { public String toJSONString() throws JsonProcessingException { ObjectMapper mapper = new ObjectMapper(); return mapper.writeValueAsString(this); } GeoMapMarker(String name); GeoMapMarker(); String getIcon(); void setIcon(String icon); String getMarkerColor(); void setMarkerColor(String mark... |
### Question:
AbstractBuilder { protected Map<String, List<String>> getEventFields() { List<String> eventStrings = DataManager.getInstance().getConfiguration().getIIIFEventFields(); Map<String, List<String>> events = new HashMap<>(); for (String string : eventStrings) { String event, field; int separatorIndex = string.... |
### Question:
SearchResultConverter { public SearchHit convertCommentToHit(String queryRegex, String pi, Comment comment) { SearchHit hit = new SearchHit(); String text = comment.getDisplayText(); Matcher m = Pattern.compile(AbstractSearchParser.getSingleWordRegex(queryRegex)).matcher(text); while (m.find()) { String m... |
### Question:
SearchResultConverter { public SearchHit convertUGCToHit(String queryRegex, SolrDocument ugc) { SearchHit hit = new SearchHit(); String mdText = SolrSearchIndex.getMetadataValues(ugc, SolrConstants.UGCTERMS).stream().collect(Collectors.joining("; ")); String type = SolrSearchIndex.getSingleFieldStringValu... |
### Question:
SearchResultConverter { public SearchHit convertMetadataToHit(String queryRegex, String fieldName, SolrDocument doc) { SearchHit hit = new SearchHit(); String mdText = SolrSearchIndex.getMetadataValues(doc, fieldName).stream().collect(Collectors.joining("; ")); Matcher m = Pattern.compile(AbstractSearchPa... |
### Question:
SearchResultConverter { public AnnotationResultList getAnnotationsFromAlto(Path path, String query) throws IOException, JDOMException { AnnotationResultList results = new AnnotationResultList(); AltoSearchParser parser = new AltoSearchParser(); AltoDocument doc = AltoDocument.getDocumentFromFile(path.toFi... |
### Question:
SearchResultConverter { public AnnotationResultList getAnnotationsFromFulltext(String text, String pi, Integer pageNo, String query, long previousHitCount, int firstIndex, int numHits) { AnnotationResultList results = new AnnotationResultList(); long firstPageHitIndex = previousHitCount; long lastPageHitI... |
### Question:
AltoSearchParser extends AbstractSearchParser { public List<List<Word>> findWordMatches(List<Word> words, String regex) { ListIterator<Word> iterator = words.listIterator(); List<List<Word>> results = new ArrayList<>(); while (iterator.hasNext()) { Word word = iterator.next(); if (Pattern.matches(regex, w... |
### Question:
AltoSearchParser extends AbstractSearchParser { public Map<Range<Integer>, List<Line>> findLineMatches(List<Line> lines, String regex) { String text = getText(lines); Map<Range<Integer>, List<Line>> map = new LinkedHashMap<>(); String singleWordRegex = getSingleWordRegex(regex); Matcher matcher = Pattern.... |
### Question:
StructElement extends StructElementStub implements Comparable<StructElementStub>, Serializable { public StructElement getParent() throws IndexUnreachableException { StructElement parent = null; try { String parentIddoc = getMetadataValue(SolrConstants.IDDOC_PARENT); if (parentIddoc != null) { parent = new... |
### Question:
StructElement extends StructElementStub implements Comparable<StructElementStub>, Serializable { public boolean isAnchorChild() throws IndexUnreachableException { if (isWork() && isHasParent()) { return true; } return false; } StructElement(); StructElement(long luceneId); StructElement(long luceneId, S... |
### Question:
CMSCategoryUpdate implements IModelUpdate { public boolean convertData() throws DAOException { if (this.entityMap == null || this.media == null || this.pages == null || this.content == null || this.categories == null) { throw new IllegalStateException("Must successfully run loadData() before calling conve... |
### Question:
CMSCategoryUpdate implements IModelUpdate { protected List<CMSCategory> createCategories(Map<String, Map<String, List<Long>>> entityMap) { return entityMap.values() .stream() .flatMap(map -> map.keySet().stream()) .flatMap(name -> Arrays.stream(name.split(CLASSIFICATION_SEPARATOR_REGEX))) .filter(name -> ... |
### Question:
LoginFilter implements Filter { public static boolean isRestrictedUri(String uri) { if (uri == null) { return false; } if (uri.matches("/?viewer/.*")) { uri = uri.replaceAll("/?viewer/", "/"); } logger.trace("uri: {}", uri); switch (uri.trim()) { case "/myactivity/": case "/mysearches/": return true; defa... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.