org.camunda.bpm.engine.impl.persistence.entity.PropertyEntity Java Examples

The following examples show how to use org.camunda.bpm.engine.impl.persistence.entity.PropertyEntity. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DeletePropertyCmd.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public Object execute(CommandContext commandContext) {
  AuthorizationManager authorizationManager = commandContext.getAuthorizationManager();
  authorizationManager.checkCamundaAdmin();

  final PropertyManager propertyManager = commandContext.getPropertyManager();

  PropertyEntity propertyEntity = propertyManager.findPropertyById(name);

  if(propertyEntity != null) {
    propertyManager.delete(propertyEntity);
    
    commandContext.getOperationLogManager().logPropertyOperation(UserOperationLogEntry.OPERATION_TYPE_DELETE, 
        Collections.singletonList(new PropertyChange("name", null, name)));
  }

  return null;
}
 
Example #2
Source File: GetLicenseKeyCmd.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Override
public String execute(CommandContext commandContext) {
  AuthorizationManager authorizationManager = commandContext.getAuthorizationManager();
  authorizationManager.checkCamundaAdmin();

  // case I: license is stored as BLOB
  ResourceEntity licenseResource = commandContext.getResourceManager().findLicenseKeyResource();
  if (licenseResource != null) {
    return new String(licenseResource.getBytes(), StandardCharsets.UTF_8);
  }

  // case II: license is stored in properties
  PropertyEntity licenseProperty = commandContext.getPropertyManager().findPropertyById(LICENSE_KEY_PROPERTY_NAME);
  if (licenseProperty != null) {
    return licenseProperty.getValue();
  }

  return null;
}
 
Example #3
Source File: BootstrapEngineCommand.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void initializeTelemetryProperty(CommandContext commandContext) {
  try {

    checkTelemetryLockExists(commandContext);

    commandContext.getPropertyManager().acquireExclusiveLockForTelemetry();
    PropertyEntity databaseTelemetryProperty = databaseTelemetryConfiguration(commandContext);

    if (databaseTelemetryProperty == null) {
      LOG.noTelemetryPropertyFound();
      createTelemetryProperty(commandContext);
    }

  } catch (Exception e) {
    LOG.errorConfiguringTelemetryProperty(e);
  }
}
 
Example #4
Source File: TestHelper.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public static void createOrUpdateHistoryLevel(final ProcessEngineConfigurationImpl processEngineConfiguration) {
  processEngineConfiguration.getCommandExecutorTxRequired()
    .execute(new Command<Object>() {
     public Object execute(CommandContext commandContext) {
       DbEntityManager dbEntityManager = commandContext.getDbEntityManager();
       PropertyEntity historyLevelProperty = dbEntityManager.selectById(PropertyEntity.class, "historyLevel");
       if (historyLevelProperty != null) {
         if (processEngineConfiguration.getHistoryLevel().getId() != new Integer(historyLevelProperty.getValue())) {
           historyLevelProperty.setValue(Integer.toString(processEngineConfiguration.getHistoryLevel().getId()));
           dbEntityManager.merge(historyLevelProperty);
         }
       } else {
         HistoryLevelSetupCommand.dbCreateHistoryLevel(commandContext);
       }
       return null;
     }
    });
}
 
Example #5
Source File: BootstrapEngineCommand.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected String databaseInstallationId(CommandContext commandContext) {
  try {
    PropertyEntity installationIdProperty = commandContext.getPropertyManager().findPropertyById(INSTALLATION_PROPERTY_NAME);
    return installationIdProperty != null ? installationIdProperty.getValue() : null;
  } catch (Exception e) {
    LOG.couldNotSelectInstallationId(e.getMessage());
    return null;
  }
}
 
Example #6
Source File: ManagementServiceTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected PropertyEntity getTelemetryProperty(ProcessEngineConfigurationImpl configuration) {
    return configuration.getCommandExecutorTxRequired()
      .execute(new Command<PropertyEntity>() {
        public PropertyEntity execute(CommandContext commandContext) {
          return commandContext.getPropertyManager().findPropertyById("camunda.telemetry.enabled");
        }
      });
}
 
Example #7
Source File: IsTelemetryEnabledCmd.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public Boolean execute(CommandContext commandContext) {

    AuthorizationManager authorizationManager = commandContext.getAuthorizationManager();
    authorizationManager.checkCamundaAdmin();

    PropertyEntity telemetryProperty = commandContext.getPropertyManager().findPropertyById("camunda.telemetry.enabled");
    if (telemetryProperty != null) {
      return Boolean.parseBoolean(telemetryProperty.getValue());
    } else {
      LOG.databaseTelemetryPropertyMissingInfo();
      return false;
    }
  }
 
