Skip to content

Commit

Permalink
feat(job): added fetching of the JobStepProperty.propertyValue max le…
Browse files Browse the repository at this point in the history
…ngth in Console

Signed-off-by: Alberto Codutti <alberto.codutti@eurotech.com>
  • Loading branch information
Coduz committed Jul 24, 2023
1 parent ce8c8d3 commit 4da84ee
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,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 @@ -198,6 +198,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 @@ -51,6 +51,11 @@ void delete(GwtXSRFToken xsrfToken, String gwtScopeId, String gwtJobStepId)
public GwtJobStep update(GwtXSRFToken xsrfToken, GwtJobStep gwtJobStep)
throws GwtKapuaException;

// Just to make Gwt serialize GwtJobStepProperty
int getJobStepPropertyLengthMax()
throws GwtKapuaException;

/**
* Just to make Gwt serialize {@link GwtJobStepProperty}
*/
GwtJobStepProperty trickGwt();
}
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 @@ -79,6 +79,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 @@ -341,6 +346,17 @@ public void delete(KapuaId scopeId, KapuaId jobStepId) throws KapuaException {
});
}

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

//
// Return the value
return jobStepPropertyValueLengthMax;
}

//
// Private methods
private void validateJobStepProperties(JobStepCreator jobStepCreator) throws KapuaException {
Expand Down

0 comments on commit 4da84ee

Please sign in to comment.