Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5c18c21

Browse files
authored
Merge pull request lowcoder-org#221 from neon-balcony/develop
feat: move workspace & request buffer limit settings to application.yml & check org state in enterprise mode
2 parents 6e2e17c + 125cefb commit 5c18c21

File tree

7 files changed

+32
-14
lines changed

7 files changed

+32
-14
lines changed

server/api-service/openblocks-domain/src/main/java/com/openblocks/domain/organization/repository/OrganizationRepository.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
@Repository
1515
public interface OrganizationRepository extends ReactiveMongoRepository<Organization, String> {
16+
Mono<Organization> findFirstByStateMatches(OrganizationState state);
1617

1718
Flux<Organization> findByIdInAndState(Collection<String> id, OrganizationState state);
1819

server/api-service/openblocks-domain/src/main/java/com/openblocks/domain/organization/service/OrganizationServiceImpl.java

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
package com.openblocks.domain.organization.service;
22

33
import static com.openblocks.domain.organization.model.OrganizationState.ACTIVE;
4+
import static com.openblocks.domain.organization.model.OrganizationState.DELETED;
45
import static com.openblocks.domain.util.QueryDslUtils.fieldName;
56
import static com.openblocks.sdk.exception.BizError.UNABLE_TO_FIND_VALID_ORG;
67
import static com.openblocks.sdk.util.ExceptionUtils.deferredError;
8+
import static com.openblocks.sdk.util.ExceptionUtils.ofError;
79
import static com.openblocks.sdk.util.LocaleUtils.getLocale;
810
import static com.openblocks.sdk.util.LocaleUtils.getMessage;
911

1012
import java.util.Collection;
1113
import java.util.Locale;
1214

15+
import javax.annotation.Nonnull;
16+
1317
import org.apache.commons.lang3.StringUtils;
1418
import org.springframework.beans.factory.annotation.Autowired;
1519
import org.springframework.context.ApplicationContext;
@@ -114,14 +118,24 @@ public Mono<Organization> getOrganizationInEnterpriseMode() {
114118
if (commonConfig.getWorkspace().getMode() == WorkspaceMode.SAAS) {
115119
return Mono.empty();
116120
}
117-
return Mono.defer(() -> {
118-
String enterpriseOrgId = commonConfig.getWorkspace().getEnterpriseOrgId();
119-
if (StringUtils.isNotBlank(enterpriseOrgId)) {
120-
return repository.findById(enterpriseOrgId);
121-
}
122-
return Mono.empty();
123-
})
124-
.switchIfEmpty(repository.findAll().next());
121+
return getByEnterpriseOrgId()
122+
.switchIfEmpty(repository.findFirstByStateMatches(ACTIVE));
123+
}
124+
125+
@Nonnull
126+
private Mono<Organization> getByEnterpriseOrgId() {
127+
String enterpriseOrgId = commonConfig.getWorkspace().getEnterpriseOrgId();
128+
if (StringUtils.isBlank(enterpriseOrgId)) {
129+
return Mono.empty();
130+
}
131+
return repository.findById(enterpriseOrgId)
132+
.delayUntil(org -> {
133+
if (org.getState() == DELETED) {
134+
return ofError(BizError.ORG_DELETED_FOR_ENTERPRISE_MODE, "ORG_DELETED_FOR_ENTERPRISE_MODE");
135+
}
136+
return Mono.empty();
137+
}
138+
);
125139
}
126140

127141
@Override

server/api-service/openblocks-sdk/src/main/java/com/openblocks/sdk/exception/BizError.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public enum BizError {
3131
EXCEED_MAX_ORG_MEMBER_COUNT(500, 5104),
3232
UNABLE_TO_FIND_VALID_ORG(500, 5105),
3333
EXCEED_MAX_DEVELOPER_COUNT(500, 5106),
34+
ORG_DELETED_FOR_ENTERPRISE_MODE(500, 5107),
3435

3536
// GROUP related, code range 5150 - 5199
3637
INVALID_GROUP_ID(500, 5150),

server/api-service/openblocks-sdk/src/main/resources/locale_en.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,4 +269,5 @@ GOOGLESHEETS_REQUEST_ERROR=Google Sheets request failed.
269269
GOOGLESHEETS_DATASOURCE_CONFIG_ERROR=Fail to parse Google Sheets data source configuration.
270270
GOOGLESHEETS_EMPTY_ROW=No data found at this row index. Do you want to try inserting something first?
271271
APPLICATION_EDIT_ERROR_LACK_OF_DATASOURCE_PERMISSIONS=Current changes of this application will not be saved for lacking of some data sources'' permissions.
272-
CERTIFICATE_EMPTY=Certificate is empty.
272+
CERTIFICATE_EMPTY=Certificate is empty.
273+
ORG_DELETED_FOR_ENTERPRISE_MODE=Provided enterpriseOrgId workspace has been deleted, please contact Openblocks team.

server/api-service/openblocks-server/src/main/java/com/openblocks/api/framework/security/SecurityConfig.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http) {
8282
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, INVITATION_URL + "/**"), // invitation
8383
ServerWebExchangeMatchers.pathMatchers(HttpMethod.POST, CUSTOM_AUTH + "/logout"),
8484
ServerWebExchangeMatchers.pathMatchers(HttpMethod.HEAD, STATE_URL + "/healthCheck"),
85+
8586
// used in public viewed apps
8687
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, CONFIG_URL), // system config
8788
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, CONFIG_URL + "/deploymentId"), // system config

server/api-service/openblocks-server/src/main/resources/selfhost/ce/application-selfhost.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ common:
44
salt: ${ENCRYPTION_SALT:openblocks.dev}
55
security:
66
corsAllowedDomainString: ${CORS_ALLOWED_DOMAINS:*}
7-
max-query-request-size-in-mb: 20
8-
max-query-response-size-in-mb: 20
97
workspace:
108
mode: ENTERPRISE
119

@@ -14,6 +12,4 @@ spring:
1412
mongodb:
1513
uri: ${MONGODB_URI:mongodb://localhost:27017/openblocks?socketTimeoutMS=5000}
1614
redis:
17-
url: ${REDIS_URL:redis://localhost:6379}
18-
codec:
19-
max-in-memory-size: 20MB
15+
url: ${REDIS_URL:redis://localhost:6379}

server/api-service/openblocks-server/src/main/resources/selfhost/ce/application.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ spring:
1111
main:
1212
allow-bean-definition-overriding: true
1313
allow-circular-references: true
14+
codec:
15+
max-in-memory-size: 20MB
1416

1517
server:
1618
compression:
@@ -31,6 +33,8 @@ common:
3133
block-hound-enable: false
3234
js-executor:
3335
host: ${JS_EXECUTOR_URI:http://127.0.0.1:6060}
36+
max-query-request-size-in-mb: 20
37+
max-query-response-size-in-mb: 20
3438

3539
material:
3640
mongodb-grid-fs:

0 commit comments

Comments
 (0)