Skip to content

Commit

Permalink
feath(job): added fetching of the JobStepProperty.propertyValue max l…
Browse files Browse the repository at this point in the history
…ength in Console

Signed-off-by: Alberto Codutti <alberto.codutti@eurotech.com>
  • Loading branch information
Coduz committed Jul 26, 2023
1 parent 2144094 commit 4523a52
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,22 @@ protected void refreshJobStepDefinition(GwtJobStepDefinition gwtJobStepDefinitio

textArea.setData(PROPERTY_TYPE, property.getPropertyType());
textArea.setData(PROPERTY_NAME, property.getPropertyName());
textArea.setMaxLength(65535);
jobStepPropertiesPanel.add(textArea);

JOB_STEP_SERVICE.getJobStepPropertyLengthMax(new AsyncCallback<Integer>() {
@Override
public void onFailure(Throwable caught) {
textArea.setMaxLength(104857600); // 100MB

FailureHandler.handle(caught);
}

@Override
public void onSuccess(Integer jobStepPropertyMaxLength) {
textArea.setMaxLength(jobStepPropertyMaxLength);
}
});

if (property.getExampleValue() != null) {
final String exampleValue = KapuaSafeHtmlUtils.htmlUnescape(property.getExampleValue());
exampleButton = new KapuaButton(getExampleButtonText(), new KapuaIcon(IconSet.EDIT), new SelectionListener<ButtonEvent>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,15 @@ public GwtJobStep update(GwtXSRFToken xsrfToken, GwtJobStep gwtJobStep) throws G
}
}

@Override
public int getJobStepPropertyLengthMax() throws GwtKapuaException {
try {
return JOB_STEP_SERVICE.getJobStepPropertyMaxLength();
} catch (Exception e) {
throw KapuaExceptionHandler.buildExceptionFromError(e);
}
}

/**
* Set the {@link GwtJobStepProperty#isEnum()} property.
* This cannot be performed in *.shared.* packages (entity converters are in that package), since `Class.forName` is not present in the JRE Emulation library.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ void delete(GwtXSRFToken xsrfToken, String gwtScopeId, String gwtJobStepId)
GwtJobStep update(GwtXSRFToken xsrfToken, GwtJobStep gwtJobStep)
throws GwtKapuaException;

int getJobStepPropertyLengthMax()
throws GwtKapuaException;

/**
* Just to make Gwt serialize {@link GwtJobStepProperty}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,9 @@ public JobStep find(KapuaId scopeId, KapuaId jobStepId) {
public void delete(KapuaId scopeId, KapuaId jobStepId) {
throw new UnsupportedOperationException();
}

@Override
public int getJobStepPropertyMaxLength() throws KapuaException {
throw new UnsupportedOperationException();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.eclipse.kapua.model.query.KapuaQuery;
import org.eclipse.kapua.service.KapuaEntityService;
import org.eclipse.kapua.service.KapuaUpdatableEntityService;
import org.eclipse.kapua.service.job.step.definition.JobStepProperty;

/**
* {@link JobStepService} exposes APIs to manage JobStep objects.<br>
Expand All @@ -38,4 +39,12 @@ public interface JobStepService extends KapuaEntityService<JobStep, JobStepCreat
@Override
JobStepListResult query(KapuaQuery query)
throws KapuaException;

/**
* Gets the maximum length that a {@link JobStepProperty#getPropertyValue()} is allowed to have.
*
* @since 2.0.0
*/
int getJobStepPropertyMaxLength()
throws KapuaException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ public class JobStepServiceImpl extends AbstractKapuaService implements JobStepS

private final JobServiceSettings jobServiceSettings = JobServiceSettings.getInstance();

/**
* The maximum length that a {@link JobStepProperty#getPropertyValue()} is allowed to have
*
* @since 2.0.0
*/
private final int jobStepPropertyValueLengthMax = jobServiceSettings.getInt(JobServiceSettingKeys.JOB_STEP_PROPERTY_VALUE_LENGTH_MAX);

public JobStepServiceImpl() {
Expand Down Expand Up @@ -382,6 +387,17 @@ public void delete(KapuaId scopeId, KapuaId jobStepId) throws KapuaException {
});
}

@Override
public int getJobStepPropertyMaxLength() throws KapuaException {
//
// Check access
authorizationService.checkPermission(permissionFactory.newPermission(JobDomains.JOB_DOMAIN, Actions.read, KapuaId.ANY));

//
// Return the value
return jobStepPropertyValueLengthMax;
}

//
// Private methods
//
Expand Down

0 comments on commit 4523a52

Please sign in to comment.