07-08-2017 06:45 AM
is
the below error raises two questions:
type Exception report
message java.lang.Exception: {"errorType":"unAuthorized","errorData":"workgroup","errorMessage":"Object is in non-lab workgroup. Cannot be deleted, trackingId: 70d81e4e-8418-4a53-8131-2c41e0783af1"}: ApiError with errorType: unAuthorized, errorData: workgroup, errorMessage: Object is in non-lab workgroup. Cannot be deleted, trackingId: 70d81e4e-8418-4a53-8131-2c41e0783af1
i've been using the sample code from register application example on devnet, when reviewing it, it's not evident how or where to set the workgroup type (production / lab) for the application.
public class Register {
public static void main(String args[]) {
RegisteringApplication registerApp = ConnectorFactory.getConnector(RegisteringApplication.class);
try{
String productCallbackUrl = "http://fake";
String APPLICATION_TYPE = "custom";
String registrationURL = registerApp.createRegistrationRequest(productCallbackUrl, APPLICATION_TYPE);
System.out.println("\n\n*** Open This URL: " + registrationURL);
}
catch (Exception e) {
System.out.println("Error Creating Request! The Error is: " + e);
}
}
}
any guidance or insights would be greatly appreciated.
Regan
07-08-2017 06:59 AM
hello.
the below code resource documentation discusses the ConnectorConfigration and the LAB_MODE property
question: does this need to occur every-time the connector factory initializes the client and management connections? or is this setting a persistent value on the workgroup that require a subsequent call setting LAB_MODE to false?
Cisco DevNet: Context Service - Context Service SDK Guide
Example Code:
public static CredentialsChangedListener addCredentialsListenerToManagementConnector(ManagementConnector managementConnector, final ContextServiceClient contextServiceClient){
CredentialsChangedListener credentialsChangedListener = new CredentialsChangedListener() {
String connectionData;
@Override
public void credentialsChanged(String newConnectionData) {
LOGGER.info("ConnectionData changed: " + newConnectionData);
connectionData = newConnectionData;
// Connection data is not usually logged due to security considerations.
String hostname = "doctest.example.com";
ConnectorInfoImpl connInfo = new ConnectorInfoImpl(hostname);
ConnectorConfiguration configuration = new ConnectorConfiguration() {{
addProperty("LAB_MODE", true); // exclude this line for production mode
addProperty("REQUEST_TIMEOUT", 10000);
}};
// Notify contextServiceClient that the connection data changed.
contextServiceClient.updateAndReloadConfigAsync(connectionData, connInfo, configuration, null);
}
};
managementConnector.addCredentialsChangedListener(credentialsChangedListener);
return credentialsChangedListener;
}
thanks.
Regan
07-08-2017 07:37 AM
i believe im making some progress. kinda.
Code / Method: issued this after connecting (client / management) to context service.
public static void setLabMode(Boolean labMode, String connectionData, String hostName, ContextServiceClient contextServiceClient) {
ConnectorInfoImpl connInfo = new ConnectorInfoImpl(hostName);
ConnectorConfiguration configuration;
if (labMode) {
configuration = new ConnectorConfiguration() {{
addProperty("LAB_MODE", true); // exclude this line for production mode
addProperty("REQUEST_TIMEOUT", 10000);
}};
} else {
configuration = new ConnectorConfiguration() {{
addProperty("LAB_MODE", false); // exclude this line for production mode
addProperty("REQUEST_TIMEOUT", 10000);
}};
}
// Notify contextServiceClient that the connection data changed.
contextServiceClient.updateAndReloadConfigAsync(connectionData, connInfo, configuration, null);
}
Connection type for client: Lab_Mode=True
"config": {
},
results: same error
type Exception report
message java.lang.Exception: {"errorType":"unAuthorized","errorData":"workgroup","errorMessage":"Object is in non-lab workgroup. Cannot be deleted, trackingId: 3a422a67-7aa6-4046-9414-d6a72f6c4a2f"}: ApiError with errorType: unAuthorized, errorData: workgroup, errorMessage: Object is in non-lab workgroup. Cannot be deleted, trackingId: 3a422a67-7aa6-4046-9414-d6a72f6c4a2f
thoughts and guidance welcome.
07-08-2017 08:14 AM
resolved:
was missing - managementConnector.addCredentialsChangedListener(credentialsChangedListener);
07-10-2017 06:55 PM
Hi,
You cannot delete objects if you are in production mode. That is by design. If you want to delete things, use lab mode.
Tom
07-13-2017 06:00 AM
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide