|
|
@@ -51,6 +51,7 @@ import org.springframework.context.annotation.Configuration; |
|
|
|
import org.springframework.core.io.Resource; |
|
|
|
import org.springframework.core.io.support.PathMatchingResourcePatternResolver; |
|
|
|
|
|
|
|
import javax.annotation.Nullable; |
|
|
|
import java.beans.Transient; |
|
|
|
import java.io.File; |
|
|
|
import java.util.*; |
|
|
@@ -93,6 +94,7 @@ public class BubbleConfiguration extends PgRestServerConfiguration |
|
|
|
public static final String TAG_SUPPORT = "support"; |
|
|
|
public static final String TAG_SECURITY_LEVELS = "securityLevels"; |
|
|
|
public static final String TAG_RESTORE_MODE = "awaitingRestore"; |
|
|
|
public static final String TAG_RESTORING_IN_PROGRESS = "restoringInProgress"; |
|
|
|
|
|
|
|
public static final String DEFAULT_LOCAL_STORAGE_DIR = HOME_DIR + "/.bubble_local_storage"; |
|
|
|
|
|
|
@@ -291,13 +293,14 @@ public class BubbleConfiguration extends PgRestServerConfiguration |
|
|
|
|
|
|
|
private final AtomicReference<Map<String, Object>> publicSystemConfigs = new AtomicReference<>(); |
|
|
|
public Map<String, Object> getPublicSystemConfigs () { |
|
|
|
final var thisNetwork = getThisNetwork(); |
|
|
|
final var awaitingRestore = thisNetwork != null && thisNetwork.getState() == BubbleNetworkState.restoring; |
|
|
|
|
|
|
|
synchronized (publicSystemConfigs) { |
|
|
|
if (publicSystemConfigs.get() == null) { |
|
|
|
final BubbleNetwork thisNetwork = getThisNetwork(); |
|
|
|
final AccountDAO accountDAO = getBean(AccountDAO.class); |
|
|
|
final CloudServiceDAO cloudDAO = getBean(CloudServiceDAO.class); |
|
|
|
final ActivationService activationService = getBean(ActivationService.class); |
|
|
|
final RestoreService restoreService = getBean(RestoreService.class); |
|
|
|
|
|
|
|
publicSystemConfigs.set(MapBuilder.build(new Object[][]{ |
|
|
|
{TAG_ALLOW_REGISTRATION, thisNetwork == null ? null : thisNetwork.getBooleanTag(TAG_ALLOW_REGISTRATION, false)}, |
|
|
@@ -312,19 +315,35 @@ public class BubbleConfiguration extends PgRestServerConfiguration |
|
|
|
{TAG_CLOUD_CONFIGS, accountDAO.activated() ? null : activationService.getCloudDefaults()}, |
|
|
|
{TAG_LOCKED, accountDAO.locked()}, |
|
|
|
{TAG_LAUNCH_LOCK, isSageLauncher() || thisNetwork == null ? null : thisNetwork.launchLock()}, |
|
|
|
{TAG_RESTORE_MODE, thisNetwork == null |
|
|
|
? false |
|
|
|
: thisNetwork.getState() == BubbleNetworkState.restoring |
|
|
|
&& !restoreService.isRestoreStarted(thisNetwork.getUuid())}, |
|
|
|
{TAG_RESTORE_MODE, awaitingRestore}, |
|
|
|
{TAG_RESTORING_IN_PROGRESS, awaitingRestore |
|
|
|
&& getBean(RestoreService.class).isSelfRestoreStarted()}, |
|
|
|
{TAG_SSL_PORT, getDefaultSslPort()}, |
|
|
|
{TAG_SUPPORT, getSupport()}, |
|
|
|
{TAG_SECURITY_LEVELS, DeviceSecurityLevel.values()} |
|
|
|
})); |
|
|
|
} else { |
|
|
|
// some things has to be refreshed all the time in some cases: |
|
|
|
if (awaitingRestore) { |
|
|
|
publicSystemConfigs.get().put(TAG_RESTORING_IN_PROGRESS, |
|
|
|
getBean(RestoreService.class).isSelfRestoreStarted()); |
|
|
|
} |
|
|
|
} |
|
|
|
return publicSystemConfigs.get(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Return true if it is expected from the user to fillin data required for starting backup restoring process on |
|
|
|
* this node of this network. |
|
|
|
*/ |
|
|
|
private boolean isRestoringInProgress(@Nullable final BubbleNetwork thisNetwork) { |
|
|
|
if (thisNetwork == null || thisNetwork.getState() != BubbleNetworkState.restoring) return false; |
|
|
|
|
|
|
|
// if restore process is already started, do not show the form to user again: |
|
|
|
return !getBean(RestoreService.class).isSelfRestoreStarted(); |
|
|
|
} |
|
|
|
|
|
|
|
// called after activation, because now thisNetwork will be defined |
|
|
|
public void refreshPublicSystemConfigs () { |
|
|
|
synchronized (publicSystemConfigs) { publicSystemConfigs.set(null); } |
|
|
|