code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
public static boolean useSequenceForOrderNumber(WorkspaceEntry wsConfig, String dbDialect) throws RepositoryConfigurationException
{
try
{
if (wsConfig.getContainer().getParameterValue(JDBCWorkspaceDataContainer.USE_SEQUENCE_FOR_ORDER_NUMBER, JDBCWorkspaceDataContainer.USE_SEQUENCE_AUTO).equalsI... | java |
SessionImpl createSession(ConversationState user) throws RepositoryException, LoginException
{
if (IdentityConstants.SYSTEM.equals(user.getIdentity().getUserId()))
{
// Need privileges to get system session.
SecurityManager security = System.getSecurityManager();
if (security !... | java |
@Override
public synchronized void retain() throws RepositoryException
{
try
{
if (!isRetainable())
throw new RepositoryException("Unsupported configuration place "
+ configurationService.getURL(param.getValue())
+ " If you want to save configuration... | java |
protected void doRestore(File backupFile) throws BackupException
{
if (!PrivilegedFileHelper.exists(backupFile))
{
LOG.warn("Nothing to restore for quotas");
return;
}
ZipObjectReader in = null;
try
{
in = new ZipObjectReader(PrivilegedFileHelper.zipInp... | java |
private void repairDataSize()
{
try
{
long dataSize = quotaPersister.getWorkspaceDataSize(rName, wsName);
ChangesItem changesItem = new ChangesItem();
changesItem.updateWorkspaceChangedSize(dataSize);
quotaPersister.setWorkspaceDataSize(rName, wsName, 0); // workarou... | java |
protected void doBackup(File backupFile) throws BackupException
{
ZipObjectWriter out = null;
try
{
out = new ZipObjectWriter(PrivilegedFileHelper.zipOutputStream(backupFile));
quotaPersister.backupWorkspaceData(rName, wsName, out);
}
catch (IOException e)
{
... | java |
private void importResource(Node parentNode, InputStream file_in, String resourceType, ArtifactDescriptor artifact)
throws RepositoryException
{
// Note that artifactBean been initialized within constructor
// resourceType can be jar, pom, metadata
String filename;
if (resourceTy... | java |
private IndexInfos createIndexInfos(Boolean system, IndexerIoModeHandler modeHandler, QueryHandlerEntry config,
QueryHandler handler) throws RepositoryConfigurationException
{
try
{
// read RSYNC configuration
RSyncConfiguration rSyncConfiguration = new RSyncConfiguration(config);... | java |
@Managed
@ManagedDescription("The number of active locks")
public int getNumLocks()
{
try
{
return getNumLocks.run();
}
catch (LockException e)
{
if (LOG.isTraceEnabled())
{
LOG.trace("An exception occurred: " + e.getMessage());
}
... | java |
protected boolean hasLocks()
{
try
{
return hasLocks.run();
}
catch (LockException e)
{
if (LOG.isTraceEnabled())
{
LOG.trace("An exception occurred: " + e.getMessage());
}
}
return true;
} | java |
public boolean isLockLive(String nodeId) throws LockException
{
try
{
return isLockLive.run(nodeId);
}
catch (LockException e)
{
if (LOG.isTraceEnabled())
{
LOG.trace("An exception occurred: " + e.getMessage());
}
}
return fals... | java |
protected LockData getLockDataById(String nodeId)
{
try
{
return getLockDataById.run(nodeId);
}
catch (LockException e)
{
if (LOG.isTraceEnabled())
{
LOG.trace("An exception occurred: " + e.getMessage());
}
}
return null;
} | java |
protected synchronized List<LockData> getLockList()
{
try
{
return getLockList.run();
}
catch (LockException e)
{
if (LOG.isTraceEnabled())
{
LOG.trace("An exception occurred: " + e.getMessage());
}
}
return null;
} | java |
public SessionLockManager getSessionLockManager(String sessionId, SessionDataManager transientManager)
{
CacheableSessionLockManager sessionManager = new CacheableSessionLockManager(sessionId, this, transientManager);
sessionLockManagers.put(sessionId, sessionManager);
return sessionManager;
} | java |
public synchronized void removeExpired()
{
final List<String> removeLockList = new ArrayList<String>();
for (LockData lock : getLockList())
{
if (!lock.isSessionScoped() && lock.getTimeToDeath() < 0)
{
removeLockList.add(lock.getNodeIdentifier());
}
}
... | java |
protected void removeLock(String nodeIdentifier)
{
try
{
NodeData nData = (NodeData)dataManager.getItemData(nodeIdentifier);
//Skip removing, because that node was removed in other node of cluster.
if (nData == null)
{
return;
}
PlainC... | java |
protected void removeAll()
{
List<LockData> locks = getLockList();
for (LockData lockData : locks)
{
removeLock(lockData.getNodeIdentifier());
}
} | java |
public static byte[] getAsByteArray(TransactionChangesLog dataChangesLog) throws IOException
{
ByteArrayOutputStream os = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(os);
oos.writeObject(dataChangesLog);
byte[] bArray = os.toByteArray();
return bArray;
... | java |
public static TransactionChangesLog getAsItemDataChangesLog(byte[] byteArray) throws IOException,
ClassNotFoundException
{
ByteArrayInputStream is = new ByteArrayInputStream(byteArray);
ObjectInputStream ois = new ObjectInputStream(is);
TransactionChangesLog objRead = (TransactionChangesLog)o... | java |
public PlainChangesLog read(ObjectReader in) throws UnknownClassIdException, IOException
{
int key;
if ((key = in.readInt()) != SerializationConstants.PLAIN_CHANGES_LOG_IMPL)
{
throw new UnknownClassIdException("There is unexpected class [" + key + "]");
}
int eventType ... | java |
public void write(ObjectWriter out, PlainChangesLog pcl) throws IOException
{
// write id
out.writeInt(SerializationConstants.PLAIN_CHANGES_LOG_IMPL);
out.writeInt(pcl.getEventType());
out.writeString(pcl.getSessionId());
List<ItemState> list = pcl.getAllStates();
int... | java |
private ExtendedNode getUsersStorageNode() throws RepositoryException
{
Session session = service.getStorageSession();
try
{
return (ExtendedNode)utils.getUsersStorageNode(service.getStorageSession());
}
finally
{
session.logout();
}
} | java |
protected void closeStatements()
{
try
{
if (findItemById != null)
{
findItemById.close();
}
if (findItemByPath != null)
{
findItemByPath.close();
}
if (findItemByName != null)
{
findItemByName.c... | java |
public List<NodeDataIndexing> getNodesAndProperties(String lastNodeId, int offset, int limit)
throws RepositoryException, IllegalStateException
{
List<NodeDataIndexing> result = new ArrayList<NodeDataIndexing>();
checkIfOpened();
try
{
startTxIfNeeded();
ResultSet res... | java |
public long getNodesCount() throws RepositoryException
{
try
{
ResultSet countNodes = findNodesCount();
try
{
if (countNodes.next())
{
return countNodes.getLong(1);
}
else
{
throw new SQLE... | java |
public long getWorkspaceDataSize() throws RepositoryException
{
long dataSize = 0;
ResultSet result = null;
try
{
result = findWorkspaceDataSize();
try
{
if (result.next())
{
dataSize += result.getLong(1);
}
... | java |
public long getNodeDataSize(String nodeIdentifier) throws RepositoryException
{
long dataSize = 0;
ResultSet result = null;
try
{
result = findNodeDataSize(getInternalId(nodeIdentifier));
try
{
if (result.next())
{
dataSize +=... | java |
protected ItemData getItemByIdentifier(String cid) throws RepositoryException, IllegalStateException
{
checkIfOpened();
try
{
ResultSet item = findItemByIdentifier(cid);
try
{
if (item.next())
{
return itemData(null, item, item.getIn... | java |
protected ItemData getItemByName(NodeData parent, String parentId, QPathEntry name, ItemType itemType)
throws RepositoryException, IllegalStateException
{
checkIfOpened();
try
{
ResultSet item = null;
try
{
item = findItemByName(parentId, name.getAsStrin... | java |
private ItemData itemData(QPath parentPath, ResultSet item, int itemClass, AccessControlList parentACL)
throws RepositoryException, SQLException, IOException
{
String cid = item.getString(COLUMN_ID);
String cname = item.getString(COLUMN_NAME);
int cversion = item.getInt(COLUMN_VERSION);
... | java |
protected MixinInfo readMixins(String cid) throws SQLException, IllegalNameException
{
ResultSet mtrs = findPropertyByName(cid, Constants.JCR_MIXINTYPES.getAsString());
try
{
List<InternalQName> mts = null;
boolean owneable = false;
boolean privilegeable = false;
... | java |
protected PersistedPropertyData loadPropertyRecord(QPath parentPath, String cname, String cid, String cpid,
int cversion, int cptype, boolean cpmultivalued) throws RepositoryException, SQLException, IOException
{
// NOTE: cpid never should be null or root parent (' ')
try
{
QPath q... | java |
private void deleteValues(String cid, PropertyData pdata, boolean update, ChangedSizeHandler sizeHandler)
throws IOException, SQLException, RepositoryException, InvalidItemStateException
{
Set<String> storages = new HashSet<String>();
final ResultSet valueRecords = findValueStorageDescAndSize(cid)... | java |
private List<ValueDataWrapper> readValues(String cid, int cptype, String identifier, int cversion)
throws IOException, SQLException, ValueStorageNotFoundException
{
List<ValueDataWrapper> data = new ArrayList<ValueDataWrapper>();
final ResultSet valueRecords = findValuesByPropertyId(cid);
tr... | java |
protected ValueDataWrapper readValueData(String identifier, int orderNumber, int type, String storageId)
throws SQLException, IOException, ValueStorageNotFoundException
{
ValueIOChannel channel = this.containerConfig.valueStorageProvider.getChannel(storageId);
try
{
return channel.re... | java |
public IndexerIoModeHandler getModeHandler()
{
if (modeHandler == null)
{
if (ctx.getCache().getStatus() != ComponentStatus.RUNNING)
{
throw new IllegalStateException("The cache should be started first");
}
synchronized (this)
{
if (mo... | java |
@SuppressWarnings("rawtypes")
protected void doPushState()
{
final boolean debugEnabled = LOG.isDebugEnabled();
if (debugEnabled)
{
LOG.debug("start pushing in-memory state to cache cacheLoader collection");
}
Map<String, ChangesFilterListsWrapper> changesMap = new HashMap... | java |
public static String getStatusDescription(int status)
{
String description = "";
Integer statusKey = new Integer(status);
if (statusDescriptions.containsKey(statusKey))
{
description = statusDescriptions.get(statusKey);
}
return String.format("%s %d %s", WebDavConst.HTT... | java |
private void spoolContent(InputStream is) throws IOException, FileNotFoundException
{
SwapFile swapFile =
SwapFile.get(spoolConfig.tempDirectory, System.currentTimeMillis() + "_" + SEQUENCE.incrementAndGet(),
spoolConfig.fileCleaner);
try
{
OutputStream os = Privileged... | java |
public MatchResult match(QPath input)
{
try
{
return match(new Context(input)).getMatchResult();
}
catch (RepositoryException e)
{
throw (IllegalArgumentException)new IllegalArgumentException("QPath not normalized").initCause(e);
}
} | java |
private void addPathsWithUnknownChangedSize(ChangesItem changesItem, ItemState state)
{
if (!state.isPersisted() && (state.isDeleted() || state.isRenamed()))
{
String itemPath = getPath(state.getData().getQPath());
for (String trackedPath : quotaPersister.getAllTrackedNodes(rName, wsNa... | java |
private void behaveWhenQuotaExceeded(String message) throws ExceededQuotaLimitException
{
switch (exceededQuotaBehavior)
{
case EXCEPTION :
throw new ExceededQuotaLimitException(message);
case WARNING :
LOG.warn(message);
break;
}
} | java |
protected void pushChangesToCoordinator(ChangesItem changesItem) throws SecurityException, RPCException
{
if (!changesItem.isEmpty())
{
rpcService.executeCommandOnCoordinator(applyPersistedChangesTask, true, changesItem);
}
} | java |
private String getPath(QPath path)
{
try
{
return lFactory.createJCRPath(path).getAsString(false);
}
catch (RepositoryException e)
{
throw new IllegalStateException(e.getMessage(), e);
}
} | java |
private Serializable executeCommand(RemoteCommand command, Serializable... args) throws RPCException
{
try
{
return command.execute(args);
}
catch (Throwable e)//NOSONAR
{
throw new RPCException(e.getMessage(), e);
}
} | java |
public ItemState read(ObjectReader in) throws UnknownClassIdException, IOException
{
// read id
int key;
if ((key = in.readInt()) != SerializationConstants.ITEM_STATE)
{
throw new UnknownClassIdException("There is unexpected class [" + key + "]");
}
ItemState is... | java |
public Response search(Session session, HierarchicalProperty body, String baseURI)
{
try
{
SearchRequestEntity requestEntity = new SearchRequestEntity(body);
Query query =
session.getWorkspace().getQueryManager().createQuery(requestEntity.getQuery(),
... | java |
public int getDoc(IndexReader reader) throws IOException {
if (doc == -1) {
TermDocs docs = reader.termDocs(new Term(FieldNames.UUID, id.toString()));
try {
if (docs.next()) {
return docs.doc();
} else {
throw new IO... | java |
private String[] safeListToArray(List<String> v)
{
return v != null ? v.toArray(new String[v.size()]) : new String[0];
} | java |
public void removeWorkspaceIndex(WorkspaceEntry wsConfig, boolean isSystem) throws RepositoryConfigurationException,
IOException
{
String indexDirName = wsConfig.getQueryHandler().getParameterValue(QueryHandlerParams.PARAM_INDEX_DIR);
File indexDir = new File(indexDirName);
if (P... | java |
public PlainChangesLog pushLog(QPath rootPath)
{
// session instance is always present in SessionChangesLog
PlainChangesLog cLog = new PlainChangesLogImpl(getDescendantsChanges(rootPath), session);
if (rootPath.equals(Constants.ROOT_PATH))
{
clear();
}
else
{
... | java |
protected void doRestore() throws Throwable
{
PlainChangesLog changes = read();
TransactionChangesLog tLog = new TransactionChangesLog(changes);
tLog.setSystemId(Constants.JCR_CORE_RESTORE_WORKSPACE_INITIALIZER_SYSTEM_ID); // mark changes
dataManager.save(tLog);
} | java |
private String removeAsterisk(String str)
{
if (str.startsWith("*"))
{
str = str.substring(1);
}
if (str.endsWith("*"))
{
str = str.substring(0, str.length() - 1);
}
return str;
} | java |
public Set<VersionResource> getVersions() throws RepositoryException, IllegalResourceTypeException
{
Set<VersionResource> resources = new HashSet<VersionResource>();
VersionIterator versions = versionHistory.getAllVersions();
while (versions.hasNext())
{
Version version = versi... | java |
public VersionResource getVersion(String name) throws RepositoryException, IllegalResourceTypeException
{
return new VersionResource(versionURI(name), versionedResource, versionHistory.getVersion(name), namespaceContext);
} | java |
protected final URI versionURI(String versionName)
{
return URI.create(versionedResource.getIdentifier().toASCIIString() + "?version=" + versionName);
} | java |
protected String buildPathX8(String fileName)
{
final int xLength = 8;
char[] chs = fileName.toCharArray();
StringBuilder path = new StringBuilder();
for (int i = 0; i < xLength; i++)
{
path.append(File.separator).append(chs[i]);
}
path.append(fileName.subs... | java |
private void load() throws IOException
{
if (PrivilegedFileHelper.exists(storage))
{
InputStream in = PrivilegedFileHelper.fileInputStream(storage);
try
{
Properties props = new Properties();
log.debug("loading namespace mappings...");
props.... | java |
private void store() throws IOException
{
Properties props = new Properties();
// store mappings in properties
Iterator<String> iter = prefixToURI.keySet().iterator();
while (iter.hasNext())
{
String prefix = iter.next();
String uri = prefixToURI.get(prefix);
... | java |
public static RegistryEntry parse(final byte[] bytes) throws IOException, SAXException, ParserConfigurationException
{
try
{
return SecurityHelper.doPrivilegedExceptionAction(new PrivilegedExceptionAction<RegistryEntry>()
{
public RegistryEntry run() throws Exception
... | java |
public void addClassTag (String tag, Class type) {
tagToClass.put(tag, type);
classToTag.put(type, tag);
} | java |
public <T> void setSerializer (Class<T> type, JsonSerializer<T> serializer) {
classToSerializer.put(type, serializer);
} | java |
public void setElementType (Class type, String fieldName, Class elementType) {
ObjectMap<String, FieldMetadata> fields = getFields(type);
FieldMetadata metadata = fields.get(fieldName);
if (metadata == null) throw new JsonException("Field not found: " + fieldName + " (" + type.getName() + ")");
metadata.ele... | java |
public void setWriter (Writer writer) {
if (!(writer instanceof JsonWriter)) writer = new JsonWriter(writer);
this.writer = (JsonWriter)writer;
this.writer.setOutputType(outputType);
this.writer.setQuoteLongValues(quoteLongValues);
} | java |
public void writeFields (Object object) {
Class type = object.getClass();
Object[] defaultValues = getDefaultValues(type);
OrderedMap<String, FieldMetadata> fields = getFields(type);
int i = 0;
for (FieldMetadata metadata : new OrderedMapValues<FieldMetadata>(fields)) {
Field field = metadata.fie... | java |
public void writeField (Object object, String fieldName, String jsonName, Class elementType) {
Class type = object.getClass();
ObjectMap<String, FieldMetadata> fields = getFields(type);
FieldMetadata metadata = fields.get(fieldName);
if (metadata == null) throw new JsonException("Field not found: " + fieldN... | java |
public void writeValue (String name, Object value) {
try {
writer.name(name);
} catch (IOException ex) {
throw new JsonException(ex);
}
if (value == null)
writeValue(value, null, null);
else
writeValue(value, value.getClass(), null);
} | java |
public void writeValue (String name, Object value, Class knownType) {
try {
writer.name(name);
} catch (IOException ex) {
throw new JsonException(ex);
}
writeValue(value, knownType, null);
} | java |
public void writeValue (Object value) {
if (value == null)
writeValue(value, null, null);
else
writeValue(value, value.getClass(), null);
} | java |
boolean detectLongRunningJob(long currentTime, Job job) {
if(job.status() == JobStatus.RUNNING && !longRunningJobs.containsKey(job)) {
int jobExecutionsCount = job.executionsCount();
Long jobStartedtimeInMillis = job.lastExecutionStartedTimeInMillis();
Thread threadRunningJob = job.threadRunningJob();
if... | java |
public Job schedule(Runnable runnable, Schedule when) {
return schedule(null, runnable, when);
} | java |
public Optional<Job> findJob(String name) {
return Optional.ofNullable(indexedJobsByName.get(name));
} | java |
@SneakyThrows
public void gracefullyShutdown(Duration timeout) {
logger.info("Shutting down...");
if(!shuttingDown) {
synchronized (this) {
shuttingDown = true;
threadPoolExecutor.shutdown();
}
// stops jobs that have not yet started to be executed
for(Job job : jobStatus()) {
Runnable ru... | java |
@SneakyThrows
private void launcher() {
while(!shuttingDown) {
Long timeBeforeNextExecution = null;
synchronized (this) {
if(nextExecutionsOrder.size() > 0) {
timeBeforeNextExecution = nextExecutionsOrder.get(0).nextExecutionTimeInMillis()
- timeProvider.currentTime();
}
}
if(timeBefo... | java |
private void runJob(Job jobToRun) {
long startExecutionTime = timeProvider.currentTime();
long timeBeforeNextExecution = jobToRun.nextExecutionTimeInMillis() - startExecutionTime;
if(timeBeforeNextExecution < 0) {
logger.debug("Job '{}' execution is {}ms late", jobToRun.name(), -timeBeforeNextExecution);
}
... | java |
private HttpURLConnection configureURLConnection(HttpMethod method, String urlString, Map<String, String> httpHeaders, int contentLength) throws IOException {
preconditionNotNull(method, "method cannot be null");
preconditionNotNull(urlString, "urlString cannot be null");
preconditionNotNull(ht... | java |
String getResponseEncoding(URLConnection connection) {
String charset = null;
String contentType = connection.getHeaderField("Content-Type");
if (contentType != null) {
for (String param : contentType.replace(" ", "").split(";")) {
if (param.startsWith("charset=")) ... | java |
public static PDFont mapDefaultFonts(Font font) {
/*
* Map default font names to the matching families.
*/
if (fontNameEqualsAnyOf(font, Font.SANS_SERIF, Font.DIALOG, Font.DIALOG_INPUT, "Arial", "Helvetica"))
return chooseMatchingHelvetica(font);
if (fontNameEqualsAnyOf(font, Font.MONOSPACED, "courier", ... | java |
public static PDFont chooseMatchingTimes(Font font) {
if ((font.getStyle() & (Font.ITALIC | Font.BOLD)) == (Font.ITALIC | Font.BOLD))
return PDType1Font.TIMES_BOLD_ITALIC;
if ((font.getStyle() & Font.ITALIC) == Font.ITALIC)
return PDType1Font.TIMES_ITALIC;
if ((font.getStyle() & Font.BOLD) == Font.BOLD)
... | java |
public static PDFont chooseMatchingCourier(Font font) {
if ((font.getStyle() & (Font.ITALIC | Font.BOLD)) == (Font.ITALIC | Font.BOLD))
return PDType1Font.COURIER_BOLD_OBLIQUE;
if ((font.getStyle() & Font.ITALIC) == Font.ITALIC)
return PDType1Font.COURIER_OBLIQUE;
if ((font.getStyle() & Font.BOLD) == Font.B... | java |
public static PDFont chooseMatchingHelvetica(Font font) {
if ((font.getStyle() & (Font.ITALIC | Font.BOLD)) == (Font.ITALIC | Font.BOLD))
return PDType1Font.HELVETICA_BOLD_OBLIQUE;
if ((font.getStyle() & Font.ITALIC) == Font.ITALIC)
return PDType1Font.HELVETICA_OBLIQUE;
if ((font.getStyle() & Font.BOLD) == ... | java |
@SuppressWarnings("WeakerAccess")
public void registerFont(String fontName, File fontFile) {
if (!fontFile.exists())
throw new IllegalArgumentException("Font " + fontFile + " does not exist!");
FontEntry entry = new FontEntry();
entry.overrideName = fontName;
entry.file = fontFile;
fontFiles.add(entry);
... | java |
@SuppressWarnings("WeakerAccess")
public void registerFont(String name, PDFont font) {
fontMap.put(name, font);
} | java |
@SuppressWarnings("WeakerAccess")
protected PDFont mapFont(final Font font, final IFontTextDrawerEnv env) throws IOException, FontFormatException {
/*
* If we have any font registering's, we must perform them now
*/
for (final FontEntry fontEntry : fontFiles) {
if (fontEntry.overrideName == null) {
Fo... | java |
public float getPixelSize() {
if (mVectorState == null && mVectorState.mVPathRenderer == null ||
mVectorState.mVPathRenderer.mBaseWidth == 0 ||
mVectorState.mVPathRenderer.mBaseHeight == 0 ||
mVectorState.mVPathRenderer.mViewportHeight == 0 ||
mVectorState.mVPathRenderer.mViewportWid... | java |
@RequestMapping(
path = "/api",
method = RequestMethod.GET,
produces = {"application/hal+json", "application/json"}
)
public HalRepresentation getHomeDocument(final HttpServletRequest request) {
final String homeUrl = request.getRequestURL().toString();
return... | java |
public static Builder copyOf(final Link prototype) {
return new Builder(prototype.rel, prototype.href)
.withType(prototype.type)
.withProfile(prototype.profile)
.withTitle(prototype.title)
.withName(prototype.name)
.withDeprecation(... | java |
public static Embedded embedded(final String rel,
final HalRepresentation embeddedItem) {
return new Embedded(singletonMap(rel, embeddedItem));
} | java |
public static Embedded embedded(final String rel,
final List<? extends HalRepresentation> embeddedRepresentations) {
return new Embedded(singletonMap(rel, new ArrayList<>(embeddedRepresentations)));
} | java |
private int calcLastPage(int total, int pageSize) {
if (total == 0) {
return firstPage;
} else {
final int zeroBasedPageNo = total % pageSize > 0
? total / pageSize
: total / pageSize - 1;
return firstPage + zeroBasedPageNo;
... | java |
private String pageUri(final UriTemplate uriTemplate, final int pageNumber, final int pageSize) {
if (pageSize == MAX_VALUE) {
return uriTemplate.expand();
}
return uriTemplate.set(pageNumberVar(), pageNumber).set(pageSizeVar(), pageSize).expand();
} | java |
@SuppressWarnings("rawtypes")
public Stream<Link> stream() {
return links.values()
.stream()
.map(obj -> {
if (obj instanceof List) {
return (List) obj;
} else {
return singletonList(obj);... | java |
private int calcLastPageSkip(int total, int skip, int limit) {
if (skip > total - limit) {
return skip;
}
if (total % limit > 0) {
return total - total % limit;
}
return total - limit;
} | java |
private String pageUri(final UriTemplate uriTemplate, final int skip, final int limit) {
if (limit == MAX_VALUE) {
return uriTemplate.expand();
}
return uriTemplate.set(skipVar(), skip).set(limitVar(), limit).expand();
} | java |
public List<Product> searchFor(final Optional<String> searchTerm) {
if (searchTerm.isPresent()) {
return products
.stream()
.filter(matchingProductsFor(searchTerm.get()))
.collect(toList());
} else {
return products;
... | java |
HalRepresentation mergeWithEmbedding(final Curies curies) {
this.curies = this.curies.mergeWith(curies);
if (this.links != null) {
removeDuplicateCuriesFromEmbedding(curies);
this.links = this.links.using(this.curies);
if (embedded != null) {
embedde... | java |
public <T extends HalRepresentation> T as(final Class<T> type) throws IOException {
return objectMapper.readValue(json, type);
} | java |
private Optional<JsonNode> findPossiblyCuriedEmbeddedNode(final HalRepresentation halRepresentation,
final JsonNode jsonNode,
final String rel) {
final JsonNode embedded = jsonNode.get("_e... | java |
public void register(final Link curi) {
if (!curi.getRel().equals("curies")) {
throw new IllegalArgumentException("Link must be a CURI");
}
final boolean alreadyRegistered = curies
.stream()
.anyMatch(link -> link.getHref().equals(curi.getHref()));
... | java |
public Curies mergeWith(final Curies other) {
final Curies merged = copyOf(this);
other.curies.forEach(merged::register);
return merged;
} | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.