Example #8
Source File: DeleteLicenseKeyCmd.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public Object execute(CommandContext commandContext) {
  AuthorizationManager authorizationManager = commandContext.getAuthorizationManager();
  authorizationManager.checkCamundaAdmin();

  final ResourceManager resourceManager = commandContext.getResourceManager();
  final PropertyManager propertyManager = commandContext.getPropertyManager();
  
  // lock the property
  @SuppressWarnings("unused")
  PropertyEntity licenseProperty = propertyManager.findPropertyById(LICENSE_KEY_BYTE_ARRAY_ID);

  // delete license key BLOB
  ResourceEntity licenseKey = resourceManager.findLicenseKeyResource();
  if(licenseKey != null) {
    resourceManager.delete(licenseKey);
  }

  // always delete license key legacy property if it still exists
  new DeletePropertyCmd(LICENSE_KEY_PROPERTY_NAME).execute(commandContext);

  if(deleteProperty) {
    // delete license key byte array id
    new DeletePropertyCmd(LICENSE_KEY_BYTE_ARRAY_ID).execute(commandContext);
  }

  return null;
}
 
Example #9
Source File: GetNextIdBlockCmd.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public IdBlock execute(CommandContext commandContext) {
  PropertyEntity property = commandContext
    .getPropertyManager()
    .findPropertyById("next.dbid");
  long oldValue = Long.parseLong(property.getValue());
  long newValue = oldValue+idBlockSize;
  property.setValue(Long.toString(newValue));
  return new IdBlock(oldValue, newValue-1);
}
 
Example #10
Source File: GetPropertiesCmd.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public Map<String, String> execute(CommandContext commandContext) {
  AuthorizationManager authorizationManager = commandContext.getAuthorizationManager();
  authorizationManager.checkCamundaAdmin();

  List<PropertyEntity> propertyEntities = commandContext
    .getDbEntityManager()
    .selectList("selectProperties");
  
  Map<String, String> properties = new HashMap<String, String>();
  for (PropertyEntity propertyEntity: propertyEntities) {
    properties.put(propertyEntity.getName(), propertyEntity.getValue());
  }
  return properties;
}
 
Example #11
Source File: TestHelper.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public static void deleteInstallationId(ProcessEngineConfigurationImpl processEngineConfiguration) {
  processEngineConfiguration.getCommandExecutorTxRequired()
    .execute(new Command<Object>() {
     public Object execute(CommandContext commandContext) {
       DbEntityManager dbEntityManager = commandContext.getDbEntityManager();
       PropertyEntity installationIdProperty = dbEntityManager.selectById(PropertyEntity.class, "camunda.installation.id");
       if (installationIdProperty != null) {
         dbEntityManager.delete(installationIdProperty);
       }
       return null;
     }
    });
}
 
Example #12
Source File: TestHelper.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public static void deleteTelemetryProperty(ProcessEngineConfigurationImpl processEngineConfiguration) {
  processEngineConfiguration.getCommandExecutorTxRequired()
    .execute(new Command<Object>() {
     public Object execute(CommandContext commandContext) {
       DbEntityManager dbEntityManager = commandContext.getDbEntityManager();
       PropertyEntity telemetryProperty = dbEntityManager.selectById(PropertyEntity.class, "camunda.telemetry.enabled");
       if (telemetryProperty != null) {
         dbEntityManager.delete(telemetryProperty);
       }
       return null;
     }
    });
}
 
Example #13
Source File: TestHelper.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public static void deleteHistoryLevel(ProcessEngineConfigurationImpl processEngineConfiguration) {
  processEngineConfiguration.getCommandExecutorTxRequired()
    .execute(new Command<Object>() {
     public Object execute(CommandContext commandContext) {
       DbEntityManager dbEntityManager = commandContext.getDbEntityManager();
       PropertyEntity historyLevelProperty = dbEntityManager.selectById(PropertyEntity.class, "historyLevel");
       if (historyLevelProperty != null) {
         dbEntityManager.delete(historyLevelProperty);
       }
       return null;
     }
    });
}
 
Example #14
Source File: AbstractCamundaAutoConfigurationIT.java    From camunda-bpm-spring-boot-starter with Apache License 2.0 5 votes vote down vote up
@After
public void cleanup() {
  //remove history level from database
  ((ProcessEngineConfigurationImpl)processEngine.getProcessEngineConfiguration()).getCommandExecutorTxRequired().execute(new Command<Void>() {
    @Override
    public Void execute(CommandContext commandContext) {
      final PropertyEntity historyLevel = commandContext.getPropertyManager().findPropertyById("historyLevel");
      if (historyLevel != null) {
        commandContext.getDbEntityManager().delete(historyLevel);
      }
      return null;
    }
  });
}
 
