method2testcases
stringlengths
118
6.63k
### Question: EventBus { public void register(Object object) { subscribeAll(finder.findAllSubscribers(object)); } void subscribe(Class<?> clazz, EventHandler handler); void subscribeAll(Multimap<Class<?>, EventHandler> handlers); void unsubscribe(Class<?> clazz, EventHandler handler); void unsubscribeAll(Multimap<Clas...
### Question: EventBus { public void unregister(Object object) { unsubscribeAll(finder.findAllSubscribers(object)); } void subscribe(Class<?> clazz, EventHandler handler); void subscribeAll(Multimap<Class<?>, EventHandler> handlers); void unsubscribe(Class<?> clazz, EventHandler handler); void unsubscribeAll(Multimap<...
### Question: CommandContext { public String[] getSlice(int index) { String[] slice = new String[originalArgs.length - index]; System.arraycopy(originalArgs, index, slice, 0, originalArgs.length - index); return slice; } CommandContext(String args); CommandContext(String[] args); CommandContext(String args, Set<Chara...
### Question: BlockMap extends AbstractMap<BlockVector3, V> { @Override public V get(Object key) { BlockVector3 vec = (BlockVector3) key; Int2ObjectMap<V> activeMap = maps.get(toGroupKey(vec)); if (activeMap == null) { return null; } return activeMap.get(toInnerKey(vec)); } private BlockMap(Supplier<Int2ObjectMap<V>> ...
### Question: Expression { public double evaluate(double... values) throws EvaluationException { return evaluate(values, WorldEdit.getInstance().getConfiguration().calculationTimeout); } private Expression(String expression, String... variableNames); static Expression compile(String expression, String... variableNames...
### Question: Expression { public static Expression compile(String expression, String... variableNames) throws ExpressionException { return new Expression(expression, variableNames); } private Expression(String expression, String... variableNames); static Expression compile(String expression, String... variableNames);...
### Question: FileSystemSnapshotDatabase implements SnapshotDatabase { public Path getRoot() { return root; } FileSystemSnapshotDatabase(Path root, ArchiveNioSupport archiveNioSupport); static ZonedDateTime tryParseDate(Path path); static URI createUri(String name); static FileSystemSnapshotDatabase maybeCreate( ...
### Question: DinnerPermsResolver implements PermissionsResolver { @Override @SuppressWarnings("deprecation") public boolean hasPermission(String name, String permission) { return hasPermission(server.getOfflinePlayer(name), permission); } DinnerPermsResolver(Server server); static PermissionsResolver factory(Server se...
### Question: DinnerPermsResolver implements PermissionsResolver { @Override @SuppressWarnings("deprecation") public boolean inGroup(String name, String group) { return inGroup(server.getOfflinePlayer(name), group); } DinnerPermsResolver(Server server); static PermissionsResolver factory(Server server, YAMLProcessor co...
### Question: BukkitWorld extends AbstractWorld { public static TreeType toBukkitTreeType(TreeGenerator.TreeType type) { return treeTypeMapping.get(type); } BukkitWorld(World world); @Override List<com.sk89q.worldedit.entity.Entity> getEntities(Region region); @Override List<com.sk89q.worldedit.entity.Entity> getEntiti...
### Question: CommandContext { public int argsLength() { return parsedArgs.size(); } CommandContext(String args); CommandContext(String[] args); CommandContext(String args, Set<Character> valueFlags); CommandContext(String args, Set<Character> valueFlags, boolean allowHangingFlag); CommandContext(String[] args, Set...
### Question: Location { public Extent getExtent() { return extent; } Location(Extent extent); Location(Extent extent, double x, double y, double z); Location(Extent extent, Vector3 position); Location(Extent extent, double x, double y, double z, Vector3 direction); Location(Extent extent, double x, double y, doubl...
### Question: Location { public Vector3 toVector() { return position; } Location(Extent extent); Location(Extent extent, double x, double y, double z); Location(Extent extent, Vector3 position); Location(Extent extent, double x, double y, double z, Vector3 direction); Location(Extent extent, double x, double y, dou...
### Question: Location { public double getX() { return position.getX(); } Location(Extent extent); Location(Extent extent, double x, double y, double z); Location(Extent extent, Vector3 position); Location(Extent extent, double x, double y, double z, Vector3 direction); Location(Extent extent, double x, double y, d...
### Question: Location { public int getBlockX() { return (int) Math.floor(position.getX()); } Location(Extent extent); Location(Extent extent, double x, double y, double z); Location(Extent extent, Vector3 position); Location(Extent extent, double x, double y, double z, Vector3 direction); Location(Extent extent, d...
### Question: Location { public Location setX(double x) { return new Location(extent, position.withX(x), yaw, pitch); } Location(Extent extent); Location(Extent extent, double x, double y, double z); Location(Extent extent, Vector3 position); Location(Extent extent, double x, double y, double z, Vector3 direction); ...
### Question: Location { public double getY() { return position.getY(); } Location(Extent extent); Location(Extent extent, double x, double y, double z); Location(Extent extent, Vector3 position); Location(Extent extent, double x, double y, double z, Vector3 direction); Location(Extent extent, double x, double y, d...
### Question: Location { public int getBlockY() { return (int) Math.floor(position.getY()); } Location(Extent extent); Location(Extent extent, double x, double y, double z); Location(Extent extent, Vector3 position); Location(Extent extent, double x, double y, double z, Vector3 direction); Location(Extent extent, d...
### Question: ViewerResourceBundle extends ResourceBundle { static String replaceParameters(final String msg, String... params) { String ret = msg; if (ret != null && params != null) { for (int i = 0; i < params.length; ++i) { ret = ret.replace(new StringBuilder("{").append(i).append("}").toString(), params[i]); } } re...
### Question: StructElement extends StructElementStub implements Comparable<StructElementStub>, Serializable { @Override public String getPi() { if (pi != null && !pi.equals("null")) { return pi; } else if (getMetadataValue(SolrConstants.PI_TOPSTRUCT) != null) { pi = getMetadataValue(SolrConstants.PI_TOPSTRUCT); return...
### Question: LeanPageLoader extends AbstractPageLoader implements Serializable { @Override public int getNumPages() throws IndexUnreachableException { if (numPages < 0) { numPages = topElement.getNumPages(); } return numPages; } LeanPageLoader(StructElement topElement, int numPages); @Override int getNumPages(); @Over...
### Question: LeanPageLoader extends AbstractPageLoader implements Serializable { @Override public PhysicalElement getPage(int pageOrder) throws IndexUnreachableException, DAOException { if (pageOrder != currentPageNumber && pageOrder >= firstPageOrder && pageOrder <= lastPageOrder) { try { currentPage = loadPage(pageO...
### Question: LeanPageLoader extends AbstractPageLoader implements Serializable { @Override public PhysicalElement getPageForFileName(String fileName) throws PresentationException, IndexUnreachableException, DAOException { return loadPage(-1, fileName); } LeanPageLoader(StructElement topElement, int numPages); @Overrid...
### Question: LeanPageLoader extends AbstractPageLoader implements Serializable { protected PhysicalElement loadPage(int pageNumber, String fileName) throws PresentationException, IndexUnreachableException, DAOException { String pi = topElement.getPi(); if (pageNumber >= 0) { logger.trace("Loading page {} for '{}'...",...
### Question: IpRange implements ILicensee, Serializable { public boolean canSatisfyAllAccessConditions(Set<String> conditionList, List<LicenseType> licenseTypes, String privilegeName, String pi) throws PresentationException, IndexUnreachableException, DAOException { if (AccessConditionUtils.isFreeOpenAccess(conditionL...
### Question: EagerPageLoader extends AbstractPageLoader implements Serializable { @Override public int getNumPages() { return pages.size(); } EagerPageLoader(StructElement topElement); @Override int getNumPages(); @Override int getFirstPageOrder(); @Override int getLastPageOrder(); @Override PhysicalElement getPage(in...
### Question: EagerPageLoader extends AbstractPageLoader implements Serializable { @Override public PhysicalElement getPage(int pageOrder) { return pages.get(pageOrder); } EagerPageLoader(StructElement topElement); @Override int getNumPages(); @Override int getFirstPageOrder(); @Override int getLastPageOrder(); @Overri...
### Question: EagerPageLoader extends AbstractPageLoader implements Serializable { @Override public PhysicalElement getPageForFileName(String fileName) { for (int key : pages.keySet()) { PhysicalElement page = pages.get(key); if (fileName.equals(page.getFileName())) { return page; } } return null; } EagerPageLoader(Str...
### Question: EagerPageLoader extends AbstractPageLoader implements Serializable { @Override public int getFirstPageOrder() { return firstPageOrder; } EagerPageLoader(StructElement topElement); @Override int getNumPages(); @Override int getFirstPageOrder(); @Override int getLastPageOrder(); @Override PhysicalElement ge...
### Question: EagerPageLoader extends AbstractPageLoader implements Serializable { @Override public int getLastPageOrder() { return lastPageOrder; } EagerPageLoader(StructElement topElement); @Override int getNumPages(); @Override int getFirstPageOrder(); @Override int getLastPageOrder(); @Override PhysicalElement getP...
### Question: AbstractPageLoader implements IPageLoader { protected String buildPageLabelTemplate(String format, Locale locale) throws IndexUnreachableException { if (format == null) { throw new IllegalArgumentException("format may not be null"); } String labelTemplate = format.replace("{numpages}", String.valueOf(getN...
### Question: PhysicalElement implements Comparable<PhysicalElement>, Serializable { protected static String determineFileName(String filePath) { String ret = filePath; if (StringUtils.isNotBlank(ret) && !(ret.startsWith("http: File file = new File(ret); ret = file.getName(); } return ret; } PhysicalElement(String phys...
### Question: EventElement implements Comparable<EventElement>, Serializable { public Date getDateStart() { return dateStart; } EventElement(SolrDocument doc, Locale locale); @Override int compareTo(EventElement o); String getDisplayDate(); String getLabel(); String getType(); void setType(String type); Date getDateSta...
### Question: EventElement implements Comparable<EventElement>, Serializable { public Date getDateEnd() { return dateEnd; } EventElement(SolrDocument doc, Locale locale); @Override int compareTo(EventElement o); String getDisplayDate(); String getLabel(); String getType(); void setType(String type); Date getDateStart()...
### Question: TocMaker { protected static List<String> getSolrFieldsToFetch(String template) { logger.trace("getSolrFieldsToFetch: {}", template); Set<String> ret = new HashSet<>(Arrays.asList(REQUIRED_FIELDS)); List<Metadata> metadataList = DataManager.getInstance().getConfiguration().getTocLabelConfiguration(template...
### Question: TOCElement implements Serializable { public String getUrl() { return urlPrefix + urlSuffix; } TOCElement(IMetadataValue label, String pageNo, String pageNoLabel, String iddoc, String logId, int level, String topStructPi, String thumbnailUrl, boolean accessPermissionPdf, boolean anchorOrGroup, ...
### Question: CalendarView { public List<String> getVolumeYears() throws PresentationException, IndexUnreachableException { if (anchorPi == null) { return Collections.emptyList(); } return SearchHelper.getFacetValues("+" + SolrConstants.PI_ANCHOR + ":" + anchorPi + " +" + SolrConstants._CALENDAR_DAY + ":*", SolrConstan...
### Question: Sitemap { private Element createUrlElement(String pi, int order, String dateModified, String type, String changefreq, String priority) { return createUrlElement(viewerRootUrl + '/' + type + '/' + pi + '/' + order + '/', dateModified, changefreq, priority); } List<File> generate(String viewerRootUrl, Stri...
### Question: ViewerPathBuilder { public static boolean startsWith(URI uri, String string) { if (uri != null) { if (uri.toString().endsWith("/") && !string.endsWith("/")) { string = string + "/"; } String[] uriParts = uri.toString().split("/"); String[] stringParts = string.toString().split("/"); if (uriParts.length < ...
### Question: AdvancedSearchFieldConfiguration { public String getLabel() { if (label == null) { return field; } return label; } AdvancedSearchFieldConfiguration(String field); String getField(); String getLabel(); AdvancedSearchFieldConfiguration setLabel(String label); boolean isHierarchical(); AdvancedSearchFieldCon...
### Question: SearchFacets implements Serializable { static String generateFacetPrefix(List<FacetItem> facetItems, boolean escapeSlashes) { if (facetItems == null) { throw new IllegalArgumentException("facetItems may not be null"); } StringBuilder sb = new StringBuilder(); for (FacetItem facetItem : facetItems) { if (e...
### Question: UserTools { public static int deleteBookmarkListsForUser(User owner) throws DAOException { List<BookmarkList> bookmarkLists = DataManager.getInstance().getDao().getBookmarkLists(owner); if (bookmarkLists.isEmpty()) { return 0; } int count = 0; for (BookmarkList bookmarkList : bookmarkLists) { if (DataMana...
### Question: SearchFacets implements Serializable { public String getCurrentFacetString() { String ret = generateFacetPrefix(currentFacets, true); if (StringUtils.isEmpty(ret)) { ret = "-"; } try { return URLEncoder.encode(ret, SearchBean.URL_ENCODING); } catch (UnsupportedEncodingException e) { return ret; } } void ...
### Question: SearchFacets implements Serializable { String generateFacetFilterQuery(boolean includeRangeFacets) { if (currentFacets.isEmpty()) { return null; } StringBuilder sbQuery = new StringBuilder(); for (FacetItem facetItem : currentFacets) { if (facetItem.isHierarchial()) { continue; } if (facetItem.getField()....
### Question: SearchFacets implements Serializable { String generateHierarchicalFacetFilterQuery(int advancedSearchGroupOperator) { if (currentFacets.isEmpty()) { return null; } StringBuilder sbQuery = new StringBuilder(); int count = 0; for (FacetItem facetItem : currentFacets) { if (!facetItem.isHierarchial()) { cont...
### Question: SearchFacets implements Serializable { public boolean isHasWrongLanguageCode(String field, String language) { if (field == null) { throw new IllegalArgumentException("field may not be null"); } if (language == null) { throw new IllegalArgumentException("language may not be null"); } if (field.contains(Sol...
### Question: SearchFacets implements Serializable { public String updateFacetItem(String field, boolean hierarchical) { updateFacetItem(field, tempValue, currentFacets, hierarchical); return "pretty:search6"; } void resetAvailableFacets(); void resetCurrentFacets(); void resetSliderRange(); List<String> generateFacet...
### Question: FacetItem implements Comparable<FacetItem>, Serializable { public String getQueryEscapedLink() { String field = SearchHelper.facetifyField(this.field); String escapedValue = getEscapedValue(value); if (hierarchial) { return new StringBuilder("(").append(field) .append(':') .append(escapedValue) .append(" ...
### Question: UserTools { public static int deleteSearchesForUser(User owner) throws DAOException { List<Search> searches = DataManager.getInstance().getDao().getSearches(owner); if (searches.isEmpty()) { return 0; } int count = 0; for (Search search : searches) { if (DataManager.getInstance().getDao().deleteSearch(sea...
### Question: FacetItem implements Comparable<FacetItem>, Serializable { static String getEscapedValue(String value) { if (StringUtils.isEmpty(value)) { return value; } String escapedValue = null; if (value.charAt(0) == '"' && value.charAt(value.length() - 1) == '"' && value.length() > 2) { escapedValue = '"' + ClientU...
### Question: BrowseElement implements Serializable { static String generateDefaultLabel(StructElement se, Locale locale) { String ret = null; if (locale != null) { String englishTitle = null; String germanTitle = null; String anyTitle = null; for (String key : se.getMetadataFields().keySet()) { if (key.equals(SolrCons...
### Question: BrowseElement implements Serializable { public String getFulltextForHtml() { if (fulltextForHtml == null) { if (fulltext != null) { fulltextForHtml = StringTools.stripJS(fulltext).replaceAll("\n", " "); } else { fulltextForHtml = ""; } } return fulltextForHtml; } BrowseElement(String pi, int imageNo, Stri...
### Question: UserTools { public static int deleteUserGroupOwnedByUser(User owner) throws DAOException { List<UserGroup> userGroups = owner.getUserGroupOwnerships(); if (userGroups.isEmpty()) { return 0; } int count = 0; for (UserGroup userGroup : userGroups) { if (!userGroup.getMemberships().isEmpty()) { for (UserRole...
### Question: UserTools { public static void deleteUserPublicContributions(User user) throws DAOException { if (user == null) { return; } int comments = DataManager.getInstance().getDao().deleteComments(null, user); logger.debug("{} comment(s) of user {} deleted.", comments, user.getId()); int statistics = DataManager....
### Question: UserTools { public static boolean anonymizeUserPublicContributions(User user) throws DAOException { User anon = UserTools.checkAndCreateAnonymousUser(); if (anon == null) { logger.error("Anonymous user could not be found"); return false; } int comments = DataManager.getInstance().getDao().changeCommentsOw...
### Question: UserGroup implements ILicensee, Serializable { public long getMemberCount() throws DAOException { return DataManager.getInstance().getDao().getUserRoleCount(this, null, null); } @Override int hashCode(); @Override boolean equals(Object obj); boolean addMember(User user, Role role); boolean changeMemberRo...
### Question: UserGroup implements ILicensee, Serializable { public Set<User> getMembersAndOwner() throws DAOException { Set<User> ret = new HashSet<>(getMembers()); ret.add(getOwner()); return ret; } @Override int hashCode(); @Override boolean equals(Object obj); boolean addMember(User user, Role role); boolean chang...
### Question: BibliothecaAuthenticationRequest extends UserPasswordAuthenticationRequest { static String normalizeUsername(String username) { if (username == null || username.length() == 11) { return username; } if (username.length() < 11) { StringBuilder sb = new StringBuilder(11); for (int i = username.length(); i < ...
### Question: BrowseTermComparator implements Comparator<BrowseTerm>, Serializable { public static String normalizeString(String s, String ignoreChars) { if (s == null) { return null; } if (StringUtils.isNotEmpty(ignoreChars)) { while (s.length() > 1 && ignoreChars.contains(s.substring(0, 1))) { s = s.substring(1); } }...
### Question: DownloadJob implements Serializable { public static String generateDownloadJobId(String... criteria) { StringBuilder sbCriteria = new StringBuilder(criteria.length * 10); for (String criterion : criteria) { if (criterion != null) { sbCriteria.append(criterion); } } return StringTools.generateMD5(sbCriteri...
### Question: LitteraProvider extends HttpAuthenticationProvider { @Override public CompletableFuture<LoginResult> login(String loginName, String password) throws AuthenticationProviderException { try { LitteraAuthenticationResponse response = get(new URI(getUrl()), loginName, password); Optional<User> user = getUser(l...
### Question: CrowdsourcingBean implements Serializable { public long getCampaignCount(CampaignVisibility visibility) throws DAOException { Map<String, String> filters = visibility != null ? Collections.singletonMap("visibility", visibility.name()) : null; return DataManager.getInstance().getDao().getCampaignCount(filt...
### Question: CrowdsourcingBean implements Serializable { public List<Campaign> getAllCampaigns() throws DAOException { List<Campaign> pages = DataManager.getInstance().getDao().getAllCampaigns(); return pages; } @PostConstruct void init(); long getCampaignCount(CampaignVisibility visibility); String filterCampaignsAc...
### Question: CrowdsourcingBean implements Serializable { public void saveSelectedCampaign() throws DAOException, PresentationException, IndexUnreachableException { logger.trace("saveSelectedCampaign"); try { if (userBean == null || !userBean.getUser().isSuperuser()) { return; } if (selectedCampaign == null) { return; ...
### Question: LocalAuthenticationProvider implements IAuthenticationProvider { @Override public CompletableFuture<LoginResult> login(String email, String password) throws AuthenticationProviderException { HttpServletRequest request = BeanUtils.getRequest(); HttpServletResponse response = BeanUtils.getResponse(); if (St...
### Question: ActiveDocumentBean implements Serializable { public void setPersistentIdentifier(String persistentIdentifier) throws PresentationException, RecordNotFoundException, IndexUnreachableException { synchronized (this) { logger.trace("setPersistentIdentifier: {}", persistentIdentifier); lastReceivedIdentifier =...
### Question: SitelinkBean implements Serializable { public List<String> getAvailableValuesForField(String field, String filterQuery) throws PresentationException, IndexUnreachableException { if (field == null) { throw new IllegalArgumentException("field may not be null"); } if (filterQuery == null) { throw new Illegal...
### Question: BeanUtils { public static String escapeCriticalUrlChracters(String value) { return escapeCriticalUrlChracters(value, false); } static HttpServletRequest getRequest(); static HttpServletRequest getRequest(FacesContext context); static HttpSession getSession(); static String getServletPathWithHostAsUrlFrom...
### Question: BeanUtils { public static String unescapeCriticalUrlChracters(String value) { if (value == null) { throw new IllegalArgumentException("value may not be null"); } return value.replace(SLASH_REPLACEMENT, "/") .replace(BACKSLASH_REPLACEMENT, "\\") .replace(PIPE_REPLACEMENT, "|") .replace(QUESTION_MARK_REPLAC...
### Question: CmsMediaBean implements Serializable { public List<CMSCategory> getAllMediaCategories() throws DAOException { return DataManager.getInstance().getDao().getAllCategories(); } CmsMediaBean(); void resetData(); CMSMediaItem createMediaItem(); List<CMSPage> getMediaOwnerPages(CMSMediaItem item); void deleteMe...
### Question: CmsMediaBean implements Serializable { public List<CategorizableTranslatedSelectable<CMSMediaItem>> getMediaItems() throws DAOException { return this.dataProvider.getPaginatorList(); } CmsMediaBean(); void resetData(); CMSMediaItem createMediaItem(); List<CMSPage> getMediaOwnerPages(CMSMediaItem item); vo...
### Question: CmsMediaBean implements Serializable { public static String getImageFilter() { return "(?i).*\\.(png|jpe?g|gif|tiff?|jp2)"; } CmsMediaBean(); void resetData(); CMSMediaItem createMediaItem(); List<CMSPage> getMediaOwnerPages(CMSMediaItem item); void deleteMedia(CMSMediaItem item); List<CMSMediaItem> getAl...
### Question: BrowseBean implements Serializable { public List<String> getBrowsingMenuItems(String language) { if (language != null) { language = language.toUpperCase(); } List<String> ret = new ArrayList<>(); for (BrowsingMenuFieldConfig bmfc : DataManager.getInstance().getConfiguration().getBrowsingMenuFields()) { if...
### Question: BrowseBean implements Serializable { public String getCollectionHierarchy(String collectionField, String collectionValue) { if (StringUtils.isEmpty(collectionField) || StringUtils.isEmpty(collectionValue)) { return ""; } String separator = DataManager.getInstance().getConfiguration().getCollectionSplittin...
### Question: ThumbnailHandler { public String getFullImageUrl(PhysicalElement page) { return getFullImageUrl(page, Scale.MAX); } ThumbnailHandler(IIIFUrlHandler iiifUrlHandler, Configuration configuration, String staticImagesPath); URI getThumbnailPath(String filename); String getThumbnailUrl(PhysicalElement page); St...
### Question: ImageHandler { public String getImageUrl(PhysicalElement page, PageType pageType) { if (page == null) { throw new IllegalArgumentException("Cannot get image url: PhysicalElement is null"); } if (pageType == null) { throw new IllegalArgumentException("Cannot get image url: PageType is null"); } String pi =...
### Question: MediaHandler { public String getMediaUrl(String type, String format, String pi, String filename) throws IllegalRequestException { if(urls != null) { if(type.equalsIgnoreCase("audio")) { return urls.path(ApiUrls.RECORDS_FILES, ApiUrls.RECORDS_FILES_AUDIO).params(pi, format, filename).build(); } else if(typ...
### Question: IIIFUrlHandler { public String getIIIFImageUrl(String fileUrl, String docStructIdentifier, String region, String size, String rotation, String quality, String format) { String apiUrl = this.urls == null ? DataManager.getInstance().getConfiguration().getIIIFApiUrl() : this.urls.getApiUrl() + "/"; return ge...
### Question: ViewerResourceBundle extends ResourceBundle { public static List<Locale> getAllLocales() { if (allLocales == null) { checkAndLoadResourceBundles(); Set<Locale> locales = new HashSet<>(); locales.addAll(defaultBundles.keySet()); locales.addAll(localBundles.keySet()); allLocales = new ArrayList<>(locales); ...
### Question: PdfHandler { public String getPdfUrl(StructElement doc, PhysicalElement page) { return getPdfUrl(doc, new PhysicalElement[] { page }); } PdfHandler(WatermarkHandler watermarkHandler, Configuration configuration); PdfHandler(WatermarkHandler watermarkHandler, AbstractApiUrlManager urls); String getPdfUrl(...
### Question: IIIFPresentationAPIHandler { public String getManifestUrl(String pi) throws URISyntaxException { return builder.getManifestURI(pi).toString(); } IIIFPresentationAPIHandler(AbstractApiUrlManager urls, Configuration configuration); String getManifestUrl(String pi); String getCollectionUrl(); String getColle...
### Question: IIIFPresentationAPIHandler { public String getCollectionUrl() throws URISyntaxException { return getCollectionUrl(SolrConstants.DC); } IIIFPresentationAPIHandler(AbstractApiUrlManager urls, Configuration configuration); String getManifestUrl(String pi); String getCollectionUrl(); String getCollectionUrl(S...
### Question: IIIFPresentationAPIHandler { public String getLayerUrl(String pi, String annotationType) throws URISyntaxException { AnnotationType type = AnnotationType.valueOf(annotationType.toUpperCase()); if (type == null) { throw new IllegalArgumentException(annotationType + " is not valid annotation type"); } retur...
### Question: IIIFPresentationAPIHandler { public String getAnnotationsUrl(String pi, int pageOrder, String annotationType) throws URISyntaxException { AnnotationType type = AnnotationType.valueOf(annotationType.toUpperCase()); if (type == null) { throw new IllegalArgumentException(annotationType + " is not valid annot...
### Question: IIIFPresentationAPIHandler { public String getCanvasUrl(String pi, int pageOrder) throws URISyntaxException { return builder.getCanvasURI(pi, pageOrder).toString(); } IIIFPresentationAPIHandler(AbstractApiUrlManager urls, Configuration configuration); String getManifestUrl(String pi); String getCollection...
### Question: IIIFPresentationAPIHandler { public String getRangeUrl(String pi, String logId) throws URISyntaxException { return builder.getRangeURI(pi, logId).toString(); } IIIFPresentationAPIHandler(AbstractApiUrlManager urls, Configuration configuration); String getManifestUrl(String pi); String getCollectionUrl(); ...
### Question: XmlTools { public static Document getDocumentFromString(String string, String encoding) throws JDOMException, IOException { if (encoding == null) { encoding = StringTools.DEFAULT_ENCODING; } byte[] byteArray = null; try { byteArray = string.getBytes(encoding); } catch (UnsupportedEncodingException e) { } ...
### Question: XmlTools { public static String getStringFromElement(Object element, String encoding) { if (element == null) { throw new IllegalArgumentException("element may not be null"); } if (encoding == null) { encoding = StringTools.DEFAULT_ENCODING; } Format format = Format.getRawFormat(); XMLOutputter outputter =...
### Question: XmlTools { public static File writeXmlFile(Document doc, String filePath) throws FileNotFoundException, IOException { return FileTools.getFileFromString(getStringFromElement(doc, StringTools.DEFAULT_ENCODING), filePath, StringTools.DEFAULT_ENCODING, false); } static Document readXmlFile(String filePath);...
### Question: XmlTools { public static Document readXmlFile(String filePath) throws FileNotFoundException, IOException, JDOMException { try (FileInputStream fis = new FileInputStream(new File(filePath))) { return new SAXBuilder().build(fis); } } static Document readXmlFile(String filePath); static Document readXmlFile...
### Question: ViewerResourceBundle extends ResourceBundle { public static List<Locale> getLocalesFromFile(Path facesConfigPath) throws FileNotFoundException, IOException, JDOMException { Document doc = XmlTools.readXmlFile(facesConfigPath); Namespace xsi = Namespace.getNamespace("xsi", "http: Namespace javaee = Namespa...
### Question: AccessConditionUtils { public static boolean isConcurrentViewsLimitEnabledForAnyAccessCondition(List<String> accessConditions) throws DAOException { if (accessConditions == null || accessConditions.isEmpty()) { return false; } List<LicenseType> licenseTypes = DataManager.getInstance().getDao().getLicenseT...
### Question: SecurityQuestion { public boolean isAnswerCorrect(String answer) { answered = true; if (StringUtils.isBlank(answer)) { return false; } return correctAnswers.contains(answer.toLowerCase()); } SecurityQuestion(String questionKey, Set<String> correctAnswers); boolean isAnswerCorrect(String answer); String ge...
### Question: DCRecordWriter { public void write(Path path) throws IOException { Path filePath = path; if(Files.isDirectory(path)) { if(StringUtils.isNotBlank(getMetadataValue("identifier"))) { filePath = path.resolve(getMetadataValue("identifier") + ".xml"); } else if(StringUtils.isNotBlank(getMetadataValue("title")))...
### Question: RecordLock { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; RecordLock other = (RecordLock) obj; if (pi == null) { if (other.pi != null) return false; } else if (!pi.equals(other.pi)) return false; ...
### Question: RecordLockManager { public synchronized void lockRecord(String pi, String sessionId, Integer limit) throws RecordLimitExceededException { logger.trace("lockRecord: {}", pi); if (pi == null) { throw new IllegalArgumentException("pi may not be null"); } if (sessionId == null) { logger.warn("No sessionId giv...
### Question: Bookmark implements Serializable { @JsonIgnore public MetadataElement getMetadataElement() throws IndexUnreachableException { SolrDocument doc = retrieveSolrDocument(); Long iddoc = Long.parseLong((String)doc.getFirstValue(SolrConstants.IDDOC)); StructElement se = new StructElement(iddoc, doc); Locale ses...
### Question: MetadataTools { public static String applyReplaceRules(String value, List<MetadataReplaceRule> replaceRules, String pi) throws IndexUnreachableException, PresentationException { if (value == null) { return null; } if (replaceRules == null) { return value; } String ret = value; for (MetadataReplaceRule rep...
### Question: MetadataTools { public static String findMetadataGroupType(String gndspec) { if (gndspec == null) { return null; } if (gndspec.length() == 3) { String ret = null; switch (gndspec.substring(0, 2)) { case "gi": ret = MetadataGroupType.LOCATION.name(); break; case "ki": ret = MetadataGroupType.CORPORATION.na...
### Question: MetadataTools { public static String convertLanguageToIso2(String language) { if (language == null) { return null; } if (language.length() == 3) { Language lang = null; try { lang = DataManager.getInstance().getLanguageHelper().getLanguage(language); } catch (IllegalArgumentException e) { logger.warn("No ...