9 Commits

Author SHA1 Message Date
3322901cb1 v1.0.5 pom 2024-05-03 12:12:47 -04:00
bf06433a4d Merge branch 'develop' into stable 2024-05-03 12:12:26 -04:00
e437234c28 share models by tenant 2024-05-03 12:12:15 -04:00
e5debe9a47 v1.0.4 pom 2024-05-03 12:11:48 -04:00
8b1c958ddc Merge branch 'develop' into stable 2024-05-02 15:58:06 -04:00
5d172e234e fix enabled typo 2024-05-02 15:57:57 -04:00
10a732adb6 v1.0.3 2024-04-22 13:04:41 -04:00
58e84c88d9 Merge branch 'develop' into stable 2024-04-22 13:04:24 -04:00
185047e755 using @EnableScheduling 2024-04-22 13:04:06 -04:00
5 changed files with 57 additions and 30 deletions

View File

@@ -13,20 +13,24 @@ You can install this like any JAR extension. It just needs to be put in the web
There are several configuration properties available to shape how this extension shares models in your APS installation.
| Property | Default | Purpose |
| -------------------------------------------------------- | ------- | ------- |
| `inteligr8.modelShareExtension.groups.canRead` | | What groups should be granted read permission to models of all types. |
| `inteligr8.modelShareExtension.groups.canWrite` | | What groups should be granted write permission to models of all types. |
| `inteligr8.modelShareExtension.groups.canReadApps` | | What groups should be granted read permission to App models. |
| `inteligr8.modelShareExtension.groups.canWriteApps` | | What groups should be granted write permission to App models. |
| `inteligr8.modelShareExtension.groups.canReadProcesses` | | What groups should be granted read permission to Process models. |
| `inteligr8.modelShareExtension.groups.canWriteProcesses` | | What groups should be granted write permission to Process models. |
| `inteligr8.modelShareExtension.groups.canReadForms` | | What groups should be granted read permission to Form models. |
| `inteligr8.modelShareExtension.groups.canWriteForms` | | What groups should be granted write permission to Form models. |
| `inteligr8.modelShareExtension.shareAllModelsOnStartup` | `false` | Set to `true` to perform a startup scanning of models, sharing them according to the configuration. |
| `inteligr8.modelShareExtension.modelChunkSize` | `50` | When querying for all models, how many models should be queried per page. |
| `inteligr8.modelShareExtension.shareChunkSize` | `20` | When querying all user/group share permissions on a single model, how many records should be queried per page. |
| Property | Default | Purpose |
| -------------------------------------------------------- | -------- | ------- |
| `inteligr8.modelShareExtension.enabled` | `true` | Enablement; `false` will disable all the behaviors of this extension. |
| `inteligr8.modelShareExtension.scanDelayInMillis` | `30000` | The delay before the first scan for all models to share. |
| `inteligr8.modelShareExtension.scanIntervalInMillis` | `600000` | The interval between scans for all models to share. |
| `inteligr8.modelShareExtension.groups.canRead` | | What groups should be granted read permission to models of all types. |
| `inteligr8.modelShareExtension.groups.canWrite` | | What groups should be granted write permission to models of all types. |
| `inteligr8.modelShareExtension.groups.canReadApps` | | What groups should be granted read permission to App models. |
| `inteligr8.modelShareExtension.groups.canWriteApps` | | What groups should be granted write permission to App models. |
| `inteligr8.modelShareExtension.groups.canReadProcesses` | | What groups should be granted read permission to Process models. |
| `inteligr8.modelShareExtension.groups.canWriteProcesses` | | What groups should be granted write permission to Process models. |
| `inteligr8.modelShareExtension.groups.canReadForms` | | What groups should be granted read permission to Form models. |
| `inteligr8.modelShareExtension.groups.canWriteForms` | | What groups should be granted write permission to Form models. |
| `inteligr8.modelShareExtension.modelChunkSize` | `50` | When querying for all models, how many models should be queried per page. |
| `inteligr8.modelShareExtension.shareChunkSize` | `25` | When querying all user/group share permissions on a single model, how many records should be queried per page. |
You can specify these at startup as JVM system properties.
When specifying groups, use commas to separate each entry. You can also prefix each group with "sys:" or "org:" to target a specific system or organizational/functional group. The extension will query by group name and then external ID in each case.
Any specification of a specific group permission (e.g. `canReadApps`) will override any specification for the same group in the generic `canRead` or `canWrite` property.

View File

