Skip to content

Commit fb7f726

Browse files
committed
ENG-5461: Restored transient fields after serialization of content attributes
1 parent fc60362 commit fb7f726

1 file changed

Lines changed: 21 additions & 5 deletions

File tree

cds-plugin/src/main/java/org/entando/entando/plugins/jpcds/aps/system/storage/CdsStorageManager.java

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
*/
1414
package org.entando.entando.plugins.jpcds.aps.system.storage;
1515

16+
import com.agiletec.aps.system.SystemConstants;
1617
import com.agiletec.aps.util.ApsTenantApplicationUtils;
1718
import java.io.ByteArrayInputStream;
1819
import java.io.IOException;
@@ -41,17 +42,18 @@
4142
import org.springframework.stereotype.Service;
4243
import org.springframework.web.client.HttpClientErrorException;
4344
import org.entando.entando.aps.system.services.storage.CdsActive;
45+
import org.springframework.web.context.ContextLoader;
46+
import org.springframework.web.context.WebApplicationContext;
4447

4548
@Slf4j
46-
@Service("StorageManager")
49+
@Service(SystemConstants.STORAGE_MANAGER)
4750
@CdsActive(true)
4851
public class CdsStorageManager implements IStorageManager {
4952

5053
private static final String ERROR_VALIDATING_PATH_MSG = "Error validating path";
51-
private final transient ITenantManager tenantManager;
52-
private final transient CdsConfiguration configuration;
53-
private final transient CdsRemoteCaller caller;
54-
54+
private transient ITenantManager tenantManager;
55+
private transient CdsConfiguration configuration;
56+
private transient CdsRemoteCaller caller;
5557

5658
@Autowired
5759
public CdsStorageManager(CdsRemoteCaller caller, ITenantManager tenantManager, CdsConfiguration configuration) {
@@ -355,4 +357,18 @@ public enum CdsFilter {
355357
DIRECTORY,
356358
ALL;
357359
}
360+
361+
private void readObject(java.io.ObjectInputStream in)
362+
throws IOException, ClassNotFoundException {
363+
in.defaultReadObject();
364+
WebApplicationContext ctx = ContextLoader.getCurrentWebApplicationContext();
365+
if (ctx == null) {
366+
log.warn("Null WebApplicationContext during deserialization");
367+
return;
368+
}
369+
this.tenantManager = ctx.getBean(ITenantManager.class);
370+
this.configuration = ctx.getBean(CdsConfiguration.class);
371+
this.caller = ctx.getBean(CdsRemoteCaller.class);
372+
}
373+
358374
}

0 commit comments

Comments
 (0)