class FieldAgent implements IOFogModule {

    public String deProvision(boolean isTokenExpired) {
        logInfo("Start Deprovisioning");

        if (!provisioningLock.tryLock()) {
            String msg = "Provisioning in progress";
            logInfo(msg);
            return msg;
        }

        try {
            if (notProvisioned()) {
                logInfo("Finished Deprovisioning : Failure - not provisioned");
                return "\nFailure - not provisioned";
            }

            if (!isTokenExpired) {
                try {
                    orchestrator.request("deprovision", RequestType.POST, null, getDeprovisionBody());
                } catch (CertificateException | SSLHandshakeException e) {
                    verificationFailed(e);
                    logError("Unable to make deprovision request due to broken certificate ",
                            new AgentSystemException(e.getMessage(), e));
                } catch (Exception e) {
                    logError("Unable to make deprovision request ",
                            new AgentSystemException(e.getMessage(), e));
                }
            }

            StatusReporter.setFieldAgentStatus().setControllerStatus(NOT_PROVISIONED);
            String iofogUuid = Configuration.getIofogUuid();
            try {
                Configuration.setIofogUuid("");
                Configuration.setAccessToken("");
                Configuration.saveConfigUpdates();
            } catch (Exception e) {
                logError("Error saving config updates", new AgentSystemException(e.getMessage(), e));
            }
            microserviceManager.clear();
            try {
                ProcessManager.getInstance().stopRunningMicroservices(false, iofogUuid);
            } catch (Exception e) {
                logError("Error stopping running microservices",
                        new AgentSystemException(e.getMessage(), e));
            }
            notifyModules();
            logInfo("Finished Deprovisioning : Success - tokens, identifiers and keys removed");
        } finally {
            provisioningLock.unlock();
        }
        return "\nSuccess - tokens, identifiers and keys removed";
    }

    private  FieldAgent();

}