Skip to content

Commit 4da84ee

Browse files
committed
feat(job): added fetching of the JobStepProperty.propertyValue max length in Console
Signed-off-by: Alberto Codutti <[email protected]>
1 parent ce8c8d3 commit 4da84ee

File tree

6 files changed

+59
-2
lines changed

6 files changed

+59
-2
lines changed

console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/client/steps/JobStepAddDialog.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,9 +314,22 @@ protected void refreshJobStepDefinition(GwtJobStepDefinition gwtJobStepDefinitio
314314

315315
textArea.setData(PROPERTY_TYPE, property.getPropertyType());
316316
textArea.setData(PROPERTY_NAME, property.getPropertyName());
317-
textArea.setMaxLength(65535);
318317
jobStepPropertiesPanel.add(textArea);
319318

319+
JOB_STEP_SERVICE.getJobStepPropertyLengthMax(new AsyncCallback<Integer>() {
320+
@Override
321+
public void onFailure(Throwable caught) {
322+
textArea.setMaxLength(104857600); // 100MB
323+
324+
FailureHandler.handle(caught);
325+
}
326+
327+
@Override
328+
public void onSuccess(Integer jobStepPropertyMaxLength) {
329+
textArea.setMaxLength(jobStepPropertyMaxLength);
330+
}
331+
});
332+
320333
if (property.getExampleValue() != null) {
321334
final String exampleValue = KapuaSafeHtmlUtils.htmlUnescape(property.getExampleValue());
322335
exampleButton = new KapuaButton(getExampleButtonText(), new KapuaIcon(IconSet.EDIT), new SelectionListener<ButtonEvent>() {

console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/server/GwtJobStepServiceImpl.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,15 @@ public GwtJobStep update(GwtXSRFToken xsrfToken, GwtJobStep gwtJobStep) throws G
198198
}
199199
}
200200

201+
@Override
202+
public int getJobStepPropertyLengthMax() throws GwtKapuaException {
203+
try {
204+
return JOB_STEP_SERVICE.getJobStepPropertyMaxLength();
205+
} catch (Exception e) {
206+
throw KapuaExceptionHandler.buildExceptionFromError(e);
207+
}
208+
}
209+
201210
/**
202211
* Set the {@link GwtJobStepProperty#isEnum()} property.
203212
* This cannot be performed in *.shared.* packages (entity converters are in that package), since `Class.forName` is not present in the JRE Emulation library.

console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/shared/service/GwtJobStepService.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ void delete(GwtXSRFToken xsrfToken, String gwtScopeId, String gwtJobStepId)
5151
public GwtJobStep update(GwtXSRFToken xsrfToken, GwtJobStep gwtJobStep)
5252
throws GwtKapuaException;
5353

54-
// Just to make Gwt serialize GwtJobStepProperty
54+
int getJobStepPropertyLengthMax()
55+
throws GwtKapuaException;
56+
57+
/**
58+
* Just to make Gwt serialize {@link GwtJobStepProperty}
59+
*/
5560
GwtJobStepProperty trickGwt();
5661
}

extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/job/JobStepMigratorServiceImpl.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,9 @@ public JobStep find(KapuaId scopeId, KapuaId jobStepId) {
6969
public void delete(KapuaId scopeId, KapuaId jobStepId) {
7070
throw new UnsupportedOperationException();
7171
}
72+
73+
@Override
74+
public int getJobStepPropertyMaxLength() throws KapuaException {
75+
throw new UnsupportedOperationException();
76+
}
7277
}

service/job/api/src/main/java/org/eclipse/kapua/service/job/step/JobStepService.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import org.eclipse.kapua.model.query.KapuaQuery;
1717
import org.eclipse.kapua.service.KapuaEntityService;
1818
import org.eclipse.kapua.service.KapuaUpdatableEntityService;
19+
import org.eclipse.kapua.service.job.step.definition.JobStepProperty;
1920

2021
/**
2122
* {@link JobStepService} exposes APIs to manage JobStep objects.<br>
@@ -38,4 +39,12 @@ public interface JobStepService extends KapuaEntityService<JobStep, JobStepCreat
3839
@Override
3940
JobStepListResult query(KapuaQuery query)
4041
throws KapuaException;
42+
43+
/**
44+
* Gets the maximum length that a {@link JobStepProperty#getPropertyValue()} is allowed to have.
45+
*
46+
* @since 2.0.0
47+
*/
48+
int getJobStepPropertyMaxLength()
49+
throws KapuaException;
4150
}

service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/internal/JobStepServiceImpl.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ public class JobStepServiceImpl extends AbstractKapuaService implements JobStepS
7979

8080
private final JobServiceSettings jobServiceSettings = JobServiceSettings.getInstance();
8181

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

8489
public JobStepServiceImpl() {
@@ -341,6 +346,17 @@ public void delete(KapuaId scopeId, KapuaId jobStepId) throws KapuaException {
341346
});
342347
}
343348

349+
@Override
350+
public int getJobStepPropertyMaxLength() throws KapuaException {
351+
//
352+
// Check access
353+
AUTHORIZATION_SERVICE.checkPermission(PERMISSION_FACTORY.newPermission(JobDomains.JOB_DOMAIN, Actions.read, KapuaId.ANY));
354+
355+
//
356+
// Return the value
357+
return jobStepPropertyValueLengthMax;
358+
}
359+
344360
//
345361
// Private methods
346362
private void validateJobStepProperties(JobStepCreator jobStepCreator) throws KapuaException {

0 commit comments

Comments
 (0)