use of EmployeeDefs.AEmployeeException.InvalidCommandDescriptor in project SmartCity-Market by TechnionYP5777.
the class Manager method addIngredient.
@Override
public Ingredient addIngredient(Ingredient w) throws InvalidParameter, CriticalError, EmployeeNotConnected, ConnectionFailure, ParamIDAlreadyExists {
log.info("Creating addIngredient command wrapper with Ingredient: " + w);
String serverResponse = sendRequestWithRespondToServer((new CommandWrapper(getClientId(), CommandDescriptor.ADD_INGREDIENT, Serialization.serialize(w))).serialize());
CommandWrapper commandDescriptor = getCommandWrapper(serverResponse);
try {
resultDescriptorHandler(commandDescriptor.getResultDescriptor());
} catch (InvalidCommandDescriptor | EmployeeAlreadyConnected | AuthenticationError | ProductStillForSale | AmountBiggerThanAvailable | ProductPackageDoesNotExist | ProductAlreadyExistInCatalog | ProductNotExistInCatalog | ParamIDDoesNotExist | WorkerAlreadyExists | WorkerDoesNotExist | IngredientStillInUse | ManfacturerStillInUse ¢) {
log.fatal("Critical bug: this command result isn't supposed to return here");
throw new CriticalError();
}
log.info("addIngredient command succeed.");
return Serialization.deserialize(commandDescriptor.getData(), Ingredient.class);
}
use of EmployeeDefs.AEmployeeException.InvalidCommandDescriptor in project SmartCity-Market by TechnionYP5777.
the class Manager method removeIngredient.
@Override
public void removeIngredient(Ingredient w, Boolean forced) throws InvalidParameter, CriticalError, EmployeeNotConnected, ConnectionFailure, ParamIDDoesNotExist, IngredientStillInUse {
log.info("Creating removeIngredient command wrapper with Ingredient: " + w);
String serverResponse = sendRequestWithRespondToServer((new CommandWrapper(getClientId(), !forced ? CommandDescriptor.REMOVE_INGREDIENT : CommandDescriptor.FORCE_REMOVE_INGREDIENT, Serialization.serialize(w))).serialize());
CommandWrapper commandDescriptor = getCommandWrapper(serverResponse);
try {
resultDescriptorHandler(commandDescriptor.getResultDescriptor());
} catch (InvalidCommandDescriptor | EmployeeAlreadyConnected | AuthenticationError | ProductStillForSale | AmountBiggerThanAvailable | ProductPackageDoesNotExist | ProductAlreadyExistInCatalog | ProductNotExistInCatalog | WorkerAlreadyExists | ParamIDAlreadyExists | WorkerDoesNotExist | ManfacturerStillInUse ¢) {
log.fatal("Critical bug: this command result isn't supposed to return here");
throw new CriticalError();
}
log.info("removeIngredient command succeed.");
}
use of EmployeeDefs.AEmployeeException.InvalidCommandDescriptor in project SmartCity-Market by TechnionYP5777.
the class Manager method getAllWorkers.
@Override
public HashMap<String, Boolean> getAllWorkers() throws CriticalError, EmployeeNotConnected, ConnectionFailure {
log.info("Creating getAllWorkers command wrapper");
String serverResponse = sendRequestWithRespondToServer((new CommandWrapper(getClientId(), CommandDescriptor.GET_ALL_WORKERS, Serialization.serialize(""))).serialize());
CommandWrapper commandDescriptor = getCommandWrapper(serverResponse);
try {
resultDescriptorHandler(commandDescriptor.getResultDescriptor());
} catch (InvalidCommandDescriptor | EmployeeAlreadyConnected | AuthenticationError | ProductStillForSale | AmountBiggerThanAvailable | ProductPackageDoesNotExist | ProductAlreadyExistInCatalog | ProductNotExistInCatalog | WorkerAlreadyExists | ParamIDAlreadyExists | ParamIDDoesNotExist | WorkerDoesNotExist | IngredientStillInUse | ManfacturerStillInUse | InvalidParameter ¢) {
log.fatal("Critical bug: this command result isn't supposed to return here");
throw new CriticalError();
}
log.info("getAllWorkers command succeed.");
return new Gson().fromJson(commandDescriptor.getData(), new TypeToken<HashMap<String, Boolean>>() {
}.getType());
}
use of EmployeeDefs.AEmployeeException.InvalidCommandDescriptor in project SmartCity-Market by TechnionYP5777.
the class Worker method addProductToWarehouse.
@Override
public void addProductToWarehouse(ProductPackage p) throws InvalidParameter, CriticalError, EmployeeNotConnected, ProductNotExistInCatalog, ConnectionFailure {
log.info("Creating addProductToWarehouse command wrapper with product package: " + p);
String serverResponse = sendRequestWithRespondToServer(new CommandWrapper(getClientId(), CommandDescriptor.ADD_PRODUCT_PACKAGE_TO_WAREHOUSE, Serialization.serialize(p)).serialize());
CommandWrapper commandDescriptor = getCommandWrapper(serverResponse);
try {
resultDescriptorHandler(commandDescriptor.getResultDescriptor());
} catch (InvalidCommandDescriptor | EmployeeAlreadyConnected | AuthenticationError | ProductAlreadyExistInCatalog | ProductStillForSale | AmountBiggerThanAvailable | ProductPackageDoesNotExist | WorkerAlreadyExists | ParamIDAlreadyExists | ParamIDDoesNotExist | WorkerDoesNotExist | IngredientStillInUse | ManfacturerStillInUse ¢) {
log.fatal("Critical bug: this command result isn't supposed to return here");
throw new CriticalError();
}
log.info("addProductToWarehouse command succeed.");
}
use of EmployeeDefs.AEmployeeException.InvalidCommandDescriptor in project SmartCity-Market by TechnionYP5777.
the class Worker method getProductPackageAmount.
@Override
public int getProductPackageAmount(ProductPackage p) throws InvalidParameter, CriticalError, EmployeeNotConnected, ProductPackageDoesNotExist, ConnectionFailure {
log.info("Creating getProductPackageAmount command wrapper with product package: " + p);
String serverResponse = sendRequestWithRespondToServer(new CommandWrapper(getClientId(), CommandDescriptor.GET_PRODUCT_PACKAGE_AMOUNT, Serialization.serialize(p)).serialize());
CommandWrapper $ = getCommandWrapper(serverResponse);
try {
resultDescriptorHandler($.getResultDescriptor());
} catch (InvalidCommandDescriptor | EmployeeAlreadyConnected | AuthenticationError | ProductNotExistInCatalog | ProductAlreadyExistInCatalog | ProductStillForSale | AmountBiggerThanAvailable | WorkerAlreadyExists | ParamIDAlreadyExists | ParamIDDoesNotExist | WorkerDoesNotExist | IngredientStillInUse | ManfacturerStillInUse ¢) {
log.fatal("Critical bug: this command result isn't supposed to return here");
throw new CriticalError();
}
log.info("getProductPackageAmount command succeed.");
return Serialization.deserialize($.getData(), Integer.class);
}
Aggregations