|
13 | 13 | */ |
14 | 14 | package org.entando.entando.plugins.jpcds.aps.system.storage; |
15 | 15 |
|
| 16 | +import com.agiletec.aps.system.SystemConstants; |
16 | 17 | import com.agiletec.aps.util.ApsTenantApplicationUtils; |
17 | 18 | import java.io.ByteArrayInputStream; |
18 | 19 | import java.io.IOException; |
|
41 | 42 | import org.springframework.stereotype.Service; |
42 | 43 | import org.springframework.web.client.HttpClientErrorException; |
43 | 44 | import org.entando.entando.aps.system.services.storage.CdsActive; |
| 45 | +import org.springframework.web.context.ContextLoader; |
| 46 | +import org.springframework.web.context.WebApplicationContext; |
44 | 47 |
|
45 | 48 | @Slf4j |
46 | | -@Service("StorageManager") |
| 49 | +@Service(SystemConstants.STORAGE_MANAGER) |
47 | 50 | @CdsActive(true) |
48 | 51 | public class CdsStorageManager implements IStorageManager { |
49 | 52 |
|
50 | 53 | 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; |
55 | 57 |
|
56 | 58 | @Autowired |
57 | 59 | public CdsStorageManager(CdsRemoteCaller caller, ITenantManager tenantManager, CdsConfiguration configuration) { |
@@ -355,4 +357,18 @@ public enum CdsFilter { |
355 | 357 | DIRECTORY, |
356 | 358 | ALL; |
357 | 359 | } |
| 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 | + |
358 | 374 | } |
0 commit comments