_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q163400 | FileHelper.updateMetadata | train | public static void updateMetadata(final File file, final PropertyMap map) throws FrameworkException {
updateMetadata(file, map, false);
} | java | {
"resource": ""
} |
q163401 | FileHelper.writeToFile | train | public static void writeToFile(final File fileNode, final InputStream data) throws FrameworkException, IOException {
setFileProperties(fileNode);
try (final FileOutputStream out = new FileOutputStream(fileNode.getFileOnDisk())) {
IOUtils.copy(data, out);
}
} | java | {
"resource": ""
} |
q163402 | FileHelper.getFileByAbsolutePath | train | public static AbstractFile getFileByAbsolutePath(final SecurityContext securityContext, final String absolutePath) {
try {
return StructrApp.getInstance(securityContext).nodeQuery(AbstractFile.class).and(StructrApp.key(AbstractFile.class, "path"), absolutePath).getFirst();
} catch (FrameworkException ex) {
... | java | {
"resource": ""
} |
q163403 | FileHelper.createFolderPath | train | public static Folder createFolderPath(final SecurityContext securityContext, final String path) throws FrameworkException {
final App app = StructrApp.getInstance(securityContext);
if (path == null) {
return null;
}
Folder folder = (Folder) FileHelper.getFileByAbsolutePath(securityContext, path);
if (... | java | {
"resource": ""
} |
q163404 | PlingStemmer.noLatin | train | public static boolean noLatin(String s) {
return(s.indexOf('h')>0 || s.indexOf('j')>0 || s.indexOf('k')>0 ||
s.indexOf('w')>0 || s.indexOf('y')>0 || s.indexOf('z')>0 ||
s.indexOf("ou")>0 || s.indexOf("sh")>0 || s.indexOf("ch")>0 ||
s.endsWith("aus"));
} | java | {
"resource": ""
} |
q163405 | GraphObjectModificationState.updateChangeLog | train | public void updateChangeLog(final Principal user, final Verb verb, final PropertyKey key, final Object previousValue, final Object newValue) {
if ((Settings.ChangelogEnabled.getValue() || Settings.UserChangelogEnabled.getValue()) && key != null) {
final String name = key.jsonName();
if (!hiddenPropertiesInAu... | java | {
"resource": ""
} |
q163406 | GraphObjectModificationState.updateChangeLog | train | public void updateChangeLog(final Principal user, final Verb verb, final String object) {
if ((Settings.ChangelogEnabled.getValue() || Settings.UserChangelogEnabled.getValue())) {
final JsonObject obj = new JsonObject();
obj.add("time", toElement(System.currentTimeMillis()));
if (user != null) {
obj.... | java | {
"resource": ""
} |
q163407 | PropertyConverter.convertForSorting | train | public Comparable convertForSorting(S source) throws FrameworkException {
if(source != null) {
if (source instanceof Comparable) {
return (Comparable)source;
}
// fallback
return source.toString();
}
return null;
} | java | {
"resource": ""
} |
q163408 | ClassFileManager.getClassLoader | train | @Override
public ClassLoader getClassLoader(final Location location) {
return new SecureClassLoader() {
@Override
protected Class<?> findClass(String name) throws ClassNotFoundException {
final JavaClassObject obj = objects.get(name);
if (obj != null) {
byte[] b = obj.getBytes();... | java | {
"resource": ""
} |
q163409 | ClassFileManager.getJavaFileForOutput | train | @Override
public JavaFileObject getJavaFileForOutput(final Location location, final String className, final Kind kind, final FileObject sibling) throws IOException {
JavaClassObject obj = new JavaClassObject(className, kind);
objects.put(className, obj);
return obj;
} | java | {
"resource": ""
} |
q163410 | JobQueueManager.startJob | train | public boolean startJob(final Long jobId) {
final ScheduledJob job = removeFromQueueInternal(jobId);
if (job != null) {
activeJobs.put(jobId, job);
job.startJob();
return true;
} else {
return false;
}
} | java | {
"resource": ""
} |
q163411 | JarConfigurationProvider.getRelationClassCandidatesForRelType | train | private List<Class<? extends RelationshipInterface>> getRelationClassCandidatesForRelType(final String relType) {
List<Class<? extends RelationshipInterface>> candidates = new ArrayList();
for (final Class<? extends RelationshipInterface> candidate : getRelationshipEntities().values()) {
Relation rel = instan... | java | {
"resource": ""
} |
q163412 | JarConfigurationProvider.findNearestMatchingRelationClass | train | private Class findNearestMatchingRelationClass(final String sourceTypeName, final String relType, final String targetTypeName) {
final Class sourceType = getNodeEntityClass(sourceTypeName);
final Class targetType = getNodeEntityClass(targetTypeName);
final Map<Integer, Class> candidat... | java | {
"resource": ""
} |
q163413 | JarConfigurationProvider.registerEntityCreationTransformation | train | @Override
public void registerEntityCreationTransformation(Class type, Transformation<GraphObject> transformation) {
final Set<Transformation<GraphObject>> transformations = getEntityCreationTransformationsForType(type);
if (!transformations.contains(transformation)) {
transformations.add(transformation);
}... | java | {
"resource": ""
} |
q163414 | JarConfigurationProvider.registerPropertyGroup | train | @Override
public void registerPropertyGroup(Class type, PropertyKey key, PropertyGroup propertyGroup) {
getPropertyGroupMapForType(type).put(key.dbName(), propertyGroup);
} | java | {
"resource": ""
} |
q163415 | JarConfigurationProvider.getResourcesToScan | train | private Set<String> getResourcesToScan() {
final String classPath = System.getProperty("java.class.path");
final Set<String> modules = new TreeSet<>();
final Pattern pattern = Pattern.compile(".*(structr).*(war|jar)");
final Matcher matcher = pattern.matcher("");
for (final String jarPath : class... | java | {
"resource": ""
} |
q163416 | DeploymentServlet.unzip | train | private void unzip(final File file, final String outputDir) throws IOException {
try (final ZipFile zipFile = new ZipFile(file)) {
final Enumeration<? extends ZipEntry> entries = zipFile.entries();
while (entries.hasMoreElements()) {
final ZipEntry entry = entries.nextElement();
final File targetFil... | java | {
"resource": ""
} |
q163417 | ResourceHelper.parsePath | train | public static List<Resource> parsePath(final SecurityContext securityContext, final HttpServletRequest request, final Map<Pattern, Class<? extends Resource>> resourceMap, final Value<String> propertyView) throws FrameworkException {
final String path = request.getPathInfo();
// intercept empty path and send 204 N... | java | {
"resource": ""
} |
q163418 | ResourceHelper.optimizeNestedResourceChain | train | public static Resource optimizeNestedResourceChain(final SecurityContext securityContext, final HttpServletRequest request, final Map<Pattern, Class<? extends Resource>> resourceMap, final Value<String> propertyView) throws FrameworkException {
final List<Resource> resourceChain = ResourceHelper.parsePath(securityCo... | java | {
"resource": ""
} |
q163419 | Function.logException | train | protected void logException (final Object caller, final Throwable t, final Object[] parameters) {
logException(t, "{}: Exception in '{}' for parameters: {}", new Object[] { getReplacement(), caller, getParametersAsString(parameters) });
} | java | {
"resource": ""
} |
q163420 | Function.logException | train | protected void logException (final Throwable t, final String msg, final Object[] messageParams) {
logger.error(msg, messageParams, t);
} | java | {
"resource": ""
} |
q163421 | Function.assertArrayHasLengthAndAllElementsNotNull | train | protected void assertArrayHasLengthAndAllElementsNotNull(final Object[] array, final Integer length) throws ArgumentCountException, ArgumentNullException {
if (array.length != length) {
throw ArgumentCountException.notEqual(array.length, length);
}
for (final Object element : array) {
if (element == null... | java | {
"resource": ""
} |
q163422 | GeoHelper.createLocation | train | public static Location createLocation(final GeoCodingResult coords) throws FrameworkException {
final PropertyMap props = new PropertyMap();
double latitude = coords.getLatitude();
double longitude = coords.getLongitude();
String type = Location.class.getSimpleName();
props.put(Ab... | java | {
"resource": ""
} |
q163423 | GeoHelper.geocode | train | public static GeoCodingResult geocode(final String street, final String house, String postalCode, final String city, final String state, final String country) throws FrameworkException {
final String language = Settings.GeocodingLanguage.getValue();
final String cacheKey = cacheKey(street, house, postalCode, cit... | java | {
"resource": ""
} |
q163424 | AuthHelper.isConfirmationKeyValid | train | public static boolean isConfirmationKeyValid(final String confirmationKey, final Integer validityPeriod) {
final String[] parts = confirmationKey.split("!");
if (parts.length == 2) {
final long confirmationKeyCreated = Long.parseLong(parts[1]);
final long maxValidity = confirmationKeyCreated + v... | java | {
"resource": ""
} |
q163425 | CsvServlet.writeCsv | train | public static void writeCsv(final ResultStream<GraphObject> result, final Writer out, final String propertyView) throws IOException {
final StringBuilder row = new StringBuilder();
boolean headerWritten = false;
for (final GraphObject obj : result) {
// Write column headers
if (!headerWritten... | java | {
"resource": ""
} |
q163426 | EntityAndPropertiesContainer.init | train | @Override
public void init(SecurityContext securityContext, Node dbNode, Class type, final long transactionId) {
throw new UnsupportedOperationException("Not supported by this container.");
} | java | {
"resource": ""
} |
q163427 | MailService.extractFileAttachment | train | private File extractFileAttachment(final Mailbox mb, final Part p) {
File file = null;
try {
final Class fileClass = p.getContentType().toLowerCase().startsWith("image/") ? Image.class : File.class;
final App app = StructrApp.getInstance();
try (final Tx tx = app.tx()) {
org.structr.web.entity.Fo... | java | {
"resource": ""
} |
q163428 | Tx.setSecurityContext | train | public void setSecurityContext(final SecurityContext sc) {
if (securityContext == null) {
if (sc.isSuperUserSecurityContext() == Boolean.FALSE) {
securityContext = sc;
}
}
} | java | {
"resource": ""
} |
q163429 | LogResource.findInterval | train | private long findInterval(final String dateFormat) {
final long max = TimeUnit.DAYS.toMillis(365);
final long step = TimeUnit.SECONDS.toMillis(60);
try {
final SimpleDateFormat format = new SimpleDateFormat(dateFormat);
final long initial = format.parse(format.format(3600)).getTime();
for (long i = i... | java | {
"resource": ""
} |
q163430 | SecurityContext.getEffectiveLocale | train | public Locale getEffectiveLocale() {
// Priority 5: Default locale
Locale locale = Locale.getDefault();
boolean userHasLocaleString = false;
if (cachedUser != null) {
// Priority 2: User locale
final String userLocaleString = cachedUser.getLocale();
if (userLocaleString != null) {
userHasLocale... | java | {
"resource": ""
} |
q163431 | Command.setArgument | train | public final void setArgument(final String key, final Object value) {
if (key != null && value != null) {
this.arguments.put(key, value);
}
} | java | {
"resource": ""
} |
q163432 | HashHelper.getHash | train | public static String getHash(final String password, final String salt) {
if (StringUtils.isEmpty(salt)) {
return getSimpleHash(password);
}
return DigestUtils.sha512Hex(DigestUtils.sha512Hex(password).concat(salt));
} | java | {
"resource": ""
} |
q163433 | HtmlServlet.notFound | train | private Page notFound(final HttpServletResponse response, final SecurityContext securityContext) throws IOException, FrameworkException {
final List<Page> errorPages = StructrApp.getInstance(securityContext).nodeQuery(Page.class).and(StructrApp.key(Page.class, "showOnErrorCodes"), "404", false).getAsList();
for (... | java | {
"resource": ""
} |
q163434 | HtmlServlet.findFirstNodeByName | train | private AbstractNode findFirstNodeByName(final SecurityContext securityContext, final HttpServletRequest request, final String path) throws FrameworkException {
final String name = PathHelper.getName(path);
if (!name.isEmpty()) {
logger.debug("Requested name: {}", name);
final Query query ... | java | {
"resource": ""
} |
q163435 | HtmlServlet.findNodeByUuid | train | private AbstractNode findNodeByUuid(final SecurityContext securityContext, final String uuid) throws FrameworkException {
if (!uuid.isEmpty()) {
logger.debug("Requested id: {}", uuid);
return (AbstractNode) StructrApp.getInstance(securityContext).getNodeById(uuid);
}
return null;
} | java | {
"resource": ""
} |
q163436 | HtmlServlet.findFile | train | private File findFile(final SecurityContext securityContext, final HttpServletRequest request, final String path) throws FrameworkException {
List<Linkable> entryPoints = findPossibleEntryPoints(securityContext, request, path);
// If no results were found, try to replace whitespace by '+' or '%20'
if (entryPoin... | java | {
"resource": ""
} |
q163437 | HtmlServlet.findPage | train | private Page findPage(final SecurityContext securityContext, List<Page> pages, final String path, final EditMode edit) throws FrameworkException {
if (pages == null) {
pages = StructrApp.getInstance(securityContext).nodeQuery(Page.class).getAsList();
Collections.sort(pages, new GraphObjectComparator(StructrAp... | java | {
"resource": ""
} |
q163438 | HtmlServlet.findIndexPage | train | private Page findIndexPage(final SecurityContext securityContext, List<Page> pages, final EditMode edit) throws FrameworkException {
final PropertyKey<Integer> positionKey = StructrApp.key(Page.class, "position");
if (pages == null) {
pages = StructrApp.getInstance(securityContext).nodeQuery(Page.class).getAs... | java | {
"resource": ""
} |
q163439 | HtmlServlet.checkRegistration | train | private boolean checkRegistration(final Authenticator auth, final HttpServletRequest request, final HttpServletResponse response, final String path) throws FrameworkException, IOException {
logger.debug("Checking registration ...");
final String key = request.getParameter(CONFIRM_KEY_KEY);
if (StringUtils.isEm... | java | {
"resource": ""
} |
q163440 | HtmlServlet.isVisibleForSite | train | private boolean isVisibleForSite(final HttpServletRequest request, final Page page) {
final Site site = page.getSite();
if (site == null) {
return true;
}
final String serverName = request.getServerName();
final int serverPort = request.getServerPort();
if (StringUtils.isNotBlank(serverName) && !s... | java | {
"resource": ""
} |
q163441 | SessionHelper.clearSession | train | public static void clearSession(final String sessionId) {
if (StringUtils.isBlank(sessionId)) {
return;
}
final App app = StructrApp.getInstance();
final PropertyKey<String[]> sessionIdKey = StructrApp.key(Principal.class, "sessionIds");
final Query<Principal> query ... | java | {
"resource": ""
} |
q163442 | SessionHelper.clearInvalidSessions | train | public static void clearInvalidSessions(final Principal user) {
logger.info("Clearing invalid sessions for user {} ({})", user.getName(), user.getUuid());
final PropertyKey<String[]> sessionIdKey = StructrApp.key(Principal.class, "sessionIds");
final String[] sessionIds = user.getProperty(session... | java | {
"resource": ""
} |
q163443 | NodeWrapper.evaluateCustomQuery | train | public boolean evaluateCustomQuery(final String customQuery, final Map<String, Object> parameters) {
final SessionTransaction tx = db.getCurrentTransaction();
boolean result = false;
try {
result = tx.getBoolean(customQuery, parameters);
} catch (Exception ignore) {}
return result;
} | java | {
"resource": ""
} |
q163444 | LinkedTreeNodeImpl.ensureCorrectChildPositions | train | private void ensureCorrectChildPositions() throws FrameworkException {
final List<Relation<T, T, OneStartpoint<T>, ManyEndpoint<T>>> childRels = treeGetChildRelationships();
int position = 0;
for (Relation<T, T, OneStartpoint<T>, ManyEndpoint<T>> childRel : childRels) {
childRel.setProperty(getPositionProper... | java | {
"resource": ""
} |
q163445 | LinkedTreeNodeImpl.getAllChildNodes | train | @Override
public Set<T> getAllChildNodes() {
Set<T> allChildNodes = new HashSet();
List<T> childNodes = treeGetChildren();
for (final T child : childNodes) {
allChildNodes.add(child);
if (child instanceof LinkedTreeNode) {
final LinkedTreeNode treeNode = (LinkedTreeNode)child;
allChildNodes.a... | java | {
"resource": ""
} |
q163446 | AbstractEndpoint.getNotionProperties | train | protected PropertyMap getNotionProperties(final SecurityContext securityContext, final Class type, final String storageKey) {
final Map<String, PropertyMap> notionPropertyMap = (Map<String, PropertyMap>)securityContext.getAttribute("notionProperties");
if (notionPropertyMap != null) {
final Set<PropertyKey> ke... | java | {
"resource": ""
} |
q163447 | NodeFactory.getNodesAt | train | protected List<NodeInterface> getNodesAt(final NodeInterface locationNode) {
final List<NodeInterface> nodes = new LinkedList<>();
for(RelationshipInterface rel : locationNode.getIncomingRelationships(NodeHasLocation.class)) {
NodeInterface startNode = rel.getSourceNode();
nodes.add(startNode);
// add... | java | {
"resource": ""
} |
q163448 | Importer.fileExists | train | private File fileExists(final String path, final long checksum) throws FrameworkException {
final PropertyKey<Long> checksumKey = StructrApp.key(File.class, "checksum");
final PropertyKey<String> pathKey = StructrApp.key(File.class, "path");
return app.nodeQuery(File.class).and(pathKey, path).and(checksumKey,... | java | {
"resource": ""
} |
q163449 | PagingHelper.subList | train | public static <T> List<T> subList(final List<T> list, int pageSize, int page) {
if (pageSize <= 0 || page == 0) {
return Collections.EMPTY_LIST;
}
int size = list.size();
int fromIndex = page > 0
? (page - 1) * pageSize
: size + (page * pageSize);
int toIndex = fromIndex + pageS... | java | {
"resource": ""
} |
q163450 | PathHelper.getRelativeNodePath | train | public static String getRelativeNodePath(String basePath, String targetPath) {
// Both paths are equal
if (basePath.equals(targetPath)) {
return ".";
}
if (basePath.equals(PATH_SEP) && (targetPath.length() > 1)) {
// Base path is root path
return targetPath.substring(1);
}
String[] baseAncest... | java | {
"resource": ""
} |
q163451 | PathHelper.getName | train | public static String getName(final String path) {
String cleanedPath = clean(path);
if (cleanedPath != null && cleanedPath.contains(PATH_SEP)) {
return StringUtils.substringAfterLast(cleanedPath, PATH_SEP);
} else {
return cleanedPath;
}
} | java | {
"resource": ""
} |
q163452 | PathHelper.getParts | train | public static String[] getParts(final String path) {
String cleanedPath = clean(path);
return StringUtils.splitByWholeSeparator(cleanedPath, PATH_SEP);
} | java | {
"resource": ""
} |
q163453 | FileUploadHandler.finish | train | public void finish() {
try {
FileChannel channel = getChannel(false);
if (channel != null && channel.isOpen()) {
channel.force(true);
channel.close();
this.privateFileChannel = null;
//file.increaseVersion();
file.notifyUploadCompletion();
}
} catch (IOException e) {
logger.w... | java | {
"resource": ""
} |
q163454 | FinalSet.indexOf | train | public int indexOf(T x) {
int r=Arrays.binarySearch(data,x);
return(r>=0?r:-1);
} | java | {
"resource": ""
} |
q163455 | DeployCommand.endsWithUuid | train | public static boolean endsWithUuid(final String name) {
if (name.length() > 32) {
return pattern.matcher(name.substring(name.length() - 32)).matches();
} else {
return false;
}
} | java | {
"resource": ""
} |
q163456 | PropertyMap.contentHashCode | train | public int contentHashCode(Set<PropertyKey> comparableKeys, boolean includeSystemProperties) {
Map<PropertyKey, Object> sortedMap = new TreeMap<>(new PropertyKeyComparator());
int hashCode = 42;
sortedMap.putAll(properties);
if (comparableKeys == null) {
// calculate hash code for a... | java | {
"resource": ""
} |
q163457 | NodeRelationshipsCommand.execute | train | public List<RelationshipInterface> execute(NodeInterface sourceNode, RelationshipType relType, Direction dir) throws FrameworkException {
RelationshipFactory factory = new RelationshipFactory(securityContext);
List<RelationshipInterface> result = new LinkedList<>();
Node node = so... | java | {
"resource": ""
} |
q163458 | DatePropertyParser.parse | train | public static Date parse(String source, final String pattern) {
if (StringUtils.isBlank(pattern)) {
return parseISO8601DateString(source);
} else {
try {
// SimpleDateFormat is not fully ISO8601 compatible, so we replace 'Z' by +0000
if (StringUtils.contains(source, "Z")) {
source = StringUt... | java | {
"resource": ""
} |
q163459 | DatePropertyParser.parseISO8601DateString | train | public static Date parseISO8601DateString(String source) {
final String[] supportedFormats = new String[] { "yyyy-MM-dd'T'HH:mm:ss.SSSXXX", "yyyy-MM-dd'T'HH:mm:ssXXX", "yyyy-MM-dd'T'HH:mm:ssZ", "yyyy-MM-dd'T'HH:mm:ss.SSSZ" };
// SimpleDateFormat is not fully ISO8601 compatible, so we replace 'Z' by +0000
if (St... | java | {
"resource": ""
} |
q163460 | DatePropertyParser.format | train | public static String format(final Date date, String format) {
if (date != null) {
if (StringUtils.isBlank(format)) {
format = DateProperty.getDefaultFormat();
}
return new SimpleDateFormat(format).format(date);
}
return null;
} | java | {
"resource": ""
} |
q163461 | AbstractCommand.getGraphObject | train | public GraphObject getGraphObject(final String id, final String nodeId) {
if (isValidUuid(id)) {
final AbstractNode node = getNode(id);
if (node != null) {
return node;
} else {
if (nodeId == null) {
logger.warn("Relationship access by UUID is deprecated and not supported by Neo4j, this can... | java | {
"resource": ""
} |
q163462 | AbstractCommand.getNode | train | public AbstractNode getNode(final String id) {
final SecurityContext securityContext = getWebSocket().getSecurityContext();
final App app = StructrApp.getInstance(securityContext);
try (final Tx tx = app.tx()) {
final AbstractNode node = (AbstractNode) app.getNodeById(id);
tx.success();
return node;... | java | {
"resource": ""
} |
q163463 | AbstractCommand.getRelationship | train | public AbstractRelationship getRelationship(final String id, final String nodeId) {
if (id == null) {
return null;
}
if (nodeId == null) {
return getRelationship(id);
}
final SecurityContext securityContext = getWebSocket().getSecurityContext();
final App app = StructrApp.getInstance(securityContex... | java | {
"resource": ""
} |
q163464 | AbstractCommand.getRelationship | train | public AbstractRelationship getRelationship(final String id) {
if (id == null) {
return null;
}
final SecurityContext securityContext = getWebSocket().getSecurityContext();
final App app = StructrApp.getInstance(securityContext);
try (final Tx tx = app.tx()) {
final AbstractRelationship rel = (Abstr... | java | {
"resource": ""
} |
q163465 | AbstractCommand.moveChildNodes | train | protected void moveChildNodes(final DOMNode sourceNode, final DOMNode targetNode) {
DOMNode child = (DOMNode) sourceNode.getFirstChild();
while (child != null) {
DOMNode next = (DOMNode) child.getNextSibling();
targetNode.appendChild(child);
child = next;
}
} | java | {
"resource": ""
} |
q163466 | PageImportVisitor.fixDocumentElements | train | private void fixDocumentElements(final Page page) {
final NodeList heads = page.getElementsByTagName("head");
if (heads.getLength() > 1) {
final Node head1 = heads.item(0);
final Node head2 = heads.item(1);
final Node parent = head1.getParentNode();
final boolean h1 = head1.hasChildNodes();
f... | java | {
"resource": ""
} |
q163467 | AbstractStructrCmisService.getCMISInfo | train | public CMISInfo getCMISInfo(final Class<? extends GraphObject> type) {
try { return type.newInstance().getCMISInfo(); } catch (Throwable t) {}
return null;
} | java | {
"resource": ""
} |
q163468 | AbstractStructrCmisService.getBaseTypeId | train | public BaseTypeId getBaseTypeId(final Class<? extends GraphObject> type) {
final CMISInfo info = getCMISInfo(type);
if (info != null) {
return info.getBaseTypeId();
}
return null;
} | java | {
"resource": ""
} |
q163469 | AbstractStructrCmisService.getBaseTypeId | train | public BaseTypeId getBaseTypeId(final String typeId) {
try { return BaseTypeId.fromValue(typeId); } catch (IllegalArgumentException iex) {}
return null;
} | java | {
"resource": ""
} |
q163470 | AbstractStructrCmisService.typeFromObjectTypeId | train | public Class typeFromObjectTypeId(final String objectTypeId, final BaseTypeId defaultType, final Class defaultClass) {
// default for cmuis:folder
if (defaultType.value().equals(objectTypeId)) {
return defaultClass;
}
return StructrApp.getConfiguration().getNodeEntityClass(objectTypeId);
} | java | {
"resource": ""
} |
q163471 | Services.registerServiceClass | train | public void registerServiceClass(Class serviceClass) {
registeredServiceClasses.put(serviceClass.getSimpleName(), serviceClass);
// make it possible to select options in configuration editor
Settings.Services.addAvailableOption(serviceClass.getSimpleName());
} | java | {
"resource": ""
} |
q163472 | Services.isReady | train | public boolean isReady(final Class serviceClass) {
Service service = serviceCache.get(serviceClass);
return (service != null && service.isRunning());
} | java | {
"resource": ""
} |
q163473 | MailHelper.replacePlaceHoldersInTemplate | train | public static String replacePlaceHoldersInTemplate(final String template, final Map<String, String> replacementMap) {
List<String> toReplace = new ArrayList<>();
List<String> replaceBy = new ArrayList<>();
for (Entry<String, String> property : replacementMap.entrySet()) {
toReplace.add(property.getKey());
... | java | {
"resource": ""
} |
q163474 | JavaParserModule.indexSourceTree | train | public void indexSourceTree(final Folder rootFolder) {
logger.info("Starting indexing of source tree " + rootFolder.getPath());
final SecurityContext securityContext = rootFolder.getSecurityContext();
app = StructrApp.getInstance(securityContext);
structrTypeSolver.parseRoot(rootFolder);
final CombinedTyp... | java | {
"resource": ""
} |
q163475 | Factory.bulkInstantiate | train | public Iterable<T> bulkInstantiate(final Iterable<S> input) throws FrameworkException {
return Iterables.map(this, input);
} | java | {
"resource": ""
} |
q163476 | SyncCommand.exportToFile | train | public static void exportToFile(final DatabaseService graphDb, final String fileName, final String query, final boolean includeFiles) throws FrameworkException {
final App app = StructrApp.getInstance();
try (final Tx tx = app.tx()) {
final NodeFactory nodeFactory = new NodeFactory(SecurityContext.get... | java | {
"resource": ""
} |
q163477 | SyncCommand.exportToFile | train | public static void exportToFile(final String fileName, final Iterable<? extends NodeInterface> nodes, final Iterable<? extends RelationshipInterface> relationships, final Iterable<String> filePaths, final boolean includeFiles) throws FrameworkException {
try (final Tx tx = StructrApp.getInstance().tx()) {
try (f... | java | {
"resource": ""
} |
q163478 | SyncCommand.exportToStream | train | public static void exportToStream(final OutputStream outputStream, final Iterable<? extends NodeInterface> nodes, final Iterable<? extends RelationshipInterface> relationships, final Iterable<String> filePaths, final boolean includeFiles) throws FrameworkException {
try (final ZipOutputStream zos = new ZipOutputStre... | java | {
"resource": ""
} |
q163479 | SyncCommand.serializeData | train | public static void serializeData(DataOutputStream outputStream, byte[] data) throws IOException {
outputStream.writeInt(data.length);
outputStream.write(data);
outputStream.flush();
} | java | {
"resource": ""
} |
q163480 | Resource.getFirstPartOfString | train | private String getFirstPartOfString(final String source) {
final int pos = source.indexOf(".");
if (pos > -1) {
return source.substring(0, pos);
}
return source;
} | java | {
"resource": ""
} |
q163481 | RestAuthenticator.initializeAndExamineRequest | train | @Override
public SecurityContext initializeAndExamineRequest(final HttpServletRequest request, final HttpServletResponse response) throws FrameworkException {
logger.warn("KAI: RestAuthenticator.initializeAndExamineRequest");
SecurityContext securityContext;
Principal user = SessionHelper.checkSessionAuthenti... | java | {
"resource": ""
} |
q163482 | PlNationalIdentificationNumberProvider.calculateSexCode | train | private int calculateSexCode(Person.Sex sex) {
return SEX_FIELDS[baseProducer.randomInt(SEX_FIELDS.length - 1)] + (sex == Person.Sex.MALE ? 1 : 0);
} | java | {
"resource": ""
} |
q163483 | ZhFairyUtil.getRandomNumStr | train | public static String getRandomNumStr(BaseProducer baseProducer, int max, int paddingSize) {
int rndNum = baseProducer.randomBetween(1, max);
String numStr = "" + rndNum;
while (numStr.length() < paddingSize) {
numStr = "0" + numStr;
}
return numStr;
} | java | {
"resource": ""
} |
q163484 | Bootstrap.create | train | public static Fairy create(Locale locale, String dataFilePrefix) {
return builder().withLocale(locale)
.withFilePrefix(dataFilePrefix)
.build();
} | java | {
"resource": ""
} |
q163485 | Bootstrap.getFairyModuleForLocale | train | private static FairyModule getFairyModuleForLocale(DataMaster dataMaster, Locale locale, RandomGenerator randomGenerator) {
LanguageCode code;
try {
code = LanguageCode.valueOf(locale.getLanguage().toUpperCase());
} catch (IllegalArgumentException e) {
LOG.warn("Uknown locale " + locale);
code = Languag... | java | {
"resource": ""
} |
q163486 | MapBasedDataMaster.readResources | train | public void readResources(String path) throws IOException {
Enumeration<URL> resources =
getClass().getClassLoader().getResources(path);
if (!resources.hasMoreElements()) {
throw new IllegalArgumentException(String.format("File %s was not found on classpath", path));
}
Yaml yaml = new Yaml();
while (... | java | {
"resource": ""
} |
q163487 | BaseProducer.randomElement | train | public <T> T randomElement(List<T> elements) {
return elements.get(randomBetween(0, elements.size() - 1));
} | java | {
"resource": ""
} |
q163488 | BaseProducer.randomElement | train | public <T extends Enum<?>> T randomElement(Class<T> enumType) {
return enumType.getEnumConstants()[randomBetween(0, enumType.getEnumConstants().length - 1)];
} | java | {
"resource": ""
} |
q163489 | BaseProducer.randomElements | train | public <T> List<T> randomElements(List<T> elements, int count) {
if (elements.size() >= count) {
return extractRandomList(elements, count);
} else {
List<T> randomElements = new ArrayList<T>();
randomElements.addAll(extractRandomList(elements, count % elements.size()));
do {
randomElements.addAll(ex... | java | {
"resource": ""
} |
q163490 | MacroSubstitutionNamingStrategy.split | train | private static String[] split(String input) {
char macroStart = MACRO_START.charAt(0);
char macroEnd = MACRO_END.charAt(0);
int startIndex = 0;
boolean inMacro = false;
List<String> list = new ArrayList<String>();
for (int endIndex = 0; endIndex < input.length(); endIn... | java | {
"resource": ""
} |
q163491 | AbstractSyncAsyncMessageBus.initDispatcherThreads | train | private void initDispatcherThreads(Feature.AsynchronousMessageDispatch configuration) {
for (int i = 0; i < configuration.getNumberOfMessageDispatchers(); i++) {
// each thread will run forever and process incoming
// message publication requests
Thread dispatcher = configura... | java | {
"resource": ""
} |
q163492 | MetadataReader.getFilter | train | private IMessageFilter[] getFilter(Method method, Handler subscription) {
Filter[] filterDefinitions = collectFilters(method, subscription);
if (filterDefinitions.length == 0) {
return null;
}
IMessageFilter[] filters = new IMessageFilter[filterDefinitions.length];
in... | java | {
"resource": ""
} |
q163493 | MetadataReader.getMessageListener | train | public MessageListener getMessageListener(Class target) {
MessageListener listenerMetadata = new MessageListener(target);
// get all handlers (this will include all (inherited) methods directly annotated using @Handler)
Method[] allHandlers = ReflectionUtils.getMethods(AllMessageHandlers, target... | java | {
"resource": ""
} |
q163494 | ReflectionUtils.getOverridingMethod | train | public static Method getOverridingMethod( final Method overridingMethod, final Class subclass ) {
Class current = subclass;
while ( !current.equals( overridingMethod.getDeclaringClass() ) ) {
try {
return current.getDeclaredMethod( overridingMethod.getName(), overridingMethod... | java | {
"resource": ""
} |
q163495 | ReflectionUtils.getAnnotation | train | private static <A extends Annotation> A getAnnotation( AnnotatedElement from, Class<A> annotationType, Set<AnnotatedElement> visited) {
if( visited.contains(from) ) return null;
visited.add(from);
A ann = from.getAnnotation( annotationType );
if( ann != null) return ann;
for ( An... | java | {
"resource": ""
} |
q163496 | MessageListener.getHandlers | train | public List<MessageHandler> getHandlers(IPredicate<MessageHandler> filter) {
List<MessageHandler> matching = new ArrayList<MessageHandler>();
for (MessageHandler handler : handlers) {
if (filter.apply(handler)) {
matching.add(handler);
}
}
return m... | java | {
"resource": ""
} |
q163497 | Pool.borrowObject | train | public T borrowObject() {
T object;
if ((object = pool.poll()) == null) {
object = createObject();
}
return object;
} | java | {
"resource": ""
} |
q163498 | AuthRequestHelper.validateAuthorizationRequest | train | public static boolean validateAuthorizationRequest(AuthRequestDto authRequestDto, OAuthApplicationDto oAuthApplicationDto) throws OAuthException {
if (StringUtils.isNotBlank(oAuthApplicationDto.getClientId()) && oAuthApplicationDto.getClientId().equals(authRequestDto.getClientId())) {
try {
... | java | {
"resource": ""
} |
q163499 | AuthRequestHelper.generateAuthorizationCode | train | public static String generateAuthorizationCode() {
StringBuilder buf = new StringBuilder(AUTHORIZATION_CODE_LENGTH);
SecureRandom rand = new SecureRandom();
for (int i = 0; i < AUTHORIZATION_CODE_LENGTH; i++) {
buf.append(allowedCharacters[rand.nextInt(allowedCharacters.length)]);
... | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.