Example #15
Source File: BootstrapEngineCommand.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void createInstallationProperty(CommandContext commandContext) {
  String installationId = UUID.randomUUID().toString();
  PropertyEntity property = new PropertyEntity(INSTALLATION_PROPERTY_NAME, installationId);
  commandContext.getPropertyManager().insert(property);
  LOG.creatingInstallationPropertyInDatabase(property.getValue());
  commandContext.getProcessEngineConfiguration().setInstallationId(installationId);
}
 
Example #16
Source File: BootstrapEngineCommand.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected PropertyEntity databaseTelemetryConfiguration(CommandContext commandContext) {
  try {
    return commandContext.getPropertyManager().findPropertyById(TELEMETRY_PROPERTY_NAME);
  } catch (Exception e) {
    LOG.errorFetchingTelemetryPropertyInDatabase(e);
    return null;
  }
}
 
Example #17
Source File: HistoryLevelSetupCommand.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
/**
 *
 * @return Integer value representing the history level or <code>null</code> if none found
 */
public static Integer databaseHistoryLevel(CommandContext commandContext) {

  try {
    PropertyEntity historyLevelProperty =  commandContext.getPropertyManager().findPropertyById("historyLevel");
    return historyLevelProperty != null ? new Integer(historyLevelProperty.getValue()) : null;
  }
  catch (Exception e) {
    LOG.couldNotSelectHistoryLevel(e.getMessage());
    return null;
  }

}
 
Example #18
Source File: HistoryLevelSetupCommand.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public static void dbCreateHistoryLevel(CommandContext commandContext) {
  ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
  HistoryLevel configuredHistoryLevel = processEngineConfiguration.getHistoryLevel();
  PropertyEntity property = new PropertyEntity("historyLevel", Integer.toString(configuredHistoryLevel.getId()));
  commandContext.getSession(DbEntityManager.class).insert(property);
  LOG.creatingHistoryLevelPropertyInDatabase(configuredHistoryLevel);
}
 
Example #19
Source File: AbstractCamundaAutoConfigurationIT.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@After
public void cleanup() {
  //remove history level from database
  ((ProcessEngineConfigurationImpl)processEngine.getProcessEngineConfiguration()).getCommandExecutorTxRequired().execute(new Command<Void>() {
    @Override
    public Void execute(CommandContext commandContext) {
      final PropertyEntity historyLevel = commandContext.getPropertyManager().findPropertyById("historyLevel");
      if (historyLevel != null) {
        commandContext.getDbEntityManager().delete(historyLevel);
      }
      return null;
    }
  });
}
 
Example #20
Source File: BootstrapEngineCommand.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected void checkInstallationIdLockExists(CommandContext commandContext) {
  PropertyEntity installationIdProperty = commandContext.getPropertyManager().findPropertyById("installationId.lock");
  if (installationIdProperty == null) {
    LOG.noInstallationIdLockPropertyFound();
  }
}
 
Example #21
Source File: BootstrapEngineCommand.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected void createTelemetryProperty(CommandContext commandContext) {
  boolean telemetryEnabled = Context.getProcessEngineConfiguration().isInitializeTelemetry();
  PropertyEntity property = new PropertyEntity(TELEMETRY_PROPERTY_NAME, Boolean.toString(telemetryEnabled));
  commandContext.getPropertyManager().insert(property);
  LOG.creatingTelemetryPropertyInDatabase(telemetryEnabled);
}
 
Example #22
Source File: BootstrapEngineCommand.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected void checkTelemetryLockExists(CommandContext commandContext) {
  PropertyEntity telemetryLockProperty = commandContext.getPropertyManager().findPropertyById("telemetry.lock");
  if (telemetryLockProperty == null) {
    LOG.noTelemetryLockPropertyFound();
  }
}
 
Example #23
Source File: BootstrapEngineCommand.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public void checkHistoryCleanupLockExists(CommandContext commandContext) {
  PropertyEntity historyCleanupLockProperty = commandContext.getPropertyManager().findPropertyById("history.cleanup.job.lock");
  if (historyCleanupLockProperty == null) {
    LOG.noHistoryCleanupLockPropertyFound();
  }
}
 
Example #24
Source File: BootstrapEngineCommand.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public void checkDeploymentLockExists(CommandContext commandContext) {
  PropertyEntity deploymentLockProperty = commandContext.getPropertyManager().findPropertyById("deployment.lock");
  if (deploymentLockProperty == null) {
    LOG.noDeploymentLockPropertyFound();
  }
}
 
Example #25
Source File: HistoryLevelSetupCommand.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected void checkStartupLockExists(CommandContext commandContext) {
  PropertyEntity historyStartupProperty = commandContext.getPropertyManager().findPropertyById("startup.lock");
  if (historyStartupProperty == null) {
    LOG.noStartupLockPropertyFound();
  }
}