@@ -5,7 +5,7 @@
<groupId>com.inteligr8.alfresco.activiti</groupId>
<artifactId>model-share-activiti-app-ext</artifactId>
<version>1.0.2</version>
<version>1.0.5</version>
<packaging>jar</packaging>
<name>Model Share APS Extension</name>

View File

@@ -17,6 +17,7 @@ package com.activiti.extension.conf;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FullyQualifiedAnnotationBeanNameGenerator;
import org.springframework.scheduling.annotation.EnableScheduling;
/**
* A means for injecting packages to scan for the Spring context.
@@ -24,6 +25,7 @@ import org.springframework.context.annotation.FullyQualifiedAnnotationBeanNameGe
* @author brian@inteligr8.com
*/
@Configuration
@EnableScheduling
@ComponentScan(
basePackages = "com.inteligr8.alfresco.activiti.share",
nameGenerator = FullyQualifiedAnnotationBeanNameGenerator.class

View File

@@ -38,20 +38,29 @@ public class ModelShareExtension implements Bootstrappable {
public void onBootstrap() {
this.logger.trace("onBootstrap()");
if (this.enabled) {
this.bootstrapped = true;
this.logger.info("Model Share Extension initialized");
}
if (!this.enabled)
return;
this.logger.info("Model Share Extension enabled");
this.bootstrapped = true;
this.logger.info("Model Share Extension initialized");
}
public boolean isEnabled() {
return this.enabled;
}
// execute every 10 minutes
@Scheduled(fixedRate = 600000)
@Scheduled(
fixedRateString = "${inteligr8.modelShareExtension.scanIntervalInMillis:600000}",
initialDelayString = "${inteligr8.modelShareExtension.scanDelayInMillis:30000}"
)
private void scheduled() {
if (!this.enabled || !this.bootstrapped)
return;
this.logger.trace("scheduled()");
this.worker.share();
this.worker.shareAllModels();
}
}

View File

@@ -25,6 +25,7 @@ import java.util.Map.Entry;
import java.util.Set;
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.repository.ModelQuery;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -104,8 +105,8 @@ public class ModelShareWorker implements Bootstrappable {
@Override
public void onBootstrap() {
this.logger.trace("onBootstrap({})");
this.logger.trace("onBootstrap()");
this.tenantId = this.tenantService.findTenantId();
this.groups = this.toMap(this.findGroups(this.readGroupNames), SharePermission.READ);
this.toMap(this.groups, this.findGroups(this.writeGroupNames), SharePermission.WRITE);
@@ -206,31 +207,42 @@ public class ModelShareWorker implements Bootstrappable {
map.put(key, value);
}
public void share() {
this.logger.trace("Discovering models ...");
public void shareAllModels() {
if (this.tenantId != null)
this.shareAllModels(this.tenantId);
this.shareAllModels(null);
}
public void shareAllModels(Long tenantId) {
this.logger.trace("Discovering models in tenant {} ...", this.tenantId);
long modelCount = 0L;
int page = 1;
int perPage = this.modelChunkSize;
List<org.activiti.engine.repository.Model> models = this.services.getRepositoryService().createModelQuery().listPage((page-1)*perPage, perPage);
ModelQuery query = this.services.getRepositoryService().createModelQuery().latestVersion();
if (tenantId != null)
query.modelTenantId(String.valueOf(tenantId));
else query.modelWithoutTenantId();
List<org.activiti.engine.repository.Model> models = query.listPage((page-1)*perPage, perPage);
while (!models.isEmpty()) {
this.logger.trace("Fetched page #{} of {} models", page, models.size());
this.logger.trace("Fetched page #{} of {} models in tenant {}", page, models.size(), this.tenantId);
for (org.activiti.engine.repository.Model model : models) {
this.logger.debug("Discovered model: {}: {}: {}", model.getCategory(), model.getId(), model.getName());
this.share(model);
this.shareModel(model);
}
modelCount += models.size();
page++;
models = this.services.getRepositoryService().createModelQuery().listPage((page-1)*perPage, perPage);
models = query.listPage((page-1)*perPage, perPage);
}
this.logger.trace("Discovered {} models", modelCount);
this.logger.trace("Discovered {} models in tenant {}", modelCount, this.tenantId);
}
public void share(org.activiti.engine.repository.Model orgModel) {
public void shareModel(org.activiti.engine.repository.Model orgModel) {
Model model = (Model) this.modelService.getModel(Long.valueOf(orgModel.getId()));
Map<HashableGroup, SharePermission> shares = this.fetchCurrentModelShares(model);