id
stringlengths
7
14
text
stringlengths
1
106k
3732883_1
@Override public Page createPage(PageId pageId) throws EntityAlreadyExistsException { if (getPage(pageId) != null) { throw new EntityAlreadyExistsException("Cannot create page. Page " + pageId + " already exists."); } if (getSite(pageId.getSiteId()) == null) { throw new EntityNotFoundExcepti...
3732883_2
@Override public Page createPage(PageId pageId) throws EntityAlreadyExistsException { if (getPage(pageId) != null) { throw new EntityAlreadyExistsException("Cannot create page. Page " + pageId + " already exists."); } if (getSite(pageId.getSiteId()) == null) { throw new EntityNotFoundExcepti...
3732883_3
@Override public Site createSite(SiteId siteId) { String template = userPortalConfigService.getDefaultPortalTemplate(); if (template == null) { template = ""; // This is valid if we're being executed within a test environment } return createSite(siteId, template); }
3732883_4
@Override public Site createSite(SiteId siteId) { String template = userPortalConfigService.getDefaultPortalTemplate(); if (template == null) { template = ""; // This is valid if we're being executed within a test environment } return createSite(siteId, template); }
3732883_5
@Override public Site createSite(SiteId siteId) { String template = userPortalConfigService.getDefaultPortalTemplate(); if (template == null) { template = ""; // This is valid if we're being executed within a test environment } return createSite(siteId, template); }
3732883_6
@Override public Site createSite(SiteId siteId) { String template = userPortalConfigService.getDefaultPortalTemplate(); if (template == null) { template = ""; // This is valid if we're being executed within a test environment } return createSite(siteId, template); }
3732883_7
@Override public List<Page> findPages(PageQuery query) { Pagination pagination = query.getPagination(); Iterator<PageContext> iterator; if (pagination == null) { if (query.getSiteType() == null || query.getSiteName() == null) throw new IllegalArgumentException("Pagination is required whe...
3732883_8
@Override public List<Site> findSites(SiteQuery query) { Parameters.requireNonNull(query, "query"); Pagination pagination = query.getPagination(); if (pagination != null && query.getSiteTypes().size() > 1) { pagination = null; // set it to null so the internal DataStorage doesn't use it, and we manu...
3732883_9
@Override public List<Site> findSites(SiteQuery query) { Parameters.requireNonNull(query, "query"); Pagination pagination = query.getPagination(); if (pagination != null && query.getSiteTypes().size() > 1) { pagination = null; // set it to null so the internal DataStorage doesn't use it, and we manu...
3742298_0
public void collate(DiffCollatorConfiguration config, Comparand base, Comparand witness) throws IOException { // This amounts to a config for the diff/collation Comparison comparison = new Comparison(base, witness); // First find an filter out any transpositions and collate // the filtered result ...
3742298_1
public void collate(DiffCollatorConfiguration config, Comparand base, Comparand witness) throws IOException { // This amounts to a config for the diff/collation Comparison comparison = new Comparison(base, witness); // First find an filter out any transpositions and collate // the filtered result ...
3742298_2
public void collate(DiffCollatorConfiguration config, Comparand base, Comparand witness) throws IOException { // This amounts to a config for the diff/collation Comparison comparison = new Comparison(base, witness); // First find an filter out any transpositions and collate // the filtered result ...
3742298_3
public void collate(DiffCollatorConfiguration config, Comparand base, Comparand witness) throws IOException { // This amounts to a config for the diff/collation Comparison comparison = new Comparison(base, witness); // First find an filter out any transpositions and collate // the filtered result ...
3742298_4
public void collate(ComparisonSet comparisonSet, CollatorConfig config, BackgroundTaskStatus taskStatus) throws IOException { // grab reference to key data used in the colaltion this.comparisonSet = comparisonSet; this.witnessList = this.setDao.getWitnesses(comparisonSet); this.comparisonSet.setSta...
3742443_0
public static BigInteger[] of(BigInteger a, BigInteger b) { BigInteger x0 = BigInteger.ONE; BigInteger y0 = BigInteger.ZERO; BigInteger x1 = BigInteger.ZERO; BigInteger y1 = BigInteger.ONE; while(!b.equals(BigInteger.ZERO)) { BigInteger[] divmod = a.divideAndRemainder(b); BigInteger xt = x0; BigInteger yt = y0; ...
3742443_1
public static List<BigInteger> of(BigInteger n) { ArrayList<BigInteger> factors = new ArrayList<BigInteger>(); BigInteger divisor = BigInteger.valueOf(2); while (divisor.compareTo(n) <= 0) { if (n.mod(divisor).equals(BigInteger.ZERO)) { factors.add(divisor); while (n.mod(divisor).equals(BigInteger.ZERO)) { ...
3742443_2
@Override public Group.Element<Gq> getIdentityElement() { return element(BigInteger.ONE); }
3742443_3
@Override public Group.Element<Gq> getGenerator() { return generator; }
3742443_4
@Override public Group.Element<Gq> getRandomElement() { Z field = new Z(q); return getGenerator().exponentiate(field.getRandomElement()); }
3742443_5
public GqSetup generateSetup() { return new GqSetup(q, p, createGenerator()); }
3742443_6
public GqSetup generateSetup() { return new GqSetup(q, p, createGenerator()); }
3742443_7
public GqSetup generateSetup() { return new GqSetup(q, p, createGenerator()); }
3742443_8
@Override public FiniteField.Element<Z> getZero() { return element(BigInteger.ZERO); }
3742443_9
@Override public FiniteField.Element<Z> getOne() { return element(BigInteger.ONE); }
3743376_0
@Override public Session getSession() { return session; }
3743376_1
@Override protected PasswordAuthentication getPasswordAuthentication() { if (null == cfg) { cfg = DSpaceServicesFactory.getInstance().getConfigurationService(); } return new PasswordAuthentication( cfg.getProperty("mail.server.username"), cfg.getProperty("mail.server.password")); }
3743376_2
@Override public Properties getProperties() { // Return our configuration as a set of Properties return ConfigurationConverter.getProperties(getConfiguration()); }
3743376_3
@Override public String getProperty(String name) { return getProperty(name, null); }
3743376_4
@Override public String[] getArrayProperty(String name) { return getArrayProperty(name, new String[0]); }
3743376_5
@Override public boolean getBooleanProperty(String name) { return getBooleanProperty(name, false); }
3743376_6
@Override public int getIntProperty(String name) { return getIntProperty(name, 0); }
3743376_7
@Override public long getLongProperty(String name) { return getLongProperty(name, 0); }
3743376_8
@Override public boolean hasProperty(String name) { if (getConfiguration().containsKey(name)) { return true; } else { return false; } }
3743376_9
@Override public <T> T getPropertyAsType(String name, Class<T> type) { return convert(name, type); }
3743505_0
public Account accountInfo() throws DropboxException { assertAuthenticated(); @SuppressWarnings("unchecked") Map<String, Object> accountInfo = (Map<String, Object>) RESTUtility.request(RequestMethod.GET, session.getAPIServer(), "/account/info", VERSION, new String[] {"loc...
3743505_1
public Entry metadata(String path, int fileLimit, String hash, boolean list, String rev) throws DropboxException { assertAuthenticated(); if (fileLimit <= 0) { fileLimit = METADATA_DEFAULT_LIMIT; } String[] params = { "file_limit", String.valueOf(fileLimit), "hash...
3743505_2
public Entry createFolder(String path) throws DropboxException { assertAuthenticated(); String[] params = {"root", session.getAccessType().toString(), "path", path, "locale", session.getLocale().toString()}; @SuppressWarnings("unchecked") Map<String, Object>...
3743505_3
public Entry createFolder(String path) throws DropboxException { assertAuthenticated(); String[] params = {"root", session.getAccessType().toString(), "path", path, "locale", session.getLocale().toString()}; @SuppressWarnings("unchecked") Map<String, Object>...
3743505_4
public Entry metadata(String path, int fileLimit, String hash, boolean list, String rev) throws DropboxException { assertAuthenticated(); if (fileLimit <= 0) { fileLimit = METADATA_DEFAULT_LIMIT; } String[] params = { "file_limit", String.valueOf(fileLimit), "hash...
3743505_5
public Entry metadata(String path, int fileLimit, String hash, boolean list, String rev) throws DropboxException { assertAuthenticated(); if (fileLimit <= 0) { fileLimit = METADATA_DEFAULT_LIMIT; } String[] params = { "file_limit", String.valueOf(fileLimit), "hash...
3743505_6
public Entry putFile(String path, InputStream is, long length, String parentRev, ProgressListener listener) throws DropboxException { UploadRequest request = putFileRequest(path, is, length, parentRev, listener); return request.upload(); }
3743505_7
public DropboxFileInfo getFile(String path, String rev, OutputStream os, ProgressListener listener) throws DropboxException { DropboxInputStream dis = getFileStream(path, rev); dis.copyStreamToOutput(os, listener); return dis.getFileInfo(); }
3743505_8
public DropboxFileInfo getThumbnail(String path, OutputStream os, ThumbSize size, ThumbFormat format, ProgressListener listener) throws DropboxException { DropboxInputStream thumb = getThumbnailStream(path, size, format); thumb.copyStreamToOutput(os, listener); return thumb.getFileInfo(); }
3743505_9
public DropboxInputStream getThumbnailStream(String path, ThumbSize size, ThumbFormat format) throws DropboxException { assertAuthenticated(); String target = "/thumbnails/" + session.getAccessType() + path; String[] params = {"size", size.toAPISize(), "format", format.toStrin...
3744706_0
@Override public void inspect(WarMachine war, PathRepo paths) { logger.info("ServletInspector started"); addServlets(war, paths); addJSPandStaticFiles(war, paths); logger.info("ServletInspector finished"); }
3744706_1
public InputStream getResourceAsStream(String name) throws IOException { if (name.startsWith("classpath:")) return openClasspathResource(name); else if (name.startsWith("file:")) return openFileResource(name); else return openWarResource(name); }
3744706_2
public InputStream getResourceAsStream(String name) throws IOException { if (name.startsWith("classpath:")) return openClasspathResource(name); else if (name.startsWith("file:")) return openFileResource(name); else return openWarResource(name); }
3744706_3
public InputStream getResourceAsStream(String name) throws IOException { if (name.startsWith("classpath:")) return openClasspathResource(name); else if (name.startsWith("file:")) return openFileResource(name); else return openWarResource(name); }
3744706_4
public InputStream getResourceAsStream(String name) throws IOException { if (name.startsWith("classpath:")) return openClasspathResource(name); else if (name.startsWith("file:")) return openFileResource(name); else return openWarResource(name); }
3744706_5
public InputStream getResourceAsStream(String name) throws IOException { if (name.startsWith("classpath:")) return openClasspathResource(name); else if (name.startsWith("file:")) return openFileResource(name); else return openWarResource(name); }
3744706_6
public InputStream getResourceAsStream(String name) throws IOException { if (name.startsWith("classpath:")) return openClasspathResource(name); else if (name.startsWith("file:")) return openFileResource(name); else return openWarResource(name); }
3744706_7
public InputStream getResourceAsStream(String name) throws IOException { if (name.startsWith("classpath:")) return openClasspathResource(name); else if (name.startsWith("file:")) return openFileResource(name); else return openWarResource(name); }
3744706_8
public InputStream getResourceAsStream(String name) throws IOException { if (name.startsWith("classpath:")) return openClasspathResource(name); else if (name.startsWith("file:")) return openFileResource(name); else return openWarResource(name); }
3744706_9
public InputStream getResourceAsStream(String name) throws IOException { if (name.startsWith("classpath:")) return openClasspathResource(name); else if (name.startsWith("file:")) return openFileResource(name); else return openWarResource(name); }
3748867_0
@SuppressWarnings("unchecked") public G readGraph() throws GraphIOException { try { // Initialize if not already. init(); while (xmlEventReader.hasNext()) { XMLEvent event = xmlEventReader.nextEvent(); if (event.isStartElement()) { StartElement element...
3748867_1
@SuppressWarnings("unchecked") public G readGraph() throws GraphIOException { try { // Initialize if not already. init(); while (xmlEventReader.hasNext()) { XMLEvent event = xmlEventReader.nextEvent(); if (event.isStartElement()) { StartElement element...
3748867_2
@SuppressWarnings("unchecked") public G readGraph() throws GraphIOException { try { // Initialize if not already. init(); while (xmlEventReader.hasNext()) { XMLEvent event = xmlEventReader.nextEvent(); if (event.isStartElement()) { StartElement element...
3748867_3
public GraphMLDocument getGraphMLDocument() { return document; }
3748867_4
@SuppressWarnings("unchecked") public G readGraph() throws GraphIOException { try { // Initialize if not already. init(); while (xmlEventReader.hasNext()) { XMLEvent event = xmlEventReader.nextEvent(); if (event.isStartElement()) { StartElement element...
3750999_0
public UserProfile fetchUserProfile(Xing xing) { XingProfile profile = xing.profileOperations().getUserProfile(); return new UserProfileBuilder() .setName(profile.getFirstName() + " " + profile.getLastName()) .setEmail(profile.getActiveEmail()).build(); }
3750999_1
public List<XingProfile> getConnections() { XingConnections connections = restOperations.getForObject(buildUrl(CONNECTIONS_URL), XingConnections.class,"me"); return connections.getContacts().getUsers(); }
3750999_2
public List<XingProfile> getConnections() { XingConnections connections = restOperations.getForObject(buildUrl(CONNECTIONS_URL), XingConnections.class,"me"); return connections.getContacts().getUsers(); }
3750999_3
public XingProfile getUserProfile() { return getProfileById("me"); }
3750999_4
public XingProfile getUserProfile() { return getProfileById("me"); }
3750999_5
public String getProfileId() { return getUserProfile().getId(); }
3756907_0
public BackoffSleeper(long minWait, long maxWait, double backoffMultiplier) { if (minWait <= 0) { throw new IllegalArgumentException("Minimum wait must be at least 1 ms"); } if (maxWait <= minWait) { throw new IllegalArgumentException("Maximum wait must be greater than minimum wait")...
3756907_1
@Override public void reset() { Collection<MockSQSQueue> mockSQSQueues = buildSetOfAllMockQueues(); for (MockSQSQueue mockSQSQueue : mockSQSQueues) { mockSQSQueue.reset(); } }
3756907_2
@Override public void reset() { _mockSQSConnector.reset(); }
3765814_0
public static <T> T getAnyElement(List<Object> anies, Class<T> classType) { for (Object any : anies) { LOG.debug("Class: " + any.getClass()); if (any instanceof Element) { Element element = (Element) any; try { JAXBContext jc = JAXBContext.newInstance(ObjectFa...
3765814_1
public static <T> T getOtherAttribute(Map<QName, String> otherAttributes, String attributeName) { T otherAttribute = null; for (QName qname : otherAttributes.keySet()) { String value = otherAttributes.get(qname); String key = qname.getLocalPart(); LOG.debug("Attribute: " + key + " : " + ...
376975_10
public static boolean equals(String text1, String text2) { if (text1 == null) { return (text2 == null); } return text1.equals(text2); }
376975_11
public static boolean endsWithIgnoreCase(String source, String suffix) { if (isEmpty(suffix)) { return true; } if (isEmpty(source)) { return false; } if (suffix.length() > source.length()) { return false; } return source.substring(source.length() - suffix.length()) .toLowerCase().endsWith(suffix.toLower...
376975_12
public static String substringBefore(String text, char separator) { if (isEmpty(text)) { return text; } int sepPos = text.indexOf(separator); if (sepPos < 0) { return text; } return text.substring(0, sepPos); }
376975_13
public static String substringBeforeLast(String text, char separator) { if (isEmpty(text)) { return text; } int cPos = text.lastIndexOf(separator); if (cPos < 0) { return text; } return text.substring(0, cPos); }
376975_14
public static String substringAfter(String text, char c) { if (isEmpty(text)) { return text; } int cPos = text.indexOf(c); if (cPos < 0) { return ""; } return text.substring(cPos + 1); }
376975_15
public static String substringAfterLast(String text, char separator) { if (isEmpty(text)) { return text; } int cPos = text.lastIndexOf(separator); if (cPos < 0) { return ""; } return text.substring(cPos + 1); }
376975_16
public static String toString(Object... keyValues) { StringBuilder result = new StringBuilder(); result.append('['); for (int i = 0; i < keyValues.length; i += 2) { if (i > 0) { result.append(", "); } result.append(keyValues[i]); result.append(": "); Object value = null; if ((i + 1) < keyValues.length...
376975_17
public static int hashCode(String... values) { int result = 31; for (int i = 0; i < values.length; i++) { result ^= String.valueOf(values[i]).hashCode(); } return result; }
376975_18
public static String collapsePathDots(String path) { String[] stringParts = path.split("/"); List<String> parts = new ArrayList<String>(Arrays.asList(stringParts)); for (int i = 0; i < parts.size() - 1; i++) { String currentDir = parts.get(i); if (currentDir.length() == 0 || currentDir.equals(".")) { parts.re...
376975_19
public static boolean isEmpty(Collection<?> collection) { return collection == null || collection.isEmpty(); }
376975_20
public static boolean isEmpty(Collection<?> collection) { return collection == null || collection.isEmpty(); }
376975_21
public static boolean isEmpty(Collection<?> collection) { return collection == null || collection.isEmpty(); }
376975_22
public static byte[] toByteArray(Reader in, String encoding) throws IOException { StringWriter out = new StringWriter(); copy(in, out); out.flush(); return out.toString().getBytes(encoding); }
376975_23
public static byte[] toByteArray(Reader in, String encoding) throws IOException { StringWriter out = new StringWriter(); copy(in, out); out.flush(); return out.toString().getBytes(encoding); }
376975_24
protected static int calcNewNrReadSize(int nrRead, int totalNrNread) { if (totalNrNread < 0) { return totalNrNread; } if (totalNrNread > (Integer.MAX_VALUE - nrRead)) { return -1; } else { return (totalNrNread + nrRead); } }
376975_25
public static Resources loadResources(ZipFile zipFile, String defaultHtmlEncoding, List<MediaType> lazyLoadedTypes) throws IOException { Resources result = new Resources(); Enumeration<? extends ZipEntry> entries = zipFile.entries(); while( entries.hasMoreElements() ) { ZipEntry zipEnt...
376975_26
public static Resources loadResources(ZipFile zipFile, String defaultHtmlEncoding, List<MediaType> lazyLoadedTypes) throws IOException { Resources result = new Resources(); Enumeration<? extends ZipEntry> entries = zipFile.entries(); while( entries.hasMoreElements() ) { ZipEntry zipEnt...
376975_27
public static Resources loadResources(ZipFile zipFile, String defaultHtmlEncoding, List<MediaType> lazyLoadedTypes) throws IOException { Resources result = new Resources(); Enumeration<? extends ZipEntry> entries = zipFile.entries(); while( entries.hasMoreElements() ) { ZipEntry zipEnt...
376975_28
public static Resources loadResources(ZipFile zipFile, String defaultHtmlEncoding, List<MediaType> lazyLoadedTypes) throws IOException { Resources result = new Resources(); Enumeration<? extends ZipEntry> entries = zipFile.entries(); while( entries.hasMoreElements() ) { ZipEntry zipEnt...
376975_29
public static Resources loadResources(ZipFile zipFile, String defaultHtmlEncoding, List<MediaType> lazyLoadedTypes) throws IOException { Resources result = new Resources(); Enumeration<? extends ZipEntry> entries = zipFile.entries(); while( entries.hasMoreElements() ) { ZipEntry zipEnt...
376975_30
public static Resources loadResources(ZipFile zipFile, String defaultHtmlEncoding, List<MediaType> lazyLoadedTypes) throws IOException { Resources result = new Resources(); Enumeration<? extends ZipEntry> entries = zipFile.entries(); while( entries.hasMoreElements() ) { ZipEntry zipEnt...
376975_31
public void write(Book book, OutputStream out) throws IOException { book = processBook(book); ZipOutputStream resultStream = new ZipOutputStream(out); writeMimeType(resultStream); writeContainer(resultStream); initTOCResource(book); writeResources(book, resultStream); writePackageDocument(book, resultStream); r...
376975_32
public static Resource read(Book book, EpubReader epubReader) { Resource ncxResource = null; if(book.getSpine().getTocResource() == null) { log.error("Book does not contain a table of contents file"); return ncxResource; } try { ncxResource = book.getSpine().getTocResource(); if(ncxResource == null) { re...
376975_33
public static Metadata readMetadata(Document packageDocument) { Metadata result = new Metadata(); Element metadataElement = DOMUtil.getFirstElementByTagNameNS(packageDocument.getDocumentElement(), NAMESPACE_OPF, OPFTags.metadata); if(metadataElement == null) { log.error("Package does not contain element " + OPFTag...
376975_34
public static Metadata readMetadata(Document packageDocument) { Metadata result = new Metadata(); Element metadataElement = DOMUtil.getFirstElementByTagNameNS(packageDocument.getDocumentElement(), NAMESPACE_OPF, OPFTags.metadata); if(metadataElement == null) { log.error("Package does not contain element " + OPFTag...
376975_35
static Set<String> findCoverHrefs(Document packageDocument) { Set<String> result = new HashSet<String>(); // try and find a meta tag with name = 'cover' and a non-blank id String coverResourceId = DOMUtil.getFindAttributeValue(packageDocument, NAMESPACE_OPF, OPFTags.meta, OPFAttributes.name, OPFValues....
376975_36
static Resource findTableOfContentsResource(String tocResourceId, Resources resources) { Resource tocResource = null; if (StringUtil.isNotBlank(tocResourceId)) { tocResource = resources.getByIdOrHref(tocResourceId); } if (tocResource != null) { return tocResource; } // get the first resource with the NCX ...
376975_37
static Resource findTableOfContentsResource(String tocResourceId, Resources resources) { Resource tocResource = null; if (StringUtil.isNotBlank(tocResourceId)) { tocResource = resources.getByIdOrHref(tocResourceId); } if (tocResource != null) { return tocResource; } // get the first resource with the NCX ...
376975_38
static Resource findTableOfContentsResource(String tocResourceId, Resources resources) { Resource tocResource = null; if (StringUtil.isNotBlank(tocResourceId)) { tocResource = resources.getByIdOrHref(tocResourceId); } if (tocResource != null) { return tocResource; } // get the first resource with the NCX ...
376975_39
static Resource findTableOfContentsResource(String tocResourceId, Resources resources) { Resource tocResource = null; if (StringUtil.isNotBlank(tocResourceId)) { tocResource = resources.getByIdOrHref(tocResourceId); } if (tocResource != null) { return tocResource; } // get the first resource with the NCX ...