id int32 0 165k | repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1
value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 |
|---|---|---|---|---|---|---|---|---|---|---|---|
122,100 | Erudika/para | para-server/src/main/java/com/erudika/para/persistence/AWSDynamoUtils.java | AWSDynamoUtils.createSharedTable | public static boolean createSharedTable(long readCapacity, long writeCapacity) {
if (StringUtils.isBlank(SHARED_TABLE) || StringUtils.containsWhitespace(SHARED_TABLE) ||
existsTable(SHARED_TABLE)) {
return false;
}
try {
GlobalSecondaryIndex secIndex = new GlobalSecondaryIndex().
withIndexName(getS... | java | public static boolean createSharedTable(long readCapacity, long writeCapacity) {
if (StringUtils.isBlank(SHARED_TABLE) || StringUtils.containsWhitespace(SHARED_TABLE) ||
existsTable(SHARED_TABLE)) {
return false;
}
try {
GlobalSecondaryIndex secIndex = new GlobalSecondaryIndex().
withIndexName(getS... | [
"public",
"static",
"boolean",
"createSharedTable",
"(",
"long",
"readCapacity",
",",
"long",
"writeCapacity",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isBlank",
"(",
"SHARED_TABLE",
")",
"||",
"StringUtils",
".",
"containsWhitespace",
"(",
"SHARED_TABLE",
")",
... | Creates a table in AWS DynamoDB which will be shared between apps.
@param readCapacity read capacity
@param writeCapacity write capacity
@return true if created | [
"Creates",
"a",
"table",
"in",
"AWS",
"DynamoDB",
"which",
"will",
"be",
"shared",
"between",
"apps",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/persistence/AWSDynamoUtils.java#L254-L282 |
122,101 | Erudika/para | para-server/src/main/java/com/erudika/para/persistence/AWSDynamoUtils.java | AWSDynamoUtils.listAllTables | public static List<String> listAllTables() {
int items = 100;
ListTablesResult ltr = getClient().listTables(items);
List<String> tables = new LinkedList<>();
String lastKey;
do {
tables.addAll(ltr.getTableNames());
lastKey = ltr.getLastEvaluatedTableName();
logger.info("Found {} tables. Total found: ... | java | public static List<String> listAllTables() {
int items = 100;
ListTablesResult ltr = getClient().listTables(items);
List<String> tables = new LinkedList<>();
String lastKey;
do {
tables.addAll(ltr.getTableNames());
lastKey = ltr.getLastEvaluatedTableName();
logger.info("Found {} tables. Total found: ... | [
"public",
"static",
"List",
"<",
"String",
">",
"listAllTables",
"(",
")",
"{",
"int",
"items",
"=",
"100",
";",
"ListTablesResult",
"ltr",
"=",
"getClient",
"(",
")",
".",
"listTables",
"(",
"items",
")",
";",
"List",
"<",
"String",
">",
"tables",
"="... | Lists all table names for this account.
@return a list of DynamoDB tables | [
"Lists",
"all",
"table",
"names",
"for",
"this",
"account",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/persistence/AWSDynamoUtils.java#L314-L329 |
122,102 | Erudika/para | para-server/src/main/java/com/erudika/para/persistence/AWSDynamoUtils.java | AWSDynamoUtils.getTableNameForAppid | public static String getTableNameForAppid(String appIdentifier) {
if (StringUtils.isBlank(appIdentifier)) {
return null;
} else {
if (isSharedAppid(appIdentifier)) {
// app is sharing a table with other apps
appIdentifier = SHARED_TABLE;
}
return (App.isRoot(appIdentifier) || appIdentifier.start... | java | public static String getTableNameForAppid(String appIdentifier) {
if (StringUtils.isBlank(appIdentifier)) {
return null;
} else {
if (isSharedAppid(appIdentifier)) {
// app is sharing a table with other apps
appIdentifier = SHARED_TABLE;
}
return (App.isRoot(appIdentifier) || appIdentifier.start... | [
"public",
"static",
"String",
"getTableNameForAppid",
"(",
"String",
"appIdentifier",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isBlank",
"(",
"appIdentifier",
")",
")",
"{",
"return",
"null",
";",
"}",
"else",
"{",
"if",
"(",
"isSharedAppid",
"(",
"appIdent... | Returns the table name for a given app id. Table names are usually in the form 'prefix-appid'.
@param appIdentifier app id
@return the table name | [
"Returns",
"the",
"table",
"name",
"for",
"a",
"given",
"app",
"id",
".",
"Table",
"names",
"are",
"usually",
"in",
"the",
"form",
"prefix",
"-",
"appid",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/persistence/AWSDynamoUtils.java#L336-L347 |
122,103 | Erudika/para | para-server/src/main/java/com/erudika/para/persistence/AWSDynamoUtils.java | AWSDynamoUtils.batchGet | protected static <P extends ParaObject> void batchGet(Map<String, KeysAndAttributes> kna, Map<String, P> results) {
if (kna == null || kna.isEmpty() || results == null) {
return;
}
try {
BatchGetItemResult result = getClient().batchGetItem(new BatchGetItemRequest().
withReturnConsumedCapacity(ReturnCon... | java | protected static <P extends ParaObject> void batchGet(Map<String, KeysAndAttributes> kna, Map<String, P> results) {
if (kna == null || kna.isEmpty() || results == null) {
return;
}
try {
BatchGetItemResult result = getClient().batchGetItem(new BatchGetItemRequest().
withReturnConsumedCapacity(ReturnCon... | [
"protected",
"static",
"<",
"P",
"extends",
"ParaObject",
">",
"void",
"batchGet",
"(",
"Map",
"<",
"String",
",",
"KeysAndAttributes",
">",
"kna",
",",
"Map",
"<",
"String",
",",
"P",
">",
"results",
")",
"{",
"if",
"(",
"kna",
"==",
"null",
"||",
"... | Reads multiple items from DynamoDB, in batch.
@param <P> type of object
@param kna a map of row key->data
@param results a map of ID->ParaObject | [
"Reads",
"multiple",
"items",
"from",
"DynamoDB",
"in",
"batch",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/persistence/AWSDynamoUtils.java#L417-L446 |
122,104 | Erudika/para | para-server/src/main/java/com/erudika/para/persistence/AWSDynamoUtils.java | AWSDynamoUtils.batchWrite | protected static void batchWrite(Map<String, List<WriteRequest>> items, int backoff) {
if (items == null || items.isEmpty()) {
return;
}
try {
BatchWriteItemResult result = getClient().batchWriteItem(new BatchWriteItemRequest().
withReturnConsumedCapacity(ReturnConsumedCapacity.TOTAL).withRequestItems(... | java | protected static void batchWrite(Map<String, List<WriteRequest>> items, int backoff) {
if (items == null || items.isEmpty()) {
return;
}
try {
BatchWriteItemResult result = getClient().batchWriteItem(new BatchWriteItemRequest().
withReturnConsumedCapacity(ReturnConsumedCapacity.TOTAL).withRequestItems(... | [
"protected",
"static",
"void",
"batchWrite",
"(",
"Map",
"<",
"String",
",",
"List",
"<",
"WriteRequest",
">",
">",
"items",
",",
"int",
"backoff",
")",
"{",
"if",
"(",
"items",
"==",
"null",
"||",
"items",
".",
"isEmpty",
"(",
")",
")",
"{",
"return... | Writes multiple items in batch.
@param items a map of tables->write requests
@param backoff backoff seconds | [
"Writes",
"multiple",
"items",
"in",
"batch",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/persistence/AWSDynamoUtils.java#L453-L474 |
122,105 | Erudika/para | para-server/src/main/java/com/erudika/para/persistence/AWSDynamoUtils.java | AWSDynamoUtils.readPageFromTable | public static <P extends ParaObject> List<P> readPageFromTable(String appid, Pager p) {
Pager pager = (p != null) ? p : new Pager();
ScanRequest scanRequest = new ScanRequest().
withTableName(getTableNameForAppid(appid)).
withLimit(pager.getLimit()).
withReturnConsumedCapacity(ReturnConsumedCapacity.TOT... | java | public static <P extends ParaObject> List<P> readPageFromTable(String appid, Pager p) {
Pager pager = (p != null) ? p : new Pager();
ScanRequest scanRequest = new ScanRequest().
withTableName(getTableNameForAppid(appid)).
withLimit(pager.getLimit()).
withReturnConsumedCapacity(ReturnConsumedCapacity.TOT... | [
"public",
"static",
"<",
"P",
"extends",
"ParaObject",
">",
"List",
"<",
"P",
">",
"readPageFromTable",
"(",
"String",
"appid",
",",
"Pager",
"p",
")",
"{",
"Pager",
"pager",
"=",
"(",
"p",
"!=",
"null",
")",
"?",
"p",
":",
"new",
"Pager",
"(",
")"... | Reads a page from a standard DynamoDB table.
@param <P> type of object
@param appid the app identifier (name)
@param p a {@link Pager}
@return the last row key of the page, or null. | [
"Reads",
"a",
"page",
"from",
"a",
"standard",
"DynamoDB",
"table",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/persistence/AWSDynamoUtils.java#L483-L511 |
122,106 | Erudika/para | para-server/src/main/java/com/erudika/para/persistence/AWSDynamoUtils.java | AWSDynamoUtils.readPageFromSharedTable | public static <P extends ParaObject> List<P> readPageFromSharedTable(String appid, Pager pager) {
LinkedList<P> results = new LinkedList<>();
if (StringUtils.isBlank(appid)) {
return results;
}
PageIterable<Item, QueryOutcome> pages = queryGSI(appid, pager);
if (pages != null) {
for (Page<Item, QueryOut... | java | public static <P extends ParaObject> List<P> readPageFromSharedTable(String appid, Pager pager) {
LinkedList<P> results = new LinkedList<>();
if (StringUtils.isBlank(appid)) {
return results;
}
PageIterable<Item, QueryOutcome> pages = queryGSI(appid, pager);
if (pages != null) {
for (Page<Item, QueryOut... | [
"public",
"static",
"<",
"P",
"extends",
"ParaObject",
">",
"List",
"<",
"P",
">",
"readPageFromSharedTable",
"(",
"String",
"appid",
",",
"Pager",
"pager",
")",
"{",
"LinkedList",
"<",
"P",
">",
"results",
"=",
"new",
"LinkedList",
"<>",
"(",
")",
";",
... | Reads a page from a "shared" DynamoDB table. Shared tables are tables that have global secondary indexes
and can contain the objects of multiple apps.
@param <P> type of object
@param appid the app identifier (name)
@param pager a {@link Pager}
@return the id of the last object on the page, or null. | [
"Reads",
"a",
"page",
"from",
"a",
"shared",
"DynamoDB",
"table",
".",
"Shared",
"tables",
"are",
"tables",
"that",
"have",
"global",
"secondary",
"indexes",
"and",
"can",
"contain",
"the",
"objects",
"of",
"multiple",
"apps",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/persistence/AWSDynamoUtils.java#L521-L541 |
122,107 | Erudika/para | para-server/src/main/java/com/erudika/para/persistence/AWSDynamoUtils.java | AWSDynamoUtils.deleteAllFromSharedTable | public static void deleteAllFromSharedTable(String appid) {
if (StringUtils.isBlank(appid) || !isSharedAppid(appid)) {
return;
}
Pager pager = new Pager(25);
PageIterable<Item, QueryOutcome> pages;
Map<String, AttributeValue> lastKey = null;
do {
// read all phase
pages = queryGSI(appid, pager);
... | java | public static void deleteAllFromSharedTable(String appid) {
if (StringUtils.isBlank(appid) || !isSharedAppid(appid)) {
return;
}
Pager pager = new Pager(25);
PageIterable<Item, QueryOutcome> pages;
Map<String, AttributeValue> lastKey = null;
do {
// read all phase
pages = queryGSI(appid, pager);
... | [
"public",
"static",
"void",
"deleteAllFromSharedTable",
"(",
"String",
"appid",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isBlank",
"(",
"appid",
")",
"||",
"!",
"isSharedAppid",
"(",
"appid",
")",
")",
"{",
"return",
";",
"}",
"Pager",
"pager",
"=",
"ne... | Deletes all objects in a shared table, which belong to a given appid, by scanning the GSI.
@param appid app id | [
"Deletes",
"all",
"objects",
"in",
"a",
"shared",
"table",
"which",
"belong",
"to",
"a",
"given",
"appid",
"by",
"scanning",
"the",
"GSI",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/persistence/AWSDynamoUtils.java#L564-L597 |
122,108 | Erudika/para | para-server/src/main/java/com/erudika/para/persistence/AWSDynamoUtils.java | AWSDynamoUtils.getSharedIndex | public static Index getSharedIndex() {
if (ddb == null) {
getClient();
}
try {
Table t = ddb.getTable(getTableNameForAppid(SHARED_TABLE));
if (t != null) {
return t.getIndex(getSharedIndexName());
}
} catch (Exception e) {
logger.info("Could not get shared index: {}.", e.getMessage());
}
... | java | public static Index getSharedIndex() {
if (ddb == null) {
getClient();
}
try {
Table t = ddb.getTable(getTableNameForAppid(SHARED_TABLE));
if (t != null) {
return t.getIndex(getSharedIndexName());
}
} catch (Exception e) {
logger.info("Could not get shared index: {}.", e.getMessage());
}
... | [
"public",
"static",
"Index",
"getSharedIndex",
"(",
")",
"{",
"if",
"(",
"ddb",
"==",
"null",
")",
"{",
"getClient",
"(",
")",
";",
"}",
"try",
"{",
"Table",
"t",
"=",
"ddb",
".",
"getTable",
"(",
"getTableNameForAppid",
"(",
"SHARED_TABLE",
")",
")",
... | Returns the Index object for the shared table.
@return the Index object or null | [
"Returns",
"the",
"Index",
"object",
"for",
"the",
"shared",
"table",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/persistence/AWSDynamoUtils.java#L603-L616 |
122,109 | Erudika/para | para-core/src/main/java/com/erudika/para/core/User.java | User.setCurrency | public void setCurrency(String currency) {
currency = StringUtils.upperCase(currency);
if (!CurrencyUtils.getInstance().isValidCurrency(currency)) {
currency = "EUR";
}
this.currency = currency;
} | java | public void setCurrency(String currency) {
currency = StringUtils.upperCase(currency);
if (!CurrencyUtils.getInstance().isValidCurrency(currency)) {
currency = "EUR";
}
this.currency = currency;
} | [
"public",
"void",
"setCurrency",
"(",
"String",
"currency",
")",
"{",
"currency",
"=",
"StringUtils",
".",
"upperCase",
"(",
"currency",
")",
";",
"if",
"(",
"!",
"CurrencyUtils",
".",
"getInstance",
"(",
")",
".",
"isValidCurrency",
"(",
"currency",
")",
... | Sets a preferred currency. Default is "EUR".
@param currency a 3-letter currency code | [
"Sets",
"a",
"preferred",
"currency",
".",
"Default",
"is",
"EUR",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-core/src/main/java/com/erudika/para/core/User.java#L279-L285 |
122,110 | Erudika/para | para-core/src/main/java/com/erudika/para/core/User.java | User.detachIdentifier | public void detachIdentifier(String identifier) {
if (!StringUtils.equals(identifier, getIdentifier())) {
Sysprop s = CoreUtils.getInstance().getDao().read(getAppid(), identifier);
if (s != null && StringUtils.equals(getId(), s.getCreatorid())) {
deleteIdentifier(identifier);
}
}
} | java | public void detachIdentifier(String identifier) {
if (!StringUtils.equals(identifier, getIdentifier())) {
Sysprop s = CoreUtils.getInstance().getDao().read(getAppid(), identifier);
if (s != null && StringUtils.equals(getId(), s.getCreatorid())) {
deleteIdentifier(identifier);
}
}
} | [
"public",
"void",
"detachIdentifier",
"(",
"String",
"identifier",
")",
"{",
"if",
"(",
"!",
"StringUtils",
".",
"equals",
"(",
"identifier",
",",
"getIdentifier",
"(",
")",
")",
")",
"{",
"Sysprop",
"s",
"=",
"CoreUtils",
".",
"getInstance",
"(",
")",
"... | Detaches a secondary identifier which is not already used by this user.
@param identifier an attached identifier | [
"Detaches",
"a",
"secondary",
"identifier",
"which",
"is",
"not",
"already",
"used",
"by",
"this",
"user",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-core/src/main/java/com/erudika/para/core/User.java#L384-L391 |
122,111 | Erudika/para | para-core/src/main/java/com/erudika/para/core/User.java | User.isModerator | @JsonIgnore
public boolean isModerator() {
return isAdmin() ? true : StringUtils.equalsIgnoreCase(this.groups, Groups.MODS.toString());
} | java | @JsonIgnore
public boolean isModerator() {
return isAdmin() ? true : StringUtils.equalsIgnoreCase(this.groups, Groups.MODS.toString());
} | [
"@",
"JsonIgnore",
"public",
"boolean",
"isModerator",
"(",
")",
"{",
"return",
"isAdmin",
"(",
")",
"?",
"true",
":",
"StringUtils",
".",
"equalsIgnoreCase",
"(",
"this",
".",
"groups",
",",
"Groups",
".",
"MODS",
".",
"toString",
"(",
")",
")",
";",
... | Checks for moderator rights.
@return true if user has mod rights | [
"Checks",
"for",
"moderator",
"rights",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-core/src/main/java/com/erudika/para/core/User.java#L478-L481 |
122,112 | Erudika/para | para-core/src/main/java/com/erudika/para/core/User.java | User.getIdentityProvider | public String getIdentityProvider() {
if (isFacebookUser()) {
return "facebook";
} else if (isGooglePlusUser()) {
return "google";
} else if (isGitHubUser()) {
return "github";
} else if (isTwitterUser()) {
return "twitter";
} else if (isLinkedInUser()) {
return "linkedin";
} else if (isMicro... | java | public String getIdentityProvider() {
if (isFacebookUser()) {
return "facebook";
} else if (isGooglePlusUser()) {
return "google";
} else if (isGitHubUser()) {
return "github";
} else if (isTwitterUser()) {
return "twitter";
} else if (isLinkedInUser()) {
return "linkedin";
} else if (isMicro... | [
"public",
"String",
"getIdentityProvider",
"(",
")",
"{",
"if",
"(",
"isFacebookUser",
"(",
")",
")",
"{",
"return",
"\"facebook\"",
";",
"}",
"else",
"if",
"(",
"isGooglePlusUser",
"(",
")",
")",
"{",
"return",
"\"google\"",
";",
"}",
"else",
"if",
"(",... | Returns the name of the identity provider.
@return "facebook", "google"... etc. | [
"Returns",
"the",
"name",
"of",
"the",
"identity",
"provider",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-core/src/main/java/com/erudika/para/core/User.java#L487-L507 |
122,113 | Erudika/para | para-core/src/main/java/com/erudika/para/core/User.java | User.readUserForIdentifier | public static final User readUserForIdentifier(final User u) {
if (u == null || StringUtils.isBlank(u.getIdentifier())) {
return null;
}
User user = null;
String password = null;
String identifier = u.getIdentifier();
// Try to read the identifier object first, then read the user object linked to it.
S... | java | public static final User readUserForIdentifier(final User u) {
if (u == null || StringUtils.isBlank(u.getIdentifier())) {
return null;
}
User user = null;
String password = null;
String identifier = u.getIdentifier();
// Try to read the identifier object first, then read the user object linked to it.
S... | [
"public",
"static",
"final",
"User",
"readUserForIdentifier",
"(",
"final",
"User",
"u",
")",
"{",
"if",
"(",
"u",
"==",
"null",
"||",
"StringUtils",
".",
"isBlank",
"(",
"u",
".",
"getIdentifier",
"(",
")",
")",
")",
"{",
"return",
"null",
";",
"}",
... | Returns a user object for a given identifier.
@param u a user having a valid identifier set.
@return a user or null if no user is found for this identifier | [
"Returns",
"a",
"user",
"object",
"for",
"a",
"given",
"identifier",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-core/src/main/java/com/erudika/para/core/User.java#L531-L574 |
122,114 | Erudika/para | para-core/src/main/java/com/erudika/para/core/User.java | User.passwordMatches | public static final boolean passwordMatches(User u) {
if (u == null) {
return false;
}
String password = u.getPassword();
String identifier = u.getIdentifier();
if (StringUtils.isBlank(password) || StringUtils.isBlank(identifier)) {
return false;
}
ParaObject s = CoreUtils.getInstance().getDao().rea... | java | public static final boolean passwordMatches(User u) {
if (u == null) {
return false;
}
String password = u.getPassword();
String identifier = u.getIdentifier();
if (StringUtils.isBlank(password) || StringUtils.isBlank(identifier)) {
return false;
}
ParaObject s = CoreUtils.getInstance().getDao().rea... | [
"public",
"static",
"final",
"boolean",
"passwordMatches",
"(",
"User",
"u",
")",
"{",
"if",
"(",
"u",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"String",
"password",
"=",
"u",
".",
"getPassword",
"(",
")",
";",
"String",
"identifier",
"=",
... | Checks if a user has entered the correct password.
Compares password hashes.
@param u a user with a set password
@return true if password matches the one in the data store | [
"Checks",
"if",
"a",
"user",
"has",
"entered",
"the",
"correct",
"password",
".",
"Compares",
"password",
"hashes",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-core/src/main/java/com/erudika/para/core/User.java#L582-L603 |
122,115 | Erudika/para | para-core/src/main/java/com/erudika/para/core/User.java | User.generatePasswordResetToken | public final String generatePasswordResetToken() {
if (StringUtils.isBlank(identifier)) {
return "";
}
Sysprop s = CoreUtils.getInstance().getDao().read(getAppid(), identifier);
if (s != null) {
String token = Utils.generateSecurityToken(42, true);
s.addProperty(Config._RESET_TOKEN, token);
CoreUtil... | java | public final String generatePasswordResetToken() {
if (StringUtils.isBlank(identifier)) {
return "";
}
Sysprop s = CoreUtils.getInstance().getDao().read(getAppid(), identifier);
if (s != null) {
String token = Utils.generateSecurityToken(42, true);
s.addProperty(Config._RESET_TOKEN, token);
CoreUtil... | [
"public",
"final",
"String",
"generatePasswordResetToken",
"(",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isBlank",
"(",
"identifier",
")",
")",
"{",
"return",
"\"\"",
";",
"}",
"Sysprop",
"s",
"=",
"CoreUtils",
".",
"getInstance",
"(",
")",
".",
"getDao",... | Generates a new password reset token. Sent via email for pass reset.
@return the pass reset token | [
"Generates",
"a",
"new",
"password",
"reset",
"token",
".",
"Sent",
"via",
"email",
"for",
"pass",
"reset",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-core/src/main/java/com/erudika/para/core/User.java#L609-L621 |
122,116 | Erudika/para | para-core/src/main/java/com/erudika/para/core/User.java | User.resetPassword | public final boolean resetPassword(String token, String newpass) {
if (StringUtils.isBlank(newpass) || StringUtils.isBlank(token) || newpass.length() < Config.MIN_PASS_LENGTH) {
return false;
}
Sysprop s = CoreUtils.getInstance().getDao().read(getAppid(), identifier);
if (isValidToken(s, Config._RESET_TOKEN,... | java | public final boolean resetPassword(String token, String newpass) {
if (StringUtils.isBlank(newpass) || StringUtils.isBlank(token) || newpass.length() < Config.MIN_PASS_LENGTH) {
return false;
}
Sysprop s = CoreUtils.getInstance().getDao().read(getAppid(), identifier);
if (isValidToken(s, Config._RESET_TOKEN,... | [
"public",
"final",
"boolean",
"resetPassword",
"(",
"String",
"token",
",",
"String",
"newpass",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isBlank",
"(",
"newpass",
")",
"||",
"StringUtils",
".",
"isBlank",
"(",
"token",
")",
"||",
"newpass",
".",
"length"... | Changes the user password permanently.
@param token the reset token. see {@link #generatePasswordResetToken()}
@param newpass the new password
@return true if successful | [
"Changes",
"the",
"user",
"password",
"permanently",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-core/src/main/java/com/erudika/para/core/User.java#L629-L643 |
122,117 | Erudika/para | para-core/src/main/java/com/erudika/para/core/User.java | User.deleteIdentifier | private void deleteIdentifier(String ident) {
if (!StringUtils.isBlank(ident)) {
CoreUtils.getInstance().getDao().delete(getAppid(), new Sysprop(ident));
}
} | java | private void deleteIdentifier(String ident) {
if (!StringUtils.isBlank(ident)) {
CoreUtils.getInstance().getDao().delete(getAppid(), new Sysprop(ident));
}
} | [
"private",
"void",
"deleteIdentifier",
"(",
"String",
"ident",
")",
"{",
"if",
"(",
"!",
"StringUtils",
".",
"isBlank",
"(",
"ident",
")",
")",
"{",
"CoreUtils",
".",
"getInstance",
"(",
")",
".",
"getDao",
"(",
")",
".",
"delete",
"(",
"getAppid",
"("... | Deletes the identifier and the user can no longer sign in with it.
@param ident the attached identifier | [
"Deletes",
"the",
"identifier",
"and",
"the",
"user",
"can",
"no",
"longer",
"sign",
"in",
"with",
"it",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-core/src/main/java/com/erudika/para/core/User.java#L672-L676 |
122,118 | Erudika/para | para-core/src/main/java/com/erudika/para/core/User.java | User.generateEmailConfirmationToken | public String generateEmailConfirmationToken() {
if (StringUtils.isBlank(identifier)) {
return "";
}
Sysprop s = CoreUtils.getInstance().getDao().read(getAppid(), identifier);
if (s != null) {
String token = Utils.base64encURL(Utils.generateSecurityToken().getBytes());
s.addProperty(Config._EMAIL_TOKEN... | java | public String generateEmailConfirmationToken() {
if (StringUtils.isBlank(identifier)) {
return "";
}
Sysprop s = CoreUtils.getInstance().getDao().read(getAppid(), identifier);
if (s != null) {
String token = Utils.base64encURL(Utils.generateSecurityToken().getBytes());
s.addProperty(Config._EMAIL_TOKEN... | [
"public",
"String",
"generateEmailConfirmationToken",
"(",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isBlank",
"(",
"identifier",
")",
")",
"{",
"return",
"\"\"",
";",
"}",
"Sysprop",
"s",
"=",
"CoreUtils",
".",
"getInstance",
"(",
")",
".",
"getDao",
"(",... | Generates a new email confirmation token. Sent via email for user activation.
@return a Base64 encoded UUID | [
"Generates",
"a",
"new",
"email",
"confirmation",
"token",
".",
"Sent",
"via",
"email",
"for",
"user",
"activation",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-core/src/main/java/com/erudika/para/core/User.java#L682-L694 |
122,119 | Erudika/para | para-core/src/main/java/com/erudika/para/core/User.java | User.activateWithEmailToken | public final boolean activateWithEmailToken(String token) {
Sysprop s = CoreUtils.getInstance().getDao().read(getAppid(), identifier);
if (isValidToken(s, Config._EMAIL_TOKEN, token)) {
s.removeProperty(Config._EMAIL_TOKEN);
CoreUtils.getInstance().getDao().update(getAppid(), s);
setActive(true);
update... | java | public final boolean activateWithEmailToken(String token) {
Sysprop s = CoreUtils.getInstance().getDao().read(getAppid(), identifier);
if (isValidToken(s, Config._EMAIL_TOKEN, token)) {
s.removeProperty(Config._EMAIL_TOKEN);
CoreUtils.getInstance().getDao().update(getAppid(), s);
setActive(true);
update... | [
"public",
"final",
"boolean",
"activateWithEmailToken",
"(",
"String",
"token",
")",
"{",
"Sysprop",
"s",
"=",
"CoreUtils",
".",
"getInstance",
"(",
")",
".",
"getDao",
"(",
")",
".",
"read",
"(",
"getAppid",
"(",
")",
",",
"identifier",
")",
";",
"if",
... | Activates a user if a given token matches the one stored.
@param token the email confirmation token. see {@link #generateEmailConfirmationToken() }
@return true if successful | [
"Activates",
"a",
"user",
"if",
"a",
"given",
"token",
"matches",
"the",
"one",
"stored",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-core/src/main/java/com/erudika/para/core/User.java#L701-L711 |
122,120 | Erudika/para | para-core/src/main/java/com/erudika/para/core/User.java | User.isValidPasswordResetToken | public final boolean isValidPasswordResetToken(String token) {
Sysprop s = CoreUtils.getInstance().getDao().read(getAppid(), identifier);
return isValidToken(s, Config._RESET_TOKEN, token);
} | java | public final boolean isValidPasswordResetToken(String token) {
Sysprop s = CoreUtils.getInstance().getDao().read(getAppid(), identifier);
return isValidToken(s, Config._RESET_TOKEN, token);
} | [
"public",
"final",
"boolean",
"isValidPasswordResetToken",
"(",
"String",
"token",
")",
"{",
"Sysprop",
"s",
"=",
"CoreUtils",
".",
"getInstance",
"(",
")",
".",
"getDao",
"(",
")",
".",
"read",
"(",
"getAppid",
"(",
")",
",",
"identifier",
")",
";",
"re... | Validates a token sent via email for password reset.
@param token a token
@return true if valid | [
"Validates",
"a",
"token",
"sent",
"via",
"email",
"for",
"password",
"reset",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-core/src/main/java/com/erudika/para/core/User.java#L718-L721 |
122,121 | Erudika/para | para-core/src/main/java/com/erudika/para/core/User.java | User.isValidEmailConfirmationToken | public final boolean isValidEmailConfirmationToken(String token) {
Sysprop s = CoreUtils.getInstance().getDao().read(getAppid(), identifier);
return isValidToken(s, Config._EMAIL_TOKEN, token);
} | java | public final boolean isValidEmailConfirmationToken(String token) {
Sysprop s = CoreUtils.getInstance().getDao().read(getAppid(), identifier);
return isValidToken(s, Config._EMAIL_TOKEN, token);
} | [
"public",
"final",
"boolean",
"isValidEmailConfirmationToken",
"(",
"String",
"token",
")",
"{",
"Sysprop",
"s",
"=",
"CoreUtils",
".",
"getInstance",
"(",
")",
".",
"getDao",
"(",
")",
".",
"read",
"(",
"getAppid",
"(",
")",
",",
"identifier",
")",
";",
... | Validates a token sent for email confirmation.
@param token a token
@return true if valid | [
"Validates",
"a",
"token",
"sent",
"for",
"email",
"confirmation",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-core/src/main/java/com/erudika/para/core/User.java#L728-L731 |
122,122 | Erudika/para | para-core/src/main/java/com/erudika/para/core/User.java | User.setGravatarPicture | private void setGravatarPicture() {
if (StringUtils.isBlank(picture)) {
if (email != null) {
String emailHash = Utils.md5(email.toLowerCase());
setPicture("https://www.gravatar.com/avatar/" + emailHash + "?size=400&d=mm&r=pg");
} else {
setPicture("https://www.gravatar.com/avatar?d=mm&size=400");
... | java | private void setGravatarPicture() {
if (StringUtils.isBlank(picture)) {
if (email != null) {
String emailHash = Utils.md5(email.toLowerCase());
setPicture("https://www.gravatar.com/avatar/" + emailHash + "?size=400&d=mm&r=pg");
} else {
setPicture("https://www.gravatar.com/avatar?d=mm&size=400");
... | [
"private",
"void",
"setGravatarPicture",
"(",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isBlank",
"(",
"picture",
")",
")",
"{",
"if",
"(",
"email",
"!=",
"null",
")",
"{",
"String",
"emailHash",
"=",
"Utils",
".",
"md5",
"(",
"email",
".",
"toLowerCas... | Sets the profile picture using the Gravatar service. | [
"Sets",
"the",
"profile",
"picture",
"using",
"the",
"Gravatar",
"service",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-core/src/main/java/com/erudika/para/core/User.java#L751-L760 |
122,123 | Erudika/para | para-server/src/main/java/com/erudika/para/rest/RestUtils.java | RestUtils.extractAccessKey | public static String extractAccessKey(HttpServletRequest request) {
if (request == null) {
return "";
}
String accessKey = "";
String auth = request.getHeader(HttpHeaders.AUTHORIZATION);
boolean isAnonymousRequest = isAnonymousRequest(request);
if (StringUtils.isBlank(auth)) {
auth = request.getParame... | java | public static String extractAccessKey(HttpServletRequest request) {
if (request == null) {
return "";
}
String accessKey = "";
String auth = request.getHeader(HttpHeaders.AUTHORIZATION);
boolean isAnonymousRequest = isAnonymousRequest(request);
if (StringUtils.isBlank(auth)) {
auth = request.getParame... | [
"public",
"static",
"String",
"extractAccessKey",
"(",
"HttpServletRequest",
"request",
")",
"{",
"if",
"(",
"request",
"==",
"null",
")",
"{",
"return",
"\"\"",
";",
"}",
"String",
"accessKey",
"=",
"\"\"",
";",
"String",
"auth",
"=",
"request",
".",
"get... | Extracts the access key from a request. It can be a header or a parameter.
@param request a request
@return the access key | [
"Extracts",
"the",
"access",
"key",
"from",
"a",
"request",
".",
"It",
"can",
"be",
"a",
"header",
"or",
"a",
"parameter",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/rest/RestUtils.java#L85-L109 |
122,124 | Erudika/para | para-server/src/main/java/com/erudika/para/rest/RestUtils.java | RestUtils.isAnonymousRequest | public static boolean isAnonymousRequest(HttpServletRequest request) {
return request != null &&
(StringUtils.startsWith(request.getHeader(HttpHeaders.AUTHORIZATION), "Anonymous") ||
StringUtils.isBlank(request.getHeader(HttpHeaders.AUTHORIZATION)));
} | java | public static boolean isAnonymousRequest(HttpServletRequest request) {
return request != null &&
(StringUtils.startsWith(request.getHeader(HttpHeaders.AUTHORIZATION), "Anonymous") ||
StringUtils.isBlank(request.getHeader(HttpHeaders.AUTHORIZATION)));
} | [
"public",
"static",
"boolean",
"isAnonymousRequest",
"(",
"HttpServletRequest",
"request",
")",
"{",
"return",
"request",
"!=",
"null",
"&&",
"(",
"StringUtils",
".",
"startsWith",
"(",
"request",
".",
"getHeader",
"(",
"HttpHeaders",
".",
"AUTHORIZATION",
")",
... | Check if Authorization header starts with 'Anonymous'. Used for guest access.
@param request a request
@return true if user is unauthenticated | [
"Check",
"if",
"Authorization",
"header",
"starts",
"with",
"Anonymous",
".",
"Used",
"for",
"guest",
"access",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/rest/RestUtils.java#L116-L120 |
122,125 | Erudika/para | para-server/src/main/java/com/erudika/para/rest/RestUtils.java | RestUtils.extractDate | public static String extractDate(HttpServletRequest request) {
if (request == null) {
return "";
}
String date = request.getHeader("X-Amz-Date");
if (StringUtils.isBlank(date)) {
return request.getParameter("X-Amz-Date");
} else {
return date;
}
} | java | public static String extractDate(HttpServletRequest request) {
if (request == null) {
return "";
}
String date = request.getHeader("X-Amz-Date");
if (StringUtils.isBlank(date)) {
return request.getParameter("X-Amz-Date");
} else {
return date;
}
} | [
"public",
"static",
"String",
"extractDate",
"(",
"HttpServletRequest",
"request",
")",
"{",
"if",
"(",
"request",
"==",
"null",
")",
"{",
"return",
"\"\"",
";",
"}",
"String",
"date",
"=",
"request",
".",
"getHeader",
"(",
"\"X-Amz-Date\"",
")",
";",
"if"... | Extracts the date field from a request. It can be a header or a parameter.
@param request a request
@return the date | [
"Extracts",
"the",
"date",
"field",
"from",
"a",
"request",
".",
"It",
"can",
"be",
"a",
"header",
"or",
"a",
"parameter",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/rest/RestUtils.java#L127-L137 |
122,126 | Erudika/para | para-server/src/main/java/com/erudika/para/rest/RestUtils.java | RestUtils.getEntity | public static Response getEntity(InputStream is, Class<?> type) {
Object entity;
try {
if (is != null && is.available() > 0) {
if (is.available() > Config.MAX_ENTITY_SIZE_BYTES) {
return getStatusResponse(Response.Status.BAD_REQUEST,
"Request is too large - the maximum is " +
(Config.MAX_E... | java | public static Response getEntity(InputStream is, Class<?> type) {
Object entity;
try {
if (is != null && is.available() > 0) {
if (is.available() > Config.MAX_ENTITY_SIZE_BYTES) {
return getStatusResponse(Response.Status.BAD_REQUEST,
"Request is too large - the maximum is " +
(Config.MAX_E... | [
"public",
"static",
"Response",
"getEntity",
"(",
"InputStream",
"is",
",",
"Class",
"<",
"?",
">",
"type",
")",
"{",
"Object",
"entity",
";",
"try",
"{",
"if",
"(",
"is",
"!=",
"null",
"&&",
"is",
".",
"available",
"(",
")",
">",
"0",
")",
"{",
... | Returns a Response with the entity object inside it and 200 status code.
If there was and error the status code is different than 200.
@param is the entity input stream
@param type the type to convert the entity into, for example a Map. If null, this returns the InputStream.
@return response with 200 or error status | [
"Returns",
"a",
"Response",
"with",
"the",
"entity",
"object",
"inside",
"it",
"and",
"200",
"status",
"code",
".",
"If",
"there",
"was",
"and",
"error",
"the",
"status",
"code",
"is",
"different",
"than",
"200",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/rest/RestUtils.java#L201-L228 |
122,127 | Erudika/para | para-server/src/main/java/com/erudika/para/rest/RestUtils.java | RestUtils.readEntityBytes | public static byte[] readEntityBytes(InputStream in) {
byte[] jsonEntity = null;
try {
if (in != null && in.available() > 0) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buf = new byte[1024];
int length;
while ((length = in.read(buf)) > 0) {
baos.write(buf, 0, length);
... | java | public static byte[] readEntityBytes(InputStream in) {
byte[] jsonEntity = null;
try {
if (in != null && in.available() > 0) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buf = new byte[1024];
int length;
while ((length = in.read(buf)) > 0) {
baos.write(buf, 0, length);
... | [
"public",
"static",
"byte",
"[",
"]",
"readEntityBytes",
"(",
"InputStream",
"in",
")",
"{",
"byte",
"[",
"]",
"jsonEntity",
"=",
"null",
";",
"try",
"{",
"if",
"(",
"in",
"!=",
"null",
"&&",
"in",
".",
"available",
"(",
")",
">",
"0",
")",
"{",
... | Reads the bytes from an InputStream.
@param in an InputStream
@return byte[] | [
"Reads",
"the",
"bytes",
"from",
"an",
"InputStream",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/rest/RestUtils.java#L235-L261 |
122,128 | Erudika/para | para-server/src/main/java/com/erudika/para/rest/RestUtils.java | RestUtils.getVotingResponse | public static Response getVotingResponse(ParaObject object, Map<String, Object> entity) {
boolean voteSuccess = false;
if (object != null && entity != null) {
String upvoterId = (String) entity.get("_voteup");
String downvoterId = (String) entity.get("_votedown");
if (!StringUtils.isBlank(upvoterId)) {
... | java | public static Response getVotingResponse(ParaObject object, Map<String, Object> entity) {
boolean voteSuccess = false;
if (object != null && entity != null) {
String upvoterId = (String) entity.get("_voteup");
String downvoterId = (String) entity.get("_votedown");
if (!StringUtils.isBlank(upvoterId)) {
... | [
"public",
"static",
"Response",
"getVotingResponse",
"(",
"ParaObject",
"object",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"entity",
")",
"{",
"boolean",
"voteSuccess",
"=",
"false",
";",
"if",
"(",
"object",
"!=",
"null",
"&&",
"entity",
"!=",
"null... | Process voting request and create vote object.
@param object the object to cast vote on
@param entity request entity data
@return status codetrue if vote was successful | [
"Process",
"voting",
"request",
"and",
"create",
"vote",
"object",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/rest/RestUtils.java#L269-L284 |
122,129 | Erudika/para | para-server/src/main/java/com/erudika/para/rest/RestUtils.java | RestUtils.getReadResponse | public static Response getReadResponse(App app, ParaObject content) {
try (final Metrics.Context context = Metrics.time(app == null ? null : app.getAppid(),
RestUtils.class, "crud", "read")) {
// app can't modify other apps except itself
if (app != null && content != null &&
checkImplicitAppPermissions... | java | public static Response getReadResponse(App app, ParaObject content) {
try (final Metrics.Context context = Metrics.time(app == null ? null : app.getAppid(),
RestUtils.class, "crud", "read")) {
// app can't modify other apps except itself
if (app != null && content != null &&
checkImplicitAppPermissions... | [
"public",
"static",
"Response",
"getReadResponse",
"(",
"App",
"app",
",",
"ParaObject",
"content",
")",
"{",
"try",
"(",
"final",
"Metrics",
".",
"Context",
"context",
"=",
"Metrics",
".",
"time",
"(",
"app",
"==",
"null",
"?",
"null",
":",
"app",
".",
... | Read response as JSON.
@param app the app object
@param content the object that was read
@return status code 200 or 404 | [
"Read",
"response",
"as",
"JSON",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/rest/RestUtils.java#L296-L306 |
122,130 | Erudika/para | para-server/src/main/java/com/erudika/para/rest/RestUtils.java | RestUtils.getCreateResponse | public static Response getCreateResponse(App app, String type, InputStream is) {
try (final Metrics.Context context = Metrics.time(app == null ? null : app.getAppid(),
RestUtils.class, "crud", "create")) {
ParaObject content;
Response entityRes = getEntity(is, Map.class);
if (entityRes.getStatusInfo() ==... | java | public static Response getCreateResponse(App app, String type, InputStream is) {
try (final Metrics.Context context = Metrics.time(app == null ? null : app.getAppid(),
RestUtils.class, "crud", "create")) {
ParaObject content;
Response entityRes = getEntity(is, Map.class);
if (entityRes.getStatusInfo() ==... | [
"public",
"static",
"Response",
"getCreateResponse",
"(",
"App",
"app",
",",
"String",
"type",
",",
"InputStream",
"is",
")",
"{",
"try",
"(",
"final",
"Metrics",
".",
"Context",
"context",
"=",
"Metrics",
".",
"time",
"(",
"app",
"==",
"null",
"?",
"nul... | Create response as JSON.
@param type type of the object to create
@param is entity input stream
@param app the app object
@return a status code 201 or 400 | [
"Create",
"response",
"as",
"JSON",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/rest/RestUtils.java#L315-L356 |
122,131 | Erudika/para | para-server/src/main/java/com/erudika/para/rest/RestUtils.java | RestUtils.getOverwriteResponse | public static Response getOverwriteResponse(App app, String id, String type, InputStream is) {
try (final Metrics.Context context = Metrics.time(app == null ? null : app.getAppid(),
RestUtils.class, "crud", "overwrite")) {
ParaObject content;
Response entityRes = getEntity(is, Map.class);
if (entityRes.g... | java | public static Response getOverwriteResponse(App app, String id, String type, InputStream is) {
try (final Metrics.Context context = Metrics.time(app == null ? null : app.getAppid(),
RestUtils.class, "crud", "overwrite")) {
ParaObject content;
Response entityRes = getEntity(is, Map.class);
if (entityRes.g... | [
"public",
"static",
"Response",
"getOverwriteResponse",
"(",
"App",
"app",
",",
"String",
"id",
",",
"String",
"type",
",",
"InputStream",
"is",
")",
"{",
"try",
"(",
"final",
"Metrics",
".",
"Context",
"context",
"=",
"Metrics",
".",
"time",
"(",
"app",
... | Overwrite response as JSON.
@param id the object id
@param type type of the object to create
@param is entity input stream
@param app the app object
@return a status code 200 or 400 | [
"Overwrite",
"response",
"as",
"JSON",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/rest/RestUtils.java#L366-L405 |
122,132 | Erudika/para | para-server/src/main/java/com/erudika/para/rest/RestUtils.java | RestUtils.getUpdateResponse | public static Response getUpdateResponse(App app, ParaObject object, InputStream is) {
try (final Metrics.Context context = Metrics.time(app == null ? null : app.getAppid(),
RestUtils.class, "crud", "update")) {
if (app != null && object != null) {
Map<String, Object> newContent;
Response entityRes = g... | java | public static Response getUpdateResponse(App app, ParaObject object, InputStream is) {
try (final Metrics.Context context = Metrics.time(app == null ? null : app.getAppid(),
RestUtils.class, "crud", "update")) {
if (app != null && object != null) {
Map<String, Object> newContent;
Response entityRes = g... | [
"public",
"static",
"Response",
"getUpdateResponse",
"(",
"App",
"app",
",",
"ParaObject",
"object",
",",
"InputStream",
"is",
")",
"{",
"try",
"(",
"final",
"Metrics",
".",
"Context",
"context",
"=",
"Metrics",
".",
"time",
"(",
"app",
"==",
"null",
"?",
... | Update response as JSON.
@param object object to validate and update
@param is entity input stream
@param app the app object
@return a status code 200 or 400 or 404 | [
"Update",
"response",
"as",
"JSON",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/rest/RestUtils.java#L414-L451 |
122,133 | Erudika/para | para-server/src/main/java/com/erudika/para/rest/RestUtils.java | RestUtils.getDeleteResponse | public static Response getDeleteResponse(App app, ParaObject content) {
try (final Metrics.Context context = Metrics.time(app == null ? null : app.getAppid(),
RestUtils.class, "crud", "delete")) {
if (app != null && content != null && content.getId() != null && content.getAppid() != null) {
if (checkImplic... | java | public static Response getDeleteResponse(App app, ParaObject content) {
try (final Metrics.Context context = Metrics.time(app == null ? null : app.getAppid(),
RestUtils.class, "crud", "delete")) {
if (app != null && content != null && content.getId() != null && content.getAppid() != null) {
if (checkImplic... | [
"public",
"static",
"Response",
"getDeleteResponse",
"(",
"App",
"app",
",",
"ParaObject",
"content",
")",
"{",
"try",
"(",
"final",
"Metrics",
".",
"Context",
"context",
"=",
"Metrics",
".",
"time",
"(",
"app",
"==",
"null",
"?",
"null",
":",
"app",
"."... | Delete response as JSON.
@param content the object to delete
@param app the current App object
@return a status code 200 or 400 | [
"Delete",
"response",
"as",
"JSON",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/rest/RestUtils.java#L459-L472 |
122,134 | Erudika/para | para-server/src/main/java/com/erudika/para/rest/RestUtils.java | RestUtils.getBatchReadResponse | public static Response getBatchReadResponse(App app, List<String> ids) {
try (final Metrics.Context context = Metrics.time(app == null ? null : app.getAppid(),
RestUtils.class, "batch", "read")) {
if (app != null && ids != null && !ids.isEmpty()) {
ArrayList<ParaObject> results = new ArrayList<>(ids.size()... | java | public static Response getBatchReadResponse(App app, List<String> ids) {
try (final Metrics.Context context = Metrics.time(app == null ? null : app.getAppid(),
RestUtils.class, "batch", "read")) {
if (app != null && ids != null && !ids.isEmpty()) {
ArrayList<ParaObject> results = new ArrayList<>(ids.size()... | [
"public",
"static",
"Response",
"getBatchReadResponse",
"(",
"App",
"app",
",",
"List",
"<",
"String",
">",
"ids",
")",
"{",
"try",
"(",
"final",
"Metrics",
".",
"Context",
"context",
"=",
"Metrics",
".",
"time",
"(",
"app",
"==",
"null",
"?",
"null",
... | Batch read response as JSON.
@param app the current App object
@param ids list of ids
@return status code 200 or 400 | [
"Batch",
"read",
"response",
"as",
"JSON",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/rest/RestUtils.java#L480-L495 |
122,135 | Erudika/para | para-server/src/main/java/com/erudika/para/rest/RestUtils.java | RestUtils.getBatchCreateResponse | public static Response getBatchCreateResponse(final App app, InputStream is) {
try (final Metrics.Context context = Metrics.time(app == null ? null : app.getAppid(),
RestUtils.class, "batch", "create")) {
if (app != null) {
final LinkedList<ParaObject> newObjects = new LinkedList<>();
Response entityRe... | java | public static Response getBatchCreateResponse(final App app, InputStream is) {
try (final Metrics.Context context = Metrics.time(app == null ? null : app.getAppid(),
RestUtils.class, "batch", "create")) {
if (app != null) {
final LinkedList<ParaObject> newObjects = new LinkedList<>();
Response entityRe... | [
"public",
"static",
"Response",
"getBatchCreateResponse",
"(",
"final",
"App",
"app",
",",
"InputStream",
"is",
")",
"{",
"try",
"(",
"final",
"Metrics",
".",
"Context",
"context",
"=",
"Metrics",
".",
"time",
"(",
"app",
"==",
"null",
"?",
"null",
":",
... | Batch create response as JSON.
@param app the current App object
@param is entity input stream
@return a status code 200 or 400 | [
"Batch",
"create",
"response",
"as",
"JSON",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/rest/RestUtils.java#L503-L544 |
122,136 | Erudika/para | para-server/src/main/java/com/erudika/para/rest/RestUtils.java | RestUtils.getBatchUpdateResponse | public static Response getBatchUpdateResponse(App app, Map<String, ParaObject> oldObjects,
List<Map<String, Object>> newProperties) {
try (final Metrics.Context context = Metrics.time(app == null ? null : app.getAppid(),
RestUtils.class, "batch", "update")) {
if (app != null && oldObjects != null && newProp... | java | public static Response getBatchUpdateResponse(App app, Map<String, ParaObject> oldObjects,
List<Map<String, Object>> newProperties) {
try (final Metrics.Context context = Metrics.time(app == null ? null : app.getAppid(),
RestUtils.class, "batch", "update")) {
if (app != null && oldObjects != null && newProp... | [
"public",
"static",
"Response",
"getBatchUpdateResponse",
"(",
"App",
"app",
",",
"Map",
"<",
"String",
",",
"ParaObject",
">",
"oldObjects",
",",
"List",
"<",
"Map",
"<",
"String",
",",
"Object",
">",
">",
"newProperties",
")",
"{",
"try",
"(",
"final",
... | Batch update response as JSON.
@param app the current App object
@param oldObjects a list of old objects read from DB
@param newProperties a list of new object properties to be updated
@return a status code 200 or 400 | [
"Batch",
"update",
"response",
"as",
"JSON",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/rest/RestUtils.java#L553-L583 |
122,137 | Erudika/para | para-server/src/main/java/com/erudika/para/rest/RestUtils.java | RestUtils.getBatchDeleteResponse | public static Response getBatchDeleteResponse(App app, List<String> ids) {
try (final Metrics.Context context = Metrics.time(app == null ? null : app.getAppid(),
RestUtils.class, "batch", "delete")) {
LinkedList<ParaObject> objects = new LinkedList<>();
if (app != null && ids != null && !ids.isEmpty()) {
... | java | public static Response getBatchDeleteResponse(App app, List<String> ids) {
try (final Metrics.Context context = Metrics.time(app == null ? null : app.getAppid(),
RestUtils.class, "batch", "delete")) {
LinkedList<ParaObject> objects = new LinkedList<>();
if (app != null && ids != null && !ids.isEmpty()) {
... | [
"public",
"static",
"Response",
"getBatchDeleteResponse",
"(",
"App",
"app",
",",
"List",
"<",
"String",
">",
"ids",
")",
"{",
"try",
"(",
"final",
"Metrics",
".",
"Context",
"context",
"=",
"Metrics",
".",
"time",
"(",
"app",
"==",
"null",
"?",
"null",
... | Batch delete response as JSON.
@param app the current App object
@param ids list of ids to delete
@return a status code 200 or 400 | [
"Batch",
"delete",
"response",
"as",
"JSON",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/rest/RestUtils.java#L591-L615 |
122,138 | Erudika/para | para-server/src/main/java/com/erudika/para/rest/RestUtils.java | RestUtils.readLinksHandler | public static Response readLinksHandler(ParaObject pobj, String id2, String type2,
MultivaluedMap<String, String> params, Pager pager, boolean childrenOnly) {
try (final Metrics.Context context = Metrics.time(null, RestUtils.class, "links", "read")) {
String query = params.getFirst("q");
if (type2 != null) {... | java | public static Response readLinksHandler(ParaObject pobj, String id2, String type2,
MultivaluedMap<String, String> params, Pager pager, boolean childrenOnly) {
try (final Metrics.Context context = Metrics.time(null, RestUtils.class, "links", "read")) {
String query = params.getFirst("q");
if (type2 != null) {... | [
"public",
"static",
"Response",
"readLinksHandler",
"(",
"ParaObject",
"pobj",
",",
"String",
"id2",
",",
"String",
"type2",
",",
"MultivaluedMap",
"<",
"String",
",",
"String",
">",
"params",
",",
"Pager",
"pager",
",",
"boolean",
"childrenOnly",
")",
"{",
... | Handles requests to search for linked objects.
@param pobj the object to operate on
@param id2 the id of the second object (optional)
@param type2 the type of the second object
@param params query parameters
@param pager a {@link Pager} object
@param childrenOnly find only directly linked objects in 1-to-many relations... | [
"Handles",
"requests",
"to",
"search",
"for",
"linked",
"objects",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/rest/RestUtils.java#L631-L671 |
122,139 | Erudika/para | para-server/src/main/java/com/erudika/para/rest/RestUtils.java | RestUtils.deleteLinksHandler | public static Response deleteLinksHandler(ParaObject pobj, String id2, String type2, boolean childrenOnly) {
try (final Metrics.Context context = Metrics.time(null, RestUtils.class, "links", "delete")) {
if (type2 == null && id2 == null) {
pobj.unlinkAll();
} else if (type2 != null) {
if (id2 != null) {... | java | public static Response deleteLinksHandler(ParaObject pobj, String id2, String type2, boolean childrenOnly) {
try (final Metrics.Context context = Metrics.time(null, RestUtils.class, "links", "delete")) {
if (type2 == null && id2 == null) {
pobj.unlinkAll();
} else if (type2 != null) {
if (id2 != null) {... | [
"public",
"static",
"Response",
"deleteLinksHandler",
"(",
"ParaObject",
"pobj",
",",
"String",
"id2",
",",
"String",
"type2",
",",
"boolean",
"childrenOnly",
")",
"{",
"try",
"(",
"final",
"Metrics",
".",
"Context",
"context",
"=",
"Metrics",
".",
"time",
"... | Handles requests to delete linked objects.
@param pobj the object to operate on
@param id2 the id of the second object (optional)
@param type2 the type of the second object
@param childrenOnly find only directly linked objects in 1-to-many relationship
@return a Response | [
"Handles",
"requests",
"to",
"delete",
"linked",
"objects",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/rest/RestUtils.java#L681-L694 |
122,140 | Erudika/para | para-server/src/main/java/com/erudika/para/rest/RestUtils.java | RestUtils.createLinksHandler | public static Response createLinksHandler(ParaObject pobj, String id2) {
try (final Metrics.Context context = Metrics.time(null, RestUtils.class, "links", "create")) {
if (id2 != null && pobj != null) {
String linkid = pobj.link(id2);
if (linkid == null) {
return getStatusResponse(Response.Status.BAD_... | java | public static Response createLinksHandler(ParaObject pobj, String id2) {
try (final Metrics.Context context = Metrics.time(null, RestUtils.class, "links", "create")) {
if (id2 != null && pobj != null) {
String linkid = pobj.link(id2);
if (linkid == null) {
return getStatusResponse(Response.Status.BAD_... | [
"public",
"static",
"Response",
"createLinksHandler",
"(",
"ParaObject",
"pobj",
",",
"String",
"id2",
")",
"{",
"try",
"(",
"final",
"Metrics",
".",
"Context",
"context",
"=",
"Metrics",
".",
"time",
"(",
"null",
",",
"RestUtils",
".",
"class",
",",
"\"li... | Handles requests to link an object to other objects.
@param pobj the object to operate on
@param id2 the id of the second object (optional)
@return a Response | [
"Handles",
"requests",
"to",
"link",
"an",
"object",
"to",
"other",
"objects",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/rest/RestUtils.java#L702-L715 |
122,141 | Erudika/para | para-server/src/main/java/com/erudika/para/rest/RestUtils.java | RestUtils.getStatusResponse | public static Response getStatusResponse(Response.Status status, String... messages) {
if (status == null) {
return Response.status(Response.Status.BAD_REQUEST).build();
}
String msg = StringUtils.join(messages, ". ");
if (StringUtils.isBlank(msg)) {
msg = status.getReasonPhrase();
}
try {
return G... | java | public static Response getStatusResponse(Response.Status status, String... messages) {
if (status == null) {
return Response.status(Response.Status.BAD_REQUEST).build();
}
String msg = StringUtils.join(messages, ". ");
if (StringUtils.isBlank(msg)) {
msg = status.getReasonPhrase();
}
try {
return G... | [
"public",
"static",
"Response",
"getStatusResponse",
"(",
"Response",
".",
"Status",
"status",
",",
"String",
"...",
"messages",
")",
"{",
"if",
"(",
"status",
"==",
"null",
")",
"{",
"return",
"Response",
".",
"status",
"(",
"Response",
".",
"Status",
"."... | A generic JSON response handler.
@param status status code
@param messages zero or more errors
@return a response as JSON | [
"A",
"generic",
"JSON",
"response",
"handler",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/rest/RestUtils.java#L920-L934 |
122,142 | Erudika/para | para-server/src/main/java/com/erudika/para/rest/RestUtils.java | RestUtils.returnStatusResponse | public static void returnStatusResponse(HttpServletResponse response, int status, String message) {
if (response == null) {
return;
}
PrintWriter out = null;
try {
response.setStatus(status);
response.setContentType(MediaType.APPLICATION_JSON);
out = response.getWriter();
ParaObjectUtils.getJsonW... | java | public static void returnStatusResponse(HttpServletResponse response, int status, String message) {
if (response == null) {
return;
}
PrintWriter out = null;
try {
response.setStatus(status);
response.setContentType(MediaType.APPLICATION_JSON);
out = response.getWriter();
ParaObjectUtils.getJsonW... | [
"public",
"static",
"void",
"returnStatusResponse",
"(",
"HttpServletResponse",
"response",
",",
"int",
"status",
",",
"String",
"message",
")",
"{",
"if",
"(",
"response",
"==",
"null",
")",
"{",
"return",
";",
"}",
"PrintWriter",
"out",
"=",
"null",
";",
... | A generic JSON response handler. Returns a message and response code.
@param response the response to write to
@param status status code
@param message error message | [
"A",
"generic",
"JSON",
"response",
"handler",
".",
"Returns",
"a",
"message",
"and",
"response",
"code",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/rest/RestUtils.java#L942-L960 |
122,143 | Erudika/para | para-server/src/main/java/com/erudika/para/rest/RestUtils.java | RestUtils.pathParam | public static String pathParam(String param, ContainerRequestContext ctx) {
return ctx.getUriInfo().getPathParameters().getFirst(param);
} | java | public static String pathParam(String param, ContainerRequestContext ctx) {
return ctx.getUriInfo().getPathParameters().getFirst(param);
} | [
"public",
"static",
"String",
"pathParam",
"(",
"String",
"param",
",",
"ContainerRequestContext",
"ctx",
")",
"{",
"return",
"ctx",
".",
"getUriInfo",
"(",
")",
".",
"getPathParameters",
"(",
")",
".",
"getFirst",
"(",
"param",
")",
";",
"}"
] | Returns the path parameter value.
@param param a parameter name
@param ctx ctx
@return a value | [
"Returns",
"the",
"path",
"parameter",
"value",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/rest/RestUtils.java#L992-L994 |
122,144 | Erudika/para | para-server/src/main/java/com/erudika/para/rest/RestUtils.java | RestUtils.pathParams | public static List<String> pathParams(String param, ContainerRequestContext ctx) {
return ctx.getUriInfo().getPathParameters().get(param);
} | java | public static List<String> pathParams(String param, ContainerRequestContext ctx) {
return ctx.getUriInfo().getPathParameters().get(param);
} | [
"public",
"static",
"List",
"<",
"String",
">",
"pathParams",
"(",
"String",
"param",
",",
"ContainerRequestContext",
"ctx",
")",
"{",
"return",
"ctx",
".",
"getUriInfo",
"(",
")",
".",
"getPathParameters",
"(",
")",
".",
"get",
"(",
"param",
")",
";",
"... | Returns the path parameters values.
@param param a parameter name
@param ctx ctx
@return a list of parameter values | [
"Returns",
"the",
"path",
"parameters",
"values",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/rest/RestUtils.java#L1002-L1004 |
122,145 | Erudika/para | para-server/src/main/java/com/erudika/para/rest/RestUtils.java | RestUtils.queryParam | public static String queryParam(String param, ContainerRequestContext ctx) {
return ctx.getUriInfo().getQueryParameters().getFirst(param);
} | java | public static String queryParam(String param, ContainerRequestContext ctx) {
return ctx.getUriInfo().getQueryParameters().getFirst(param);
} | [
"public",
"static",
"String",
"queryParam",
"(",
"String",
"param",
",",
"ContainerRequestContext",
"ctx",
")",
"{",
"return",
"ctx",
".",
"getUriInfo",
"(",
")",
".",
"getQueryParameters",
"(",
")",
".",
"getFirst",
"(",
"param",
")",
";",
"}"
] | Returns the query parameter value.
@param param a parameter name
@param ctx ctx
@return parameter value | [
"Returns",
"the",
"query",
"parameter",
"value",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/rest/RestUtils.java#L1012-L1014 |
122,146 | Erudika/para | para-server/src/main/java/com/erudika/para/rest/RestUtils.java | RestUtils.queryParams | public static List<String> queryParams(String param, ContainerRequestContext ctx) {
return ctx.getUriInfo().getQueryParameters().get(param);
} | java | public static List<String> queryParams(String param, ContainerRequestContext ctx) {
return ctx.getUriInfo().getQueryParameters().get(param);
} | [
"public",
"static",
"List",
"<",
"String",
">",
"queryParams",
"(",
"String",
"param",
",",
"ContainerRequestContext",
"ctx",
")",
"{",
"return",
"ctx",
".",
"getUriInfo",
"(",
")",
".",
"getQueryParameters",
"(",
")",
".",
"get",
"(",
"param",
")",
";",
... | Returns the query parameter values.
@param param a parameter name
@param ctx ctx
@return a list of values | [
"Returns",
"the",
"query",
"parameter",
"values",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/rest/RestUtils.java#L1022-L1024 |
122,147 | Erudika/para | para-server/src/main/java/com/erudika/para/rest/RestUtils.java | RestUtils.hasQueryParam | public static boolean hasQueryParam(String param, ContainerRequestContext ctx) {
return ctx.getUriInfo().getQueryParameters().containsKey(param);
} | java | public static boolean hasQueryParam(String param, ContainerRequestContext ctx) {
return ctx.getUriInfo().getQueryParameters().containsKey(param);
} | [
"public",
"static",
"boolean",
"hasQueryParam",
"(",
"String",
"param",
",",
"ContainerRequestContext",
"ctx",
")",
"{",
"return",
"ctx",
".",
"getUriInfo",
"(",
")",
".",
"getQueryParameters",
"(",
")",
".",
"containsKey",
"(",
"param",
")",
";",
"}"
] | Returns true if parameter exists.
@param param a parameter name
@param ctx ctx
@return true if parameter is set | [
"Returns",
"true",
"if",
"parameter",
"exists",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/rest/RestUtils.java#L1032-L1034 |
122,148 | Erudika/para | para-server/src/main/java/com/erudika/para/queue/AWSQueue.java | AWSQueue.getUrl | public String getUrl() {
if (StringUtils.isBlank(url) && !StringUtils.isBlank(name)) {
this.url = AWSQueueUtils.createQueue(name);
}
return url;
} | java | public String getUrl() {
if (StringUtils.isBlank(url) && !StringUtils.isBlank(name)) {
this.url = AWSQueueUtils.createQueue(name);
}
return url;
} | [
"public",
"String",
"getUrl",
"(",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isBlank",
"(",
"url",
")",
"&&",
"!",
"StringUtils",
".",
"isBlank",
"(",
"name",
")",
")",
"{",
"this",
".",
"url",
"=",
"AWSQueueUtils",
".",
"createQueue",
"(",
"name",
"... | Returns the queue URL on SQS.
@return returns the URL of this queue | [
"Returns",
"the",
"queue",
"URL",
"on",
"SQS",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/queue/AWSQueue.java#L92-L97 |
122,149 | Erudika/para | para-server/src/main/java/com/erudika/para/utils/filters/GZipServletFilter.java | GZipServletFilter.isIncluded | private boolean isIncluded(final HttpServletRequest request) {
final String uri = (String) request.getAttribute("javax.servlet.include.request_uri");
final boolean includeRequest = !(uri == null);
if (includeRequest && log.isDebugEnabled()) {
log.debug("{} resulted in an include request. This is unusable, bec... | java | private boolean isIncluded(final HttpServletRequest request) {
final String uri = (String) request.getAttribute("javax.servlet.include.request_uri");
final boolean includeRequest = !(uri == null);
if (includeRequest && log.isDebugEnabled()) {
log.debug("{} resulted in an include request. This is unusable, bec... | [
"private",
"boolean",
"isIncluded",
"(",
"final",
"HttpServletRequest",
"request",
")",
"{",
"final",
"String",
"uri",
"=",
"(",
"String",
")",
"request",
".",
"getAttribute",
"(",
"\"javax.servlet.include.request_uri\"",
")",
";",
"final",
"boolean",
"includeReques... | Checks if the request uri is an include. These cannot be gzipped. | [
"Checks",
"if",
"the",
"request",
"uri",
"is",
"an",
"include",
".",
"These",
"cannot",
"be",
"gzipped",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/utils/filters/GZipServletFilter.java#L131-L141 |
122,150 | Erudika/para | para-core/src/main/java/com/erudika/para/rest/Signer.java | Signer.parseAWSDate | public static Date parseAWSDate(String date) {
if (date == null) {
return null;
}
return TIME_FORMATTER.parseDateTime(date).toDate();
} | java | public static Date parseAWSDate(String date) {
if (date == null) {
return null;
}
return TIME_FORMATTER.parseDateTime(date).toDate();
} | [
"public",
"static",
"Date",
"parseAWSDate",
"(",
"String",
"date",
")",
"{",
"if",
"(",
"date",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"TIME_FORMATTER",
".",
"parseDateTime",
"(",
"date",
")",
".",
"toDate",
"(",
")",
";",
"}"
] | Returns a parsed Date.
@param date a date in the AWS format yyyyMMdd'T'HHmmss'Z'
@return a date | [
"Returns",
"a",
"parsed",
"Date",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-core/src/main/java/com/erudika/para/rest/Signer.java#L151-L156 |
122,151 | Erudika/para | para-core/src/main/java/com/erudika/para/rest/Signer.java | Signer.signRequest | public Map<String, String> signRequest(String accessKey, String secretKey,
String httpMethod, String endpointURL, String reqPath,
Map<String, String> headers, MultivaluedMap<String, String> params, byte[] jsonEntity) {
if (StringUtils.isBlank(accessKey)) {
logger.error("Blank access key: {} {}", httpMethod,... | java | public Map<String, String> signRequest(String accessKey, String secretKey,
String httpMethod, String endpointURL, String reqPath,
Map<String, String> headers, MultivaluedMap<String, String> params, byte[] jsonEntity) {
if (StringUtils.isBlank(accessKey)) {
logger.error("Blank access key: {} {}", httpMethod,... | [
"public",
"Map",
"<",
"String",
",",
"String",
">",
"signRequest",
"(",
"String",
"accessKey",
",",
"String",
"secretKey",
",",
"String",
"httpMethod",
",",
"String",
"endpointURL",
",",
"String",
"reqPath",
",",
"Map",
"<",
"String",
",",
"String",
">",
"... | Builds and signs a request to an API endpoint using the provided credentials.
@param accessKey access key
@param secretKey secret key
@param httpMethod the method (GET, POST...)
@param endpointURL protocol://host:port
@param reqPath the API resource path relative to the endpointURL
@param headers headers map
@param par... | [
"Builds",
"and",
"signs",
"a",
"request",
"to",
"an",
"API",
"endpoint",
"using",
"the",
"provided",
"credentials",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-core/src/main/java/com/erudika/para/rest/Signer.java#L268-L308 |
122,152 | Erudika/para | para-core/src/main/java/com/erudika/para/validation/ValidationUtils.java | ValidationUtils.validateObject | public static String[] validateObject(ParaObject content) {
if (content == null) {
return new String[]{"Object cannot be null."};
}
LinkedList<String> list = new LinkedList<>();
try {
for (ConstraintViolation<ParaObject> constraintViolation : getValidator().validate(content)) {
String prop = "'".conca... | java | public static String[] validateObject(ParaObject content) {
if (content == null) {
return new String[]{"Object cannot be null."};
}
LinkedList<String> list = new LinkedList<>();
try {
for (ConstraintViolation<ParaObject> constraintViolation : getValidator().validate(content)) {
String prop = "'".conca... | [
"public",
"static",
"String",
"[",
"]",
"validateObject",
"(",
"ParaObject",
"content",
")",
"{",
"if",
"(",
"content",
"==",
"null",
")",
"{",
"return",
"new",
"String",
"[",
"]",
"{",
"\"Object cannot be null.\"",
"}",
";",
"}",
"LinkedList",
"<",
"Strin... | Validates objects using Hibernate Validator.
@param content an object to be validated
@return a list of error messages or empty if object is valid | [
"Validates",
"objects",
"using",
"Hibernate",
"Validator",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-core/src/main/java/com/erudika/para/validation/ValidationUtils.java#L117-L131 |
122,153 | Erudika/para | para-core/src/main/java/com/erudika/para/validation/ValidationUtils.java | ValidationUtils.validateObject | public static String[] validateObject(App app, ParaObject content) {
if (content == null || app == null) {
return new String[]{"Object cannot be null."};
}
try {
String type = content.getType();
boolean isCustomType = (content instanceof Sysprop) && !type.equals(Utils.type(Sysprop.class));
// Validate... | java | public static String[] validateObject(App app, ParaObject content) {
if (content == null || app == null) {
return new String[]{"Object cannot be null."};
}
try {
String type = content.getType();
boolean isCustomType = (content instanceof Sysprop) && !type.equals(Utils.type(Sysprop.class));
// Validate... | [
"public",
"static",
"String",
"[",
"]",
"validateObject",
"(",
"App",
"app",
",",
"ParaObject",
"content",
")",
"{",
"if",
"(",
"content",
"==",
"null",
"||",
"app",
"==",
"null",
")",
"{",
"return",
"new",
"String",
"[",
"]",
"{",
"\"Object cannot be nu... | Validates objects.
@param content an object to be validated
@param app the current app
@return a list of error messages or empty if object is valid | [
"Validates",
"objects",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-core/src/main/java/com/erudika/para/validation/ValidationUtils.java#L139-L172 |
122,154 | Erudika/para | para-core/src/main/java/com/erudika/para/validation/ValidationUtils.java | ValidationUtils.getCoreValidationConstraints | public static Map<String, Map<String, Map<String, Map<String, ?>>>> getCoreValidationConstraints() {
if (CORE_CONSTRAINTS.isEmpty()) {
for (Map.Entry<String, Class<? extends ParaObject>> e : ParaObjectUtils.getCoreClassesMap().entrySet()) {
String type = e.getKey();
List<Field> fieldlist = Utils.getAllDecl... | java | public static Map<String, Map<String, Map<String, Map<String, ?>>>> getCoreValidationConstraints() {
if (CORE_CONSTRAINTS.isEmpty()) {
for (Map.Entry<String, Class<? extends ParaObject>> e : ParaObjectUtils.getCoreClassesMap().entrySet()) {
String type = e.getKey();
List<Field> fieldlist = Utils.getAllDecl... | [
"public",
"static",
"Map",
"<",
"String",
",",
"Map",
"<",
"String",
",",
"Map",
"<",
"String",
",",
"Map",
"<",
"String",
",",
"?",
">",
">",
">",
">",
"getCoreValidationConstraints",
"(",
")",
"{",
"if",
"(",
"CORE_CONSTRAINTS",
".",
"isEmpty",
"(",
... | Returns all validation constraints that are defined by Java annotation in the core classes.
@return a map of all core types to all core annotated constraints. See JSR-303. | [
"Returns",
"all",
"validation",
"constraints",
"that",
"are",
"defined",
"by",
"Java",
"annotation",
"in",
"the",
"core",
"classes",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-core/src/main/java/com/erudika/para/validation/ValidationUtils.java#L237-L265 |
122,155 | Erudika/para | para-server/src/main/java/com/erudika/para/aop/IndexAndCacheAspect.java | IndexAndCacheAspect.invoke | public Object invoke(MethodInvocation mi) throws Throwable {
if (!Modifier.isPublic(mi.getMethod().getModifiers())) {
return mi.proceed();
}
Method daoMethod = mi.getMethod();
Object[] args = mi.getArguments();
String appid = AOPUtils.getFirstArgOfString(args);
Method superMethod = null;
Indexed inde... | java | public Object invoke(MethodInvocation mi) throws Throwable {
if (!Modifier.isPublic(mi.getMethod().getModifiers())) {
return mi.proceed();
}
Method daoMethod = mi.getMethod();
Object[] args = mi.getArguments();
String appid = AOPUtils.getFirstArgOfString(args);
Method superMethod = null;
Indexed inde... | [
"public",
"Object",
"invoke",
"(",
"MethodInvocation",
"mi",
")",
"throws",
"Throwable",
"{",
"if",
"(",
"!",
"Modifier",
".",
"isPublic",
"(",
"mi",
".",
"getMethod",
"(",
")",
".",
"getModifiers",
"(",
")",
")",
")",
"{",
"return",
"mi",
".",
"procee... | Executes code when a method is invoked. A big switch statement.
@param mi method invocation
@return the returned value of the method invoked or something else (decided here)
@throws Throwable error | [
"Executes",
"code",
"when",
"a",
"method",
"is",
"invoked",
".",
"A",
"big",
"switch",
"statement",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/aop/IndexAndCacheAspect.java#L101-L148 |
122,156 | Erudika/para | para-core/src/main/java/com/erudika/para/metrics/Metrics.java | Metrics.time | public static Context time(String appid, Class<?> clazz, String... names) {
String className = getClassName(clazz);
Timer systemTimer = getTimer(SYSTEM_METRICS_NAME, className, names);
Timer appTimer = appid == null || appid.isEmpty() ? null : getTimer(appid, className, names);
return new Context(systemTimer, a... | java | public static Context time(String appid, Class<?> clazz, String... names) {
String className = getClassName(clazz);
Timer systemTimer = getTimer(SYSTEM_METRICS_NAME, className, names);
Timer appTimer = appid == null || appid.isEmpty() ? null : getTimer(appid, className, names);
return new Context(systemTimer, a... | [
"public",
"static",
"Context",
"time",
"(",
"String",
"appid",
",",
"Class",
"<",
"?",
">",
"clazz",
",",
"String",
"...",
"names",
")",
"{",
"String",
"className",
"=",
"getClassName",
"(",
"clazz",
")",
";",
"Timer",
"systemTimer",
"=",
"getTimer",
"("... | Instantiate timing of a particular class and method for a specific application.
@param appid the application that invoked the request
@param clazz the Class to be timed
@param names one or more unique names to identify the timer - usually a method name
@return a closeable context that encapsulates the timed method | [
"Instantiate",
"timing",
"of",
"a",
"particular",
"class",
"and",
"method",
"for",
"a",
"specific",
"application",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-core/src/main/java/com/erudika/para/metrics/Metrics.java#L71-L76 |
122,157 | Erudika/para | para-core/src/main/java/com/erudika/para/metrics/Metrics.java | Metrics.counter | public static Counter counter(String appid, Class<?> clazz, String... names) {
String className = getClassName(clazz);
return getCounter(App.isRoot(appid) ? SYSTEM_METRICS_NAME : appid, className, names);
} | java | public static Counter counter(String appid, Class<?> clazz, String... names) {
String className = getClassName(clazz);
return getCounter(App.isRoot(appid) ? SYSTEM_METRICS_NAME : appid, className, names);
} | [
"public",
"static",
"Counter",
"counter",
"(",
"String",
"appid",
",",
"Class",
"<",
"?",
">",
"clazz",
",",
"String",
"...",
"names",
")",
"{",
"String",
"className",
"=",
"getClassName",
"(",
"clazz",
")",
";",
"return",
"getCounter",
"(",
"App",
".",
... | Creates a new counter for a particular class and method for a specific application.
@param appid the application that invoked the request
@param clazz the Class to be counted
@param names one or more unique names to identify the counter - usually a method name
@return a counter | [
"Creates",
"a",
"new",
"counter",
"for",
"a",
"particular",
"class",
"and",
"method",
"for",
"a",
"specific",
"application",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-core/src/main/java/com/erudika/para/metrics/Metrics.java#L86-L89 |
122,158 | Erudika/para | para-server/src/main/java/com/erudika/para/security/filters/FacebookAuthFilter.java | FacebookAuthFilter.getOrCreateUser | @SuppressWarnings("unchecked")
public UserAuthentication getOrCreateUser(App app, String accessToken) throws IOException {
UserAuthentication userAuth = null;
User user = new User();
if (accessToken != null) {
String ctype = null;
HttpEntity respEntity = null;
CloseableHttpResponse resp2 = null;
try ... | java | @SuppressWarnings("unchecked")
public UserAuthentication getOrCreateUser(App app, String accessToken) throws IOException {
UserAuthentication userAuth = null;
User user = new User();
if (accessToken != null) {
String ctype = null;
HttpEntity respEntity = null;
CloseableHttpResponse resp2 = null;
try ... | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"UserAuthentication",
"getOrCreateUser",
"(",
"App",
"app",
",",
"String",
"accessToken",
")",
"throws",
"IOException",
"{",
"UserAuthentication",
"userAuth",
"=",
"null",
";",
"User",
"user",
"=",
"new... | Calls the Facebook API to get the user profile using a given access token.
@param app the app where the user will be created, use null for root app
@param accessToken access token
@return {@link UserAuthentication} object or null if something went wrong
@throws IOException ex | [
"Calls",
"the",
"Facebook",
"API",
"to",
"get",
"the",
"user",
"profile",
"using",
"a",
"given",
"access",
"token",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/security/filters/FacebookAuthFilter.java#L128-L192 |
122,159 | Erudika/para | para-server/src/main/java/com/erudika/para/security/SecurityUtils.java | SecurityUtils.getAuthenticatedUser | public static User getAuthenticatedUser(Authentication auth) {
User user = null;
if (auth != null && auth.isAuthenticated() && auth.getPrincipal() instanceof AuthenticatedUserDetails) {
user = ((AuthenticatedUserDetails) auth.getPrincipal()).getUser();
}
return user;
} | java | public static User getAuthenticatedUser(Authentication auth) {
User user = null;
if (auth != null && auth.isAuthenticated() && auth.getPrincipal() instanceof AuthenticatedUserDetails) {
user = ((AuthenticatedUserDetails) auth.getPrincipal()).getUser();
}
return user;
} | [
"public",
"static",
"User",
"getAuthenticatedUser",
"(",
"Authentication",
"auth",
")",
"{",
"User",
"user",
"=",
"null",
";",
"if",
"(",
"auth",
"!=",
"null",
"&&",
"auth",
".",
"isAuthenticated",
"(",
")",
"&&",
"auth",
".",
"getPrincipal",
"(",
")",
"... | Extracts a User object from the security context.
@param auth the authentication object
@return an authenticated user or null if a user is not authenticated | [
"Extracts",
"a",
"User",
"object",
"from",
"the",
"security",
"context",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/security/SecurityUtils.java#L82-L88 |
122,160 | Erudika/para | para-server/src/main/java/com/erudika/para/security/SecurityUtils.java | SecurityUtils.getAuthenticatedApp | public static App getAuthenticatedApp() {
App app = null;
if (SecurityContextHolder.getContext().getAuthentication() != null) {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
if (auth.isAuthenticated() && auth.getPrincipal() instanceof App) {
app = (App) auth.getPrincipal();... | java | public static App getAuthenticatedApp() {
App app = null;
if (SecurityContextHolder.getContext().getAuthentication() != null) {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
if (auth.isAuthenticated() && auth.getPrincipal() instanceof App) {
app = (App) auth.getPrincipal();... | [
"public",
"static",
"App",
"getAuthenticatedApp",
"(",
")",
"{",
"App",
"app",
"=",
"null",
";",
"if",
"(",
"SecurityContextHolder",
".",
"getContext",
"(",
")",
".",
"getAuthentication",
"(",
")",
"!=",
"null",
")",
"{",
"Authentication",
"auth",
"=",
"Se... | Extracts a App object from the security context.
@return an authenticated app or null if a app is not authenticated | [
"Extracts",
"a",
"App",
"object",
"from",
"the",
"security",
"context",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/security/SecurityUtils.java#L94-L103 |
122,161 | Erudika/para | para-server/src/main/java/com/erudika/para/security/SecurityUtils.java | SecurityUtils.checkImplicitAppPermissions | public static boolean checkImplicitAppPermissions(App app, ParaObject object) {
if (app != null && object != null) {
return isNotAnApp(object.getType()) || app.getId().equals(object.getId()) || app.isRootApp();
}
return false;
} | java | public static boolean checkImplicitAppPermissions(App app, ParaObject object) {
if (app != null && object != null) {
return isNotAnApp(object.getType()) || app.getId().equals(object.getId()) || app.isRootApp();
}
return false;
} | [
"public",
"static",
"boolean",
"checkImplicitAppPermissions",
"(",
"App",
"app",
",",
"ParaObject",
"object",
")",
"{",
"if",
"(",
"app",
"!=",
"null",
"&&",
"object",
"!=",
"null",
")",
"{",
"return",
"isNotAnApp",
"(",
"object",
".",
"getType",
"(",
")",... | An app can edit itself or delete itself. It can't read, edit, overwrite or delete other apps, unless it is the
root app.
@param app an app
@param object another object
@return true if app passes the check | [
"An",
"app",
"can",
"edit",
"itself",
"or",
"delete",
"itself",
".",
"It",
"can",
"t",
"read",
"edit",
"overwrite",
"or",
"delete",
"other",
"apps",
"unless",
"it",
"is",
"the",
"root",
"app",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/security/SecurityUtils.java#L169-L174 |
122,162 | Erudika/para | para-server/src/main/java/com/erudika/para/security/SecurityUtils.java | SecurityUtils.checkIfUserCanModifyObject | public static boolean checkIfUserCanModifyObject(App app, ParaObject object) {
User user = SecurityUtils.getAuthenticatedUser();
if (user != null && app != null && object != null) {
if (app.permissionsContainOwnKeyword(user, object)) {
return user.canModify(object);
}
}
return true; // skip
} | java | public static boolean checkIfUserCanModifyObject(App app, ParaObject object) {
User user = SecurityUtils.getAuthenticatedUser();
if (user != null && app != null && object != null) {
if (app.permissionsContainOwnKeyword(user, object)) {
return user.canModify(object);
}
}
return true; // skip
} | [
"public",
"static",
"boolean",
"checkIfUserCanModifyObject",
"(",
"App",
"app",
",",
"ParaObject",
"object",
")",
"{",
"User",
"user",
"=",
"SecurityUtils",
".",
"getAuthenticatedUser",
"(",
")",
";",
"if",
"(",
"user",
"!=",
"null",
"&&",
"app",
"!=",
"null... | Check if a user can modify an object. If there's no user principal found, this returns true.
@param app app in context
@param object some object
@return true if user is the owner/creator of the object. | [
"Check",
"if",
"a",
"user",
"can",
"modify",
"an",
"object",
".",
"If",
"there",
"s",
"no",
"user",
"principal",
"found",
"this",
"returns",
"true",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/security/SecurityUtils.java#L200-L208 |
122,163 | Erudika/para | para-server/src/main/java/com/erudika/para/security/SecurityUtils.java | SecurityUtils.clearSession | public static void clearSession(HttpServletRequest req) {
SecurityContextHolder.clearContext();
if (req != null) {
HttpSession session = req.getSession(false);
if (session != null) {
session.invalidate();
}
}
} | java | public static void clearSession(HttpServletRequest req) {
SecurityContextHolder.clearContext();
if (req != null) {
HttpSession session = req.getSession(false);
if (session != null) {
session.invalidate();
}
}
} | [
"public",
"static",
"void",
"clearSession",
"(",
"HttpServletRequest",
"req",
")",
"{",
"SecurityContextHolder",
".",
"clearContext",
"(",
")",
";",
"if",
"(",
"req",
"!=",
"null",
")",
"{",
"HttpSession",
"session",
"=",
"req",
".",
"getSession",
"(",
"fals... | Clears the session. Deletes cookies and clears the security context.
@param req HTTP request | [
"Clears",
"the",
"session",
".",
"Deletes",
"cookies",
"and",
"clears",
"the",
"security",
"context",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/security/SecurityUtils.java#L214-L222 |
122,164 | Erudika/para | para-server/src/main/java/com/erudika/para/security/SecurityUtils.java | SecurityUtils.isValidJWToken | public static boolean isValidJWToken(String secret, SignedJWT jwt) {
try {
if (secret != null && jwt != null) {
JWSVerifier verifier = new MACVerifier(secret);
if (jwt.verify(verifier)) {
Date referenceTime = new Date();
JWTClaimsSet claims = jwt.getJWTClaimsSet();
Date expirationTime = cla... | java | public static boolean isValidJWToken(String secret, SignedJWT jwt) {
try {
if (secret != null && jwt != null) {
JWSVerifier verifier = new MACVerifier(secret);
if (jwt.verify(verifier)) {
Date referenceTime = new Date();
JWTClaimsSet claims = jwt.getJWTClaimsSet();
Date expirationTime = cla... | [
"public",
"static",
"boolean",
"isValidJWToken",
"(",
"String",
"secret",
",",
"SignedJWT",
"jwt",
")",
"{",
"try",
"{",
"if",
"(",
"secret",
"!=",
"null",
"&&",
"jwt",
"!=",
"null",
")",
"{",
"JWSVerifier",
"verifier",
"=",
"new",
"MACVerifier",
"(",
"s... | Validates a JWT token.
@param secret secret used for generating the token
@param jwt token to validate
@return true if token is valid | [
"Validates",
"a",
"JWT",
"token",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/security/SecurityUtils.java#L230-L252 |
122,165 | Erudika/para | para-server/src/main/java/com/erudika/para/security/SecurityUtils.java | SecurityUtils.generateJWToken | public static SignedJWT generateJWToken(User user, App app) {
if (app != null) {
try {
Date now = new Date();
JWTClaimsSet.Builder claimsSet = new JWTClaimsSet.Builder();
String userSecret = "";
claimsSet.issueTime(now);
claimsSet.expirationTime(new Date(now.getTime() + (app.getTokenValiditySec... | java | public static SignedJWT generateJWToken(User user, App app) {
if (app != null) {
try {
Date now = new Date();
JWTClaimsSet.Builder claimsSet = new JWTClaimsSet.Builder();
String userSecret = "";
claimsSet.issueTime(now);
claimsSet.expirationTime(new Date(now.getTime() + (app.getTokenValiditySec... | [
"public",
"static",
"SignedJWT",
"generateJWToken",
"(",
"User",
"user",
",",
"App",
"app",
")",
"{",
"if",
"(",
"app",
"!=",
"null",
")",
"{",
"try",
"{",
"Date",
"now",
"=",
"new",
"Date",
"(",
")",
";",
"JWTClaimsSet",
".",
"Builder",
"claimsSet",
... | Generates a new JWT token.
@param user a User object belonging to the app
@param app the app object
@return a new JWT or null | [
"Generates",
"a",
"new",
"JWT",
"token",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/security/SecurityUtils.java#L269-L293 |
122,166 | Erudika/para | para-server/src/main/java/com/erudika/para/security/SecurityUtils.java | SecurityUtils.getNextRefresh | private static long getNextRefresh(long tokenValiditySec) {
long interval = Config.JWT_REFRESH_INTERVAL_SEC;
// estimate when the next token refresh should be
// usually every hour, or halfway until the time it expires
if (tokenValiditySec < (2 * interval)) {
interval = (tokenValiditySec / 2);
}
return S... | java | private static long getNextRefresh(long tokenValiditySec) {
long interval = Config.JWT_REFRESH_INTERVAL_SEC;
// estimate when the next token refresh should be
// usually every hour, or halfway until the time it expires
if (tokenValiditySec < (2 * interval)) {
interval = (tokenValiditySec / 2);
}
return S... | [
"private",
"static",
"long",
"getNextRefresh",
"(",
"long",
"tokenValiditySec",
")",
"{",
"long",
"interval",
"=",
"Config",
".",
"JWT_REFRESH_INTERVAL_SEC",
";",
"// estimate when the next token refresh should be",
"// usually every hour, or halfway until the time it expires",
"... | Decides when the next token refresh should be.
@param tokenValiditySec token validity period
@return a refresh timestamp to be used by API clients | [
"Decides",
"when",
"the",
"next",
"token",
"refresh",
"should",
"be",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/security/SecurityUtils.java#L300-L308 |
122,167 | Erudika/para | para-server/src/main/java/com/erudika/para/security/SecurityUtils.java | SecurityUtils.getOAuthKeysForApp | public static String[] getOAuthKeysForApp(App app, String prefix) {
prefix = StringUtils.removeEnd(prefix + "", Config.SEPARATOR);
String appIdKey = prefix + "_app_id";
String secretKey = prefix + "_secret";
String[] keys = new String[]{"", ""};
if (app != null) {
Map<String, Object> settings = app.getSet... | java | public static String[] getOAuthKeysForApp(App app, String prefix) {
prefix = StringUtils.removeEnd(prefix + "", Config.SEPARATOR);
String appIdKey = prefix + "_app_id";
String secretKey = prefix + "_secret";
String[] keys = new String[]{"", ""};
if (app != null) {
Map<String, Object> settings = app.getSet... | [
"public",
"static",
"String",
"[",
"]",
"getOAuthKeysForApp",
"(",
"App",
"app",
",",
"String",
"prefix",
")",
"{",
"prefix",
"=",
"StringUtils",
".",
"removeEnd",
"(",
"prefix",
"+",
"\"\"",
",",
"Config",
".",
"SEPARATOR",
")",
";",
"String",
"appIdKey",... | Return the OAuth app ID and secret key for a given app by reading the app settings, or the config file.
@param app the app in which to look for these keys
@param prefix a service prefix: "fb" for facebook, "tw" for twitter etc. See {@link Config}
@return an array ["app_id", "secret_key"] or ["", ""] | [
"Return",
"the",
"OAuth",
"app",
"ID",
"and",
"secret",
"key",
"for",
"a",
"given",
"app",
"by",
"reading",
"the",
"app",
"settings",
"or",
"the",
"config",
"file",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/security/SecurityUtils.java#L316-L333 |
122,168 | Erudika/para | para-server/src/main/java/com/erudika/para/security/SecurityUtils.java | SecurityUtils.getLdapSettingsForApp | public static Map<String, String> getLdapSettingsForApp(App app) {
Map<String, String> ldapSettings = new HashMap<>();
if (app != null) {
ldapSettings.put("security.ldap.server_url", "ldap://localhost:8389/");
ldapSettings.put("security.ldap.active_directory_domain", "");
ldapSettings.put("security.ldap.ba... | java | public static Map<String, String> getLdapSettingsForApp(App app) {
Map<String, String> ldapSettings = new HashMap<>();
if (app != null) {
ldapSettings.put("security.ldap.server_url", "ldap://localhost:8389/");
ldapSettings.put("security.ldap.active_directory_domain", "");
ldapSettings.put("security.ldap.ba... | [
"public",
"static",
"Map",
"<",
"String",
",",
"String",
">",
"getLdapSettingsForApp",
"(",
"App",
"app",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"ldapSettings",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"if",
"(",
"app",
"!=",
"null",
... | Returns a map of LDAP configuration properties for a given app, read from app.settings or config file.
@param app the app in which to look for these keys
@return a map of keys and values | [
"Returns",
"a",
"map",
"of",
"LDAP",
"configuration",
"properties",
"for",
"a",
"given",
"app",
"read",
"from",
"app",
".",
"settings",
"or",
"config",
"file",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/security/SecurityUtils.java#L340-L363 |
122,169 | Erudika/para | para-server/src/main/java/com/erudika/para/security/SecurityUtils.java | SecurityUtils.getSettingForApp | public static String getSettingForApp(App app, String key, String defaultValue) {
if (app != null) {
Map<String, Object> settings = app.getSettings();
if (settings.containsKey(key)) {
return String.valueOf(settings.getOrDefault(key, defaultValue));
} else if (app.isRootApp()) {
return Config.getConfi... | java | public static String getSettingForApp(App app, String key, String defaultValue) {
if (app != null) {
Map<String, Object> settings = app.getSettings();
if (settings.containsKey(key)) {
return String.valueOf(settings.getOrDefault(key, defaultValue));
} else if (app.isRootApp()) {
return Config.getConfi... | [
"public",
"static",
"String",
"getSettingForApp",
"(",
"App",
"app",
",",
"String",
"key",
",",
"String",
"defaultValue",
")",
"{",
"if",
"(",
"app",
"!=",
"null",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"settings",
"=",
"app",
".",
"getSet... | Returns the value of the app setting, read from from app.settings or from the config file if app is root.
@param app the app in which to look for these keys
@param key setting key
@param defaultValue default value
@return the value of the configuration property as string | [
"Returns",
"the",
"value",
"of",
"the",
"app",
"setting",
"read",
"from",
"from",
"app",
".",
"settings",
"or",
"from",
"the",
"config",
"file",
"if",
"app",
"is",
"root",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/security/SecurityUtils.java#L372-L382 |
122,170 | Erudika/para | para-server/src/main/java/com/erudika/para/security/SecurityUtils.java | SecurityUtils.checkIfActive | public static UserAuthentication checkIfActive(UserAuthentication userAuth, User user, boolean throwException) {
if (userAuth == null || user == null || user.getIdentifier() == null) {
if (throwException) {
throw new BadCredentialsException("Bad credentials.");
} else {
logger.debug("Bad credentials. {}... | java | public static UserAuthentication checkIfActive(UserAuthentication userAuth, User user, boolean throwException) {
if (userAuth == null || user == null || user.getIdentifier() == null) {
if (throwException) {
throw new BadCredentialsException("Bad credentials.");
} else {
logger.debug("Bad credentials. {}... | [
"public",
"static",
"UserAuthentication",
"checkIfActive",
"(",
"UserAuthentication",
"userAuth",
",",
"User",
"user",
",",
"boolean",
"throwException",
")",
"{",
"if",
"(",
"userAuth",
"==",
"null",
"||",
"user",
"==",
"null",
"||",
"user",
".",
"getIdentifier"... | Checks if account is active.
@param userAuth user authentication object
@param user user object
@param throwException throw or not
@return the authentication object if {@code user.active == true} | [
"Checks",
"if",
"account",
"is",
"active",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/security/SecurityUtils.java#L391-L409 |
122,171 | Erudika/para | para-server/src/main/java/com/erudika/para/security/SecurityUtils.java | SecurityUtils.isValidSignature | public static boolean isValidSignature(HttpServletRequest incoming, String secretKey) {
if (incoming == null || StringUtils.isBlank(secretKey)) {
return false;
}
String auth = incoming.getHeader(HttpHeaders.AUTHORIZATION);
String givenSig = StringUtils.substringAfter(auth, "Signature=");
String sigHeaders ... | java | public static boolean isValidSignature(HttpServletRequest incoming, String secretKey) {
if (incoming == null || StringUtils.isBlank(secretKey)) {
return false;
}
String auth = incoming.getHeader(HttpHeaders.AUTHORIZATION);
String givenSig = StringUtils.substringAfter(auth, "Signature=");
String sigHeaders ... | [
"public",
"static",
"boolean",
"isValidSignature",
"(",
"HttpServletRequest",
"incoming",
",",
"String",
"secretKey",
")",
"{",
"if",
"(",
"incoming",
"==",
"null",
"||",
"StringUtils",
".",
"isBlank",
"(",
"secretKey",
")",
")",
"{",
"return",
"false",
";",
... | Validates the signature of the request.
@param incoming the incoming HTTP request containing a signature
@param secretKey the app's secret key
@return true if the signature is valid | [
"Validates",
"the",
"signature",
"of",
"the",
"request",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/security/SecurityUtils.java#L417-L469 |
122,172 | Erudika/para | para-core/src/main/java/com/erudika/para/Para.java | Para.initialize | public static void initialize() {
if (isInitialized) {
return;
}
isInitialized = true;
printLogo();
try {
logger.info("--- Para.initialize() [{}] ---", Config.ENVIRONMENT);
for (InitializeListener initListener : INIT_LISTENERS) {
if (initListener != null) {
initListener.onInitialize();
... | java | public static void initialize() {
if (isInitialized) {
return;
}
isInitialized = true;
printLogo();
try {
logger.info("--- Para.initialize() [{}] ---", Config.ENVIRONMENT);
for (InitializeListener initListener : INIT_LISTENERS) {
if (initListener != null) {
initListener.onInitialize();
... | [
"public",
"static",
"void",
"initialize",
"(",
")",
"{",
"if",
"(",
"isInitialized",
")",
"{",
"return",
";",
"}",
"isInitialized",
"=",
"true",
";",
"printLogo",
"(",
")",
";",
"try",
"{",
"logger",
".",
"info",
"(",
"\"--- Para.initialize() [{}] ---\"",
... | Executes all initialize listeners and prints logo. Call this method first. | [
"Executes",
"all",
"initialize",
"listeners",
"and",
"prints",
"logo",
".",
"Call",
"this",
"method",
"first",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-core/src/main/java/com/erudika/para/Para.java#L99-L118 |
122,173 | Erudika/para | para-core/src/main/java/com/erudika/para/Para.java | Para.destroy | public static void destroy() {
try {
logger.info("--- Para.destroy() ---");
for (DestroyListener destroyListener : DESTROY_LISTENERS) {
if (destroyListener != null) {
destroyListener.onDestroy();
logger.debug("Executed {}.onDestroy().", destroyListener.getClass().getName());
}
}
if (!EXE... | java | public static void destroy() {
try {
logger.info("--- Para.destroy() ---");
for (DestroyListener destroyListener : DESTROY_LISTENERS) {
if (destroyListener != null) {
destroyListener.onDestroy();
logger.debug("Executed {}.onDestroy().", destroyListener.getClass().getName());
}
}
if (!EXE... | [
"public",
"static",
"void",
"destroy",
"(",
")",
"{",
"try",
"{",
"logger",
".",
"info",
"(",
"\"--- Para.destroy() ---\"",
")",
";",
"for",
"(",
"DestroyListener",
"destroyListener",
":",
"DESTROY_LISTENERS",
")",
"{",
"if",
"(",
"destroyListener",
"!=",
"nul... | Calls all registered listeners on exit. Call this method last. | [
"Calls",
"all",
"registered",
"listeners",
"on",
"exit",
".",
"Call",
"this",
"method",
"last",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-core/src/main/java/com/erudika/para/Para.java#L123-L143 |
122,174 | Erudika/para | para-core/src/main/java/com/erudika/para/Para.java | Para.setup | public static Map<String, String> setup() {
return newApp(Config.getRootAppIdentifier(), Config.APP_NAME, false, false);
} | java | public static Map<String, String> setup() {
return newApp(Config.getRootAppIdentifier(), Config.APP_NAME, false, false);
} | [
"public",
"static",
"Map",
"<",
"String",
",",
"String",
">",
"setup",
"(",
")",
"{",
"return",
"newApp",
"(",
"Config",
".",
"getRootAppIdentifier",
"(",
")",
",",
"Config",
".",
"APP_NAME",
",",
"false",
",",
"false",
")",
";",
"}"
] | Creates the root application and returns the credentials for it.
@return credentials for the root app | [
"Creates",
"the",
"root",
"application",
"and",
"returns",
"the",
"credentials",
"for",
"it",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-core/src/main/java/com/erudika/para/Para.java#L344-L346 |
122,175 | Erudika/para | para-core/src/main/java/com/erudika/para/Para.java | Para.newApp | public static Map<String, String> newApp(String appid, String name, boolean sharedTable, boolean sharedIndex) {
Map<String, String> creds = new TreeMap<>();
creds.put("message", "All set!");
if (StringUtils.isBlank(appid)) {
return creds;
}
App app = new App(appid);
if (!app.exists()) {
app.setName(na... | java | public static Map<String, String> newApp(String appid, String name, boolean sharedTable, boolean sharedIndex) {
Map<String, String> creds = new TreeMap<>();
creds.put("message", "All set!");
if (StringUtils.isBlank(appid)) {
return creds;
}
App app = new App(appid);
if (!app.exists()) {
app.setName(na... | [
"public",
"static",
"Map",
"<",
"String",
",",
"String",
">",
"newApp",
"(",
"String",
"appid",
",",
"String",
"name",
",",
"boolean",
"sharedTable",
",",
"boolean",
"sharedIndex",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"creds",
"=",
"new",
... | Creates a new application and returns the credentials for it.
@param appid the app identifier
@param name the full name of the app
@param sharedTable false if the app should have its own table
@param sharedIndex false if the app should have its own index
@return credentials for the root app | [
"Creates",
"a",
"new",
"application",
"and",
"returns",
"the",
"credentials",
"for",
"it",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-core/src/main/java/com/erudika/para/Para.java#L356-L380 |
122,176 | Erudika/para | para-server/src/main/java/com/erudika/para/i18n/LanguageUtils.java | LanguageUtils.readLanguage | public Map<String, String> readLanguage(String appid, String langCode) {
if (StringUtils.isBlank(langCode) || langCode.equals(getDefaultLanguageCode())) {
return getDefaultLanguage(appid);
} else if (langCode.length() > 2 && !ALL_LOCALES.containsKey(langCode)) {
return readLanguage(appid, langCode.substring(0... | java | public Map<String, String> readLanguage(String appid, String langCode) {
if (StringUtils.isBlank(langCode) || langCode.equals(getDefaultLanguageCode())) {
return getDefaultLanguage(appid);
} else if (langCode.length() > 2 && !ALL_LOCALES.containsKey(langCode)) {
return readLanguage(appid, langCode.substring(0... | [
"public",
"Map",
"<",
"String",
",",
"String",
">",
"readLanguage",
"(",
"String",
"appid",
",",
"String",
"langCode",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isBlank",
"(",
"langCode",
")",
"||",
"langCode",
".",
"equals",
"(",
"getDefaultLanguageCode",
... | Returns a map of all translations for a given language.
Defaults to the default language which must be set.
@param appid appid name of the {@link com.erudika.para.core.App}
@param langCode the 2-letter language code
@return the language map | [
"Returns",
"a",
"map",
"of",
"all",
"translations",
"for",
"a",
"given",
"language",
".",
"Defaults",
"to",
"the",
"default",
"language",
"which",
"must",
"be",
"set",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/i18n/LanguageUtils.java#L106-L134 |
122,177 | Erudika/para | para-server/src/main/java/com/erudika/para/i18n/LanguageUtils.java | LanguageUtils.writeLanguage | public void writeLanguage(String appid, String langCode, Map<String, String> lang, boolean writeToDatabase) {
if (lang == null || lang.isEmpty() || StringUtils.isBlank(langCode) || !ALL_LOCALES.containsKey(langCode)) {
return;
}
writeLanguageToFile(appid, langCode, lang);
if (writeToDatabase) {
// this w... | java | public void writeLanguage(String appid, String langCode, Map<String, String> lang, boolean writeToDatabase) {
if (lang == null || lang.isEmpty() || StringUtils.isBlank(langCode) || !ALL_LOCALES.containsKey(langCode)) {
return;
}
writeLanguageToFile(appid, langCode, lang);
if (writeToDatabase) {
// this w... | [
"public",
"void",
"writeLanguage",
"(",
"String",
"appid",
",",
"String",
"langCode",
",",
"Map",
"<",
"String",
",",
"String",
">",
"lang",
",",
"boolean",
"writeToDatabase",
")",
"{",
"if",
"(",
"lang",
"==",
"null",
"||",
"lang",
".",
"isEmpty",
"(",
... | Persists the language map in the data store. Overwrites any existing maps.
@param appid appid name of the {@link com.erudika.para.core.App}
@param langCode the 2-letter language code
@param lang the language map
@param writeToDatabase true if you want the language map to be stored in the DB as well | [
"Persists",
"the",
"language",
"map",
"in",
"the",
"data",
"store",
".",
"Overwrites",
"any",
"existing",
"maps",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/i18n/LanguageUtils.java#L143-L163 |
122,178 | Erudika/para | para-server/src/main/java/com/erudika/para/i18n/LanguageUtils.java | LanguageUtils.getProperLocale | public Locale getProperLocale(String langCode) {
if (StringUtils.startsWith(langCode, "zh")) {
if ("zh_tw".equalsIgnoreCase(langCode)) {
return Locale.TRADITIONAL_CHINESE;
} else {
return Locale.SIMPLIFIED_CHINESE;
}
}
String lang = StringUtils.substring(langCode, 0, 2);
lang = (StringUtils.isB... | java | public Locale getProperLocale(String langCode) {
if (StringUtils.startsWith(langCode, "zh")) {
if ("zh_tw".equalsIgnoreCase(langCode)) {
return Locale.TRADITIONAL_CHINESE;
} else {
return Locale.SIMPLIFIED_CHINESE;
}
}
String lang = StringUtils.substring(langCode, 0, 2);
lang = (StringUtils.isB... | [
"public",
"Locale",
"getProperLocale",
"(",
"String",
"langCode",
")",
"{",
"if",
"(",
"StringUtils",
".",
"startsWith",
"(",
"langCode",
",",
"\"zh\"",
")",
")",
"{",
"if",
"(",
"\"zh_tw\"",
".",
"equalsIgnoreCase",
"(",
"langCode",
")",
")",
"{",
"return... | Returns a non-null locale for a given language code.
@param langCode the 2-letter language code
@return a locale. default is English | [
"Returns",
"a",
"non",
"-",
"null",
"locale",
"for",
"a",
"given",
"language",
"code",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/i18n/LanguageUtils.java#L170-L181 |
122,179 | Erudika/para | para-server/src/main/java/com/erudika/para/i18n/LanguageUtils.java | LanguageUtils.getDefaultLanguage | public Map<String, String> getDefaultLanguage(String appid) {
if (!LANG_CACHE.containsKey(getDefaultLanguageCode())) {
logger.info("Default language map not set, loading English.");
Map<String, String> deflang = readLanguageFromFile(appid, getDefaultLanguageCode());
if (deflang != null && !deflang.isEmpty())... | java | public Map<String, String> getDefaultLanguage(String appid) {
if (!LANG_CACHE.containsKey(getDefaultLanguageCode())) {
logger.info("Default language map not set, loading English.");
Map<String, String> deflang = readLanguageFromFile(appid, getDefaultLanguageCode());
if (deflang != null && !deflang.isEmpty())... | [
"public",
"Map",
"<",
"String",
",",
"String",
">",
"getDefaultLanguage",
"(",
"String",
"appid",
")",
"{",
"if",
"(",
"!",
"LANG_CACHE",
".",
"containsKey",
"(",
"getDefaultLanguageCode",
"(",
")",
")",
")",
"{",
"logger",
".",
"info",
"(",
"\"Default lan... | Returns the default language map.
@param appid appid name of the {@link com.erudika.para.core.App}
@return the default language map or an empty map if the default isn't set. | [
"Returns",
"the",
"default",
"language",
"map",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/i18n/LanguageUtils.java#L188-L198 |
122,180 | Erudika/para | para-server/src/main/java/com/erudika/para/i18n/LanguageUtils.java | LanguageUtils.setDefaultLanguage | public void setDefaultLanguage(Map<String, String> deflang) {
if (deflang != null && !deflang.isEmpty()) {
LANG_CACHE.put(getDefaultLanguageCode(), deflang);
}
} | java | public void setDefaultLanguage(Map<String, String> deflang) {
if (deflang != null && !deflang.isEmpty()) {
LANG_CACHE.put(getDefaultLanguageCode(), deflang);
}
} | [
"public",
"void",
"setDefaultLanguage",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"deflang",
")",
"{",
"if",
"(",
"deflang",
"!=",
"null",
"&&",
"!",
"deflang",
".",
"isEmpty",
"(",
")",
")",
"{",
"LANG_CACHE",
".",
"put",
"(",
"getDefaultLanguageCo... | Sets the default language map. It is the basis language template which is to be translated.
@param deflang the default language map | [
"Sets",
"the",
"default",
"language",
"map",
".",
"It",
"is",
"the",
"basis",
"language",
"template",
"which",
"is",
"to",
"be",
"translated",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/i18n/LanguageUtils.java#L204-L208 |
122,181 | Erudika/para | para-server/src/main/java/com/erudika/para/i18n/LanguageUtils.java | LanguageUtils.readAllTranslationsForKey | public List<Translation> readAllTranslationsForKey(String appid, String locale, String key, Pager pager) {
Map<String, Object> terms = new HashMap<>(2);
terms.put("thekey", key);
terms.put("locale", locale);
return search.findTerms(appid, Utils.type(Translation.class), terms, true, pager);
} | java | public List<Translation> readAllTranslationsForKey(String appid, String locale, String key, Pager pager) {
Map<String, Object> terms = new HashMap<>(2);
terms.put("thekey", key);
terms.put("locale", locale);
return search.findTerms(appid, Utils.type(Translation.class), terms, true, pager);
} | [
"public",
"List",
"<",
"Translation",
">",
"readAllTranslationsForKey",
"(",
"String",
"appid",
",",
"String",
"locale",
",",
"String",
"key",
",",
"Pager",
"pager",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"terms",
"=",
"new",
"HashMap",
"<>",
... | Returns a list of translations for a specific string.
@param appid appid name of the {@link com.erudika.para.core.App}
@param locale a locale
@param key the string key
@param pager the pager object
@return a list of translations | [
"Returns",
"a",
"list",
"of",
"translations",
"for",
"a",
"specific",
"string",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/i18n/LanguageUtils.java#L237-L242 |
122,182 | Erudika/para | para-server/src/main/java/com/erudika/para/i18n/LanguageUtils.java | LanguageUtils.getApprovedTransKeys | public Set<String> getApprovedTransKeys(String appid, String langCode) {
HashSet<String> approvedTransKeys = new HashSet<>();
if (StringUtils.isBlank(langCode)) {
return approvedTransKeys;
}
for (Map.Entry<String, String> entry : readLanguage(appid, langCode).entrySet()) {
if (!getDefaultLanguage(appid).... | java | public Set<String> getApprovedTransKeys(String appid, String langCode) {
HashSet<String> approvedTransKeys = new HashSet<>();
if (StringUtils.isBlank(langCode)) {
return approvedTransKeys;
}
for (Map.Entry<String, String> entry : readLanguage(appid, langCode).entrySet()) {
if (!getDefaultLanguage(appid).... | [
"public",
"Set",
"<",
"String",
">",
"getApprovedTransKeys",
"(",
"String",
"appid",
",",
"String",
"langCode",
")",
"{",
"HashSet",
"<",
"String",
">",
"approvedTransKeys",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"if",
"(",
"StringUtils",
".",
"isBlan... | Returns the set of all approved translations.
@param appid appid name of the {@link com.erudika.para.core.App}
@param langCode the 2-letter language code
@return a set of keys for approved translations | [
"Returns",
"the",
"set",
"of",
"all",
"approved",
"translations",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/i18n/LanguageUtils.java#L250-L262 |
122,183 | Erudika/para | para-server/src/main/java/com/erudika/para/i18n/LanguageUtils.java | LanguageUtils.getTranslationProgressMap | public Map<String, Integer> getTranslationProgressMap(String appid) {
if (dao == null) {
return Collections.emptyMap();
}
Sysprop progress;
if (langProgressCache.getProperties().isEmpty()) {
progress = dao.read(appid, progressKey);
if (progress != null) {
langProgressCache = progress;
}
} else... | java | public Map<String, Integer> getTranslationProgressMap(String appid) {
if (dao == null) {
return Collections.emptyMap();
}
Sysprop progress;
if (langProgressCache.getProperties().isEmpty()) {
progress = dao.read(appid, progressKey);
if (progress != null) {
langProgressCache = progress;
}
} else... | [
"public",
"Map",
"<",
"String",
",",
"Integer",
">",
"getTranslationProgressMap",
"(",
"String",
"appid",
")",
"{",
"if",
"(",
"dao",
"==",
"null",
")",
"{",
"return",
"Collections",
".",
"emptyMap",
"(",
")",
";",
"}",
"Sysprop",
"progress",
";",
"if",
... | Returns a map of language codes and the percentage of translated string for that language.
@param appid appid name of the {@link com.erudika.para.core.App}
@return a map indicating translation progress | [
"Returns",
"a",
"map",
"of",
"language",
"codes",
"and",
"the",
"percentage",
"of",
"translated",
"string",
"for",
"that",
"language",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/i18n/LanguageUtils.java#L269-L302 |
122,184 | Erudika/para | para-server/src/main/java/com/erudika/para/i18n/LanguageUtils.java | LanguageUtils.approveTranslation | public boolean approveTranslation(String appid, String langCode, String key, String value) {
if (StringUtils.isBlank(langCode) || key == null || value == null || getDefaultLanguageCode().equals(langCode)) {
return false;
}
Sysprop s = dao.read(appid, keyPrefix.concat(langCode));
boolean create = false;
if ... | java | public boolean approveTranslation(String appid, String langCode, String key, String value) {
if (StringUtils.isBlank(langCode) || key == null || value == null || getDefaultLanguageCode().equals(langCode)) {
return false;
}
Sysprop s = dao.read(appid, keyPrefix.concat(langCode));
boolean create = false;
if ... | [
"public",
"boolean",
"approveTranslation",
"(",
"String",
"appid",
",",
"String",
"langCode",
",",
"String",
"key",
",",
"String",
"value",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isBlank",
"(",
"langCode",
")",
"||",
"key",
"==",
"null",
"||",
"value",
... | Approves a translation for a given language.
@param appid appid name of the {@link com.erudika.para.core.App}
@param langCode the 2-letter language code
@param key the translation key
@param value the translated string
@return true if the operation was successful | [
"Approves",
"a",
"translation",
"for",
"a",
"given",
"language",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/i18n/LanguageUtils.java#L320-L342 |
122,185 | Erudika/para | para-server/src/main/java/com/erudika/para/i18n/LanguageUtils.java | LanguageUtils.disapproveTranslation | public boolean disapproveTranslation(String appid, String langCode, String key) {
if (StringUtils.isBlank(langCode) || key == null || getDefaultLanguageCode().equals(langCode)) {
return false;
}
Sysprop s = dao.read(appid, keyPrefix.concat(langCode));
if (s != null) {
String value = getDefaultLanguage(app... | java | public boolean disapproveTranslation(String appid, String langCode, String key) {
if (StringUtils.isBlank(langCode) || key == null || getDefaultLanguageCode().equals(langCode)) {
return false;
}
Sysprop s = dao.read(appid, keyPrefix.concat(langCode));
if (s != null) {
String value = getDefaultLanguage(app... | [
"public",
"boolean",
"disapproveTranslation",
"(",
"String",
"appid",
",",
"String",
"langCode",
",",
"String",
"key",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isBlank",
"(",
"langCode",
")",
"||",
"key",
"==",
"null",
"||",
"getDefaultLanguageCode",
"(",
"... | Disapproves a translation for a given language.
@param appid appid name of the {@link com.erudika.para.core.App}
@param langCode the 2-letter language code
@param key the translation key
@return true if the operation was successful | [
"Disapproves",
"a",
"translation",
"for",
"a",
"given",
"language",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/i18n/LanguageUtils.java#L351-L367 |
122,186 | Erudika/para | para-server/src/main/java/com/erudika/para/i18n/LanguageUtils.java | LanguageUtils.updateTranslationProgressMap | private void updateTranslationProgressMap(String appid, String langCode, int value) {
if (dao == null || getDefaultLanguageCode().equals(langCode)) {
return;
}
double defsize = getDefaultLanguage(appid).size();
double approved = value;
Map<String, Integer> progress = getTranslationProgressMap(appid);
I... | java | private void updateTranslationProgressMap(String appid, String langCode, int value) {
if (dao == null || getDefaultLanguageCode().equals(langCode)) {
return;
}
double defsize = getDefaultLanguage(appid).size();
double approved = value;
Map<String, Integer> progress = getTranslationProgressMap(appid);
I... | [
"private",
"void",
"updateTranslationProgressMap",
"(",
"String",
"appid",
",",
"String",
"langCode",
",",
"int",
"value",
")",
"{",
"if",
"(",
"dao",
"==",
"null",
"||",
"getDefaultLanguageCode",
"(",
")",
".",
"equals",
"(",
"langCode",
")",
")",
"{",
"r... | Updates the progress for all languages.
@param appid appid name of the {@link com.erudika.para.core.App}
@param langCode the 2-letter language code
@param value {@link #PLUS}, {@link #MINUS} or the total percent of completion (0-100) | [
"Updates",
"the",
"progress",
"for",
"all",
"languages",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/i18n/LanguageUtils.java#L375-L409 |
122,187 | Erudika/para | para-server/src/main/java/com/erudika/para/security/UserAuthentication.java | UserAuthentication.getAuthorities | public Collection<? extends GrantedAuthority> getAuthorities() {
if (principal == null) {
return Collections.emptyList();
}
return Collections.unmodifiableCollection(principal.getAuthorities());
} | java | public Collection<? extends GrantedAuthority> getAuthorities() {
if (principal == null) {
return Collections.emptyList();
}
return Collections.unmodifiableCollection(principal.getAuthorities());
} | [
"public",
"Collection",
"<",
"?",
"extends",
"GrantedAuthority",
">",
"getAuthorities",
"(",
")",
"{",
"if",
"(",
"principal",
"==",
"null",
")",
"{",
"return",
"Collections",
".",
"emptyList",
"(",
")",
";",
"}",
"return",
"Collections",
".",
"unmodifiableC... | A list of roles for the authenticated user.
@return a list of roles | [
"A",
"list",
"of",
"roles",
"for",
"the",
"authenticated",
"user",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/security/UserAuthentication.java#L48-L53 |
122,188 | Erudika/para | para-server/src/main/java/com/erudika/para/security/SimpleAuthenticationSuccessHandler.java | SimpleAuthenticationSuccessHandler.isRestRequest | protected boolean isRestRequest(HttpServletRequest request) {
return RestRequestMatcher.INSTANCE.matches(request) || AjaxRequestMatcher.INSTANCE.matches(request);
} | java | protected boolean isRestRequest(HttpServletRequest request) {
return RestRequestMatcher.INSTANCE.matches(request) || AjaxRequestMatcher.INSTANCE.matches(request);
} | [
"protected",
"boolean",
"isRestRequest",
"(",
"HttpServletRequest",
"request",
")",
"{",
"return",
"RestRequestMatcher",
".",
"INSTANCE",
".",
"matches",
"(",
"request",
")",
"||",
"AjaxRequestMatcher",
".",
"INSTANCE",
".",
"matches",
"(",
"request",
")",
";",
... | Checks if it is a rest request.
@param request request
@return true if rest or ajax | [
"Checks",
"if",
"it",
"is",
"a",
"rest",
"request",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/security/SimpleAuthenticationSuccessHandler.java#L100-L102 |
122,189 | Erudika/para | para-server/src/main/java/com/erudika/para/security/SimpleUserService.java | SimpleUserService.loadUserByUsername | public UserDetails loadUserByUsername(String ident) {
User user = new User();
// check if the cookie has an appid prefix
// and load user from the corresponding app
if (StringUtils.contains(ident, "/")) {
String[] parts = ident.split("/");
user.setAppid(parts[0]);
ident = parts[1];
}
user.setIdenti... | java | public UserDetails loadUserByUsername(String ident) {
User user = new User();
// check if the cookie has an appid prefix
// and load user from the corresponding app
if (StringUtils.contains(ident, "/")) {
String[] parts = ident.split("/");
user.setAppid(parts[0]);
ident = parts[1];
}
user.setIdenti... | [
"public",
"UserDetails",
"loadUserByUsername",
"(",
"String",
"ident",
")",
"{",
"User",
"user",
"=",
"new",
"User",
"(",
")",
";",
"// check if the cookie has an appid prefix",
"// and load user from the corresponding app",
"if",
"(",
"StringUtils",
".",
"contains",
"(... | Loads a user from the data store.
@param ident the user identifier
@return a user object or null if user is not found | [
"Loads",
"a",
"user",
"from",
"the",
"data",
"store",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/security/SimpleUserService.java#L44-L61 |
122,190 | Erudika/para | para-server/src/main/java/com/erudika/para/security/SimpleUserService.java | SimpleUserService.loadUserDetails | public UserDetails loadUserDetails(OpenIDAuthenticationToken token) {
if (token == null) {
return null;
}
User user = new User();
user.setIdentifier(token.getIdentityUrl());
user = loadUser(user);
if (user == null) {
// create new OpenID user
String email = "email@domain.com";
String firstName... | java | public UserDetails loadUserDetails(OpenIDAuthenticationToken token) {
if (token == null) {
return null;
}
User user = new User();
user.setIdentifier(token.getIdentityUrl());
user = loadUser(user);
if (user == null) {
// create new OpenID user
String email = "email@domain.com";
String firstName... | [
"public",
"UserDetails",
"loadUserDetails",
"(",
"OpenIDAuthenticationToken",
"token",
")",
"{",
"if",
"(",
"token",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"User",
"user",
"=",
"new",
"User",
"(",
")",
";",
"user",
".",
"setIdentifier",
"(",
... | Loads a user from the data store or creates a new user from an OpenID profile.
@param token the OpenID authentication token holding the user profile
@return a user object or null if user is not found | [
"Loads",
"a",
"user",
"from",
"the",
"data",
"store",
"or",
"creates",
"a",
"new",
"user",
"from",
"an",
"OpenID",
"profile",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/security/SimpleUserService.java#L68-L121 |
122,191 | Erudika/para | para-server/src/main/java/com/erudika/para/security/SecurityConfig.java | SecurityConfig.configure | @Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
OpenIDAuthenticationProvider openidProvider = new OpenIDAuthenticationProvider();
openidProvider.setAuthenticationUserDetailsService(new SimpleUserService());
auth.authenticationProvider(openidProvider);
RememberMeAuthent... | java | @Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
OpenIDAuthenticationProvider openidProvider = new OpenIDAuthenticationProvider();
openidProvider.setAuthenticationUserDetailsService(new SimpleUserService());
auth.authenticationProvider(openidProvider);
RememberMeAuthent... | [
"@",
"Override",
"protected",
"void",
"configure",
"(",
"AuthenticationManagerBuilder",
"auth",
")",
"throws",
"Exception",
"{",
"OpenIDAuthenticationProvider",
"openidProvider",
"=",
"new",
"OpenIDAuthenticationProvider",
"(",
")",
";",
"openidProvider",
".",
"setAuthent... | Configures the authentication providers.
@param auth a builder
@throws Exception ex | [
"Configures",
"the",
"authentication",
"providers",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/security/SecurityConfig.java#L112-L126 |
122,192 | Erudika/para | para-server/src/main/java/com/erudika/para/security/SecurityConfig.java | SecurityConfig.configure | @Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().requestMatchers(IgnoredRequestMatcher.INSTANCE);
DefaultHttpFirewall firewall = new DefaultHttpFirewall();
firewall.setAllowUrlEncodedSlash(true);
web.httpFirewall(firewall);
//web.debug(true);
} | java | @Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().requestMatchers(IgnoredRequestMatcher.INSTANCE);
DefaultHttpFirewall firewall = new DefaultHttpFirewall();
firewall.setAllowUrlEncodedSlash(true);
web.httpFirewall(firewall);
//web.debug(true);
} | [
"@",
"Override",
"public",
"void",
"configure",
"(",
"WebSecurity",
"web",
")",
"throws",
"Exception",
"{",
"web",
".",
"ignoring",
"(",
")",
".",
"requestMatchers",
"(",
"IgnoredRequestMatcher",
".",
"INSTANCE",
")",
";",
"DefaultHttpFirewall",
"firewall",
"=",... | Configures the unsecured public resources.
@param web web sec object
@throws Exception ex | [
"Configures",
"the",
"unsecured",
"public",
"resources",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/security/SecurityConfig.java#L134-L141 |
122,193 | Erudika/para | para-server/src/main/java/com/erudika/para/security/SecurityConfig.java | SecurityConfig.configure | @Override
protected void configure(HttpSecurity http) throws Exception {
ConfigObject protectedResources = Config.getConfig().getObject("security.protected");
ConfigValue apiSec = Config.getConfig().getValue("security.api_security");
boolean enableRestFilter = apiSec != null && Boolean.TRUE.equals(apiSec.unwrapp... | java | @Override
protected void configure(HttpSecurity http) throws Exception {
ConfigObject protectedResources = Config.getConfig().getObject("security.protected");
ConfigValue apiSec = Config.getConfig().getValue("security.api_security");
boolean enableRestFilter = apiSec != null && Boolean.TRUE.equals(apiSec.unwrapp... | [
"@",
"Override",
"protected",
"void",
"configure",
"(",
"HttpSecurity",
"http",
")",
"throws",
"Exception",
"{",
"ConfigObject",
"protectedResources",
"=",
"Config",
".",
"getConfig",
"(",
")",
".",
"getObject",
"(",
"\"security.protected\"",
")",
";",
"ConfigValu... | Configures the protected private resources.
@param http HTTP sec object
@throws Exception ex | [
"Configures",
"the",
"protected",
"private",
"resources",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/security/SecurityConfig.java#L149-L192 |
122,194 | Erudika/para | para-core/src/main/java/com/erudika/para/validation/Constraint.java | Constraint.matches | public static boolean matches(Class<? extends Annotation> anno, String consName) {
return VALIDATORS.get(anno).equals(consName);
} | java | public static boolean matches(Class<? extends Annotation> anno, String consName) {
return VALIDATORS.get(anno).equals(consName);
} | [
"public",
"static",
"boolean",
"matches",
"(",
"Class",
"<",
"?",
"extends",
"Annotation",
">",
"anno",
",",
"String",
"consName",
")",
"{",
"return",
"VALIDATORS",
".",
"get",
"(",
"anno",
")",
".",
"equals",
"(",
"consName",
")",
";",
"}"
] | Verifies that the given annotation type corresponds to a known constraint.
@param anno annotation type
@param consName constraint name
@return true if known | [
"Verifies",
"that",
"the",
"given",
"annotation",
"type",
"corresponds",
"to",
"a",
"known",
"constraint",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-core/src/main/java/com/erudika/para/validation/Constraint.java#L144-L146 |
122,195 | Erudika/para | para-core/src/main/java/com/erudika/para/validation/Constraint.java | Constraint.fromAnnotation | public static Constraint fromAnnotation(Annotation anno) {
if (anno instanceof Min) {
return min(((Min) anno).value());
} else if (anno instanceof Max) {
return max(((Max) anno).value());
} else if (anno instanceof Size) {
return size(((Size) anno).min(), ((Size) anno).max());
} else if (anno instanceo... | java | public static Constraint fromAnnotation(Annotation anno) {
if (anno instanceof Min) {
return min(((Min) anno).value());
} else if (anno instanceof Max) {
return max(((Max) anno).value());
} else if (anno instanceof Size) {
return size(((Size) anno).min(), ((Size) anno).max());
} else if (anno instanceo... | [
"public",
"static",
"Constraint",
"fromAnnotation",
"(",
"Annotation",
"anno",
")",
"{",
"if",
"(",
"anno",
"instanceof",
"Min",
")",
"{",
"return",
"min",
"(",
"(",
"(",
"Min",
")",
"anno",
")",
".",
"value",
"(",
")",
")",
";",
"}",
"else",
"if",
... | Builds a new constraint from the annotation data.
@param anno JSR-303 annotation instance
@return a new constraint | [
"Builds",
"a",
"new",
"constraint",
"from",
"the",
"annotation",
"data",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-core/src/main/java/com/erudika/para/validation/Constraint.java#L153-L172 |
122,196 | Erudika/para | para-core/src/main/java/com/erudika/para/validation/Constraint.java | Constraint.simplePayload | static Map<String, Object> simplePayload(final String name) {
if (name == null) {
return null;
}
Map<String, Object> payload = new LinkedHashMap<>();
payload.put("message", MSG_PREFIX + name);
return payload;
} | java | static Map<String, Object> simplePayload(final String name) {
if (name == null) {
return null;
}
Map<String, Object> payload = new LinkedHashMap<>();
payload.put("message", MSG_PREFIX + name);
return payload;
} | [
"static",
"Map",
"<",
"String",
",",
"Object",
">",
"simplePayload",
"(",
"final",
"String",
"name",
")",
"{",
"if",
"(",
"name",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"Map",
"<",
"String",
",",
"Object",
">",
"payload",
"=",
"new",
"... | Creates a new map representing a simple validation constraint.
@param name the name of the constraint
@return a map | [
"Creates",
"a",
"new",
"map",
"representing",
"a",
"simple",
"validation",
"constraint",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-core/src/main/java/com/erudika/para/validation/Constraint.java#L179-L186 |
122,197 | Erudika/para | para-core/src/main/java/com/erudika/para/validation/Constraint.java | Constraint.required | public static Constraint required() {
return new Constraint("required", simplePayload("required")) {
public boolean isValid(Object actualValue) {
return !(actualValue == null || StringUtils.isBlank(actualValue.toString()));
}
};
} | java | public static Constraint required() {
return new Constraint("required", simplePayload("required")) {
public boolean isValid(Object actualValue) {
return !(actualValue == null || StringUtils.isBlank(actualValue.toString()));
}
};
} | [
"public",
"static",
"Constraint",
"required",
"(",
")",
"{",
"return",
"new",
"Constraint",
"(",
"\"required\"",
",",
"simplePayload",
"(",
"\"required\"",
")",
")",
"{",
"public",
"boolean",
"isValid",
"(",
"Object",
"actualValue",
")",
"{",
"return",
"!",
... | The 'required' constraint - marks a field as required.
@return constraint | [
"The",
"required",
"constraint",
"-",
"marks",
"a",
"field",
"as",
"required",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-core/src/main/java/com/erudika/para/validation/Constraint.java#L289-L295 |
122,198 | Erudika/para | para-core/src/main/java/com/erudika/para/validation/Constraint.java | Constraint.min | public static Constraint min(final Number min) {
return new Constraint("min", minPayload(min)) {
public boolean isValid(Object actualValue) {
return actualValue == null || (actualValue instanceof Number && min != null &&
min.longValue() <= ((Number) actualValue).longValue());
}
};
} | java | public static Constraint min(final Number min) {
return new Constraint("min", minPayload(min)) {
public boolean isValid(Object actualValue) {
return actualValue == null || (actualValue instanceof Number && min != null &&
min.longValue() <= ((Number) actualValue).longValue());
}
};
} | [
"public",
"static",
"Constraint",
"min",
"(",
"final",
"Number",
"min",
")",
"{",
"return",
"new",
"Constraint",
"(",
"\"min\"",
",",
"minPayload",
"(",
"min",
")",
")",
"{",
"public",
"boolean",
"isValid",
"(",
"Object",
"actualValue",
")",
"{",
"return",... | The 'min' constraint - field must contain a number larger than or equal to min.
@param min the minimum value
@return constraint | [
"The",
"min",
"constraint",
"-",
"field",
"must",
"contain",
"a",
"number",
"larger",
"than",
"or",
"equal",
"to",
"min",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-core/src/main/java/com/erudika/para/validation/Constraint.java#L302-L309 |
122,199 | Erudika/para | para-core/src/main/java/com/erudika/para/validation/Constraint.java | Constraint.max | public static Constraint max(final Number max) {
return new Constraint("max", maxPayload(max)) {
public boolean isValid(Object actualValue) {
return actualValue == null || (actualValue instanceof Number && max != null &&
max.longValue() >= ((Number) actualValue).longValue());
}
};
} | java | public static Constraint max(final Number max) {
return new Constraint("max", maxPayload(max)) {
public boolean isValid(Object actualValue) {
return actualValue == null || (actualValue instanceof Number && max != null &&
max.longValue() >= ((Number) actualValue).longValue());
}
};
} | [
"public",
"static",
"Constraint",
"max",
"(",
"final",
"Number",
"max",
")",
"{",
"return",
"new",
"Constraint",
"(",
"\"max\"",
",",
"maxPayload",
"(",
"max",
")",
")",
"{",
"public",
"boolean",
"isValid",
"(",
"Object",
"actualValue",
")",
"{",
"return",... | The 'max' constraint - field must contain a number smaller than or equal to max.
@param max the maximum value
@return constraint | [
"The",
"max",
"constraint",
"-",
"field",
"must",
"contain",
"a",
"number",
"smaller",
"than",
"or",
"equal",
"to",
"max",
"."
] | 5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9 | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-core/src/main/java/com/erudika/para/validation/Constraint.java#L316-L323 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.