use of EmployeeDefs.AEmployeeException.EmployeeAlreadyConnected in project SmartCity-Market by TechnionYP5777.
the class Worker method isLoggedIn.
@Override
public boolean isLoggedIn() throws CriticalError, ConnectionFailure {
String serverResponse;
log.info("Creating is logged in command wrapper with senderID: " + getClientId());
serverResponse = sendRequestWithRespondToServer((new CommandWrapper(getClientId(), CommandDescriptor.IS_LOGGED_IN)).serialize());
CommandWrapper commandWrapper = getCommandWrapper(serverResponse);
try {
resultDescriptorHandler(commandWrapper.getResultDescriptor());
} catch (InvalidCommandDescriptor | InvalidParameter | EmployeeNotConnected | EmployeeAlreadyConnected | AuthenticationError | ProductNotExistInCatalog | ProductAlreadyExistInCatalog | ProductStillForSale | AmountBiggerThanAvailable | ProductPackageDoesNotExist | WorkerAlreadyExists | ParamIDAlreadyExists | ParamIDDoesNotExist | WorkerDoesNotExist | IngredientStillInUse | ManfacturerStillInUse e) {
log.fatal("Critical bug: this command result isn't supposed to return here");
throw new CriticalError();
}
log.info("is logged out from server succeed");
return Serialization.deserialize(commandWrapper.getData(), Boolean.class);
}
use of EmployeeDefs.AEmployeeException.EmployeeAlreadyConnected in project SmartCity-Market by TechnionYP5777.
the class Worker method viewProductFromCatalog.
@Override
public CatalogProduct viewProductFromCatalog(long barcode) throws InvalidParameter, CriticalError, EmployeeNotConnected, ProductNotExistInCatalog, ConnectionFailure {
log.info("Creating viewProductFromCatalog command wrapper with barcode: " + barcode);
String serverResponse = sendRequestWithRespondToServer(new CommandWrapper(getClientId(), CommandDescriptor.VIEW_PRODUCT_FROM_CATALOG, Serialization.serialize(new SmartCode(barcode, null))).serialize());
CommandWrapper $ = getCommandWrapper(serverResponse);
try {
resultDescriptorHandler($.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("viewProductFromCatalog command succeed.");
return Serialization.deserialize($.getData(), CatalogProduct.class);
}
use of EmployeeDefs.AEmployeeException.EmployeeAlreadyConnected in project SmartCity-Market by TechnionYP5777.
the class Worker method placeProductPackageOnShelves.
@Override
public void placeProductPackageOnShelves(ProductPackage p) throws InvalidParameter, CriticalError, EmployeeNotConnected, ProductNotExistInCatalog, AmountBiggerThanAvailable, ProductPackageDoesNotExist, ConnectionFailure {
log.info("Creating placeProductPackageOnShelves command wrapper with product package: " + p);
String serverResponse = sendRequestWithRespondToServer(new CommandWrapper(getClientId(), CommandDescriptor.PLACE_PRODUCT_PACKAGE_ON_SHELVES, Serialization.serialize(p)).serialize());
CommandWrapper commandDescriptor = getCommandWrapper(serverResponse);
try {
resultDescriptorHandler(commandDescriptor.getResultDescriptor());
} catch (InvalidCommandDescriptor | EmployeeAlreadyConnected | AuthenticationError | ProductAlreadyExistInCatalog | ProductStillForSale | WorkerAlreadyExists | ParamIDAlreadyExists | ParamIDDoesNotExist | WorkerDoesNotExist | IngredientStillInUse | ManfacturerStillInUse ¢) {
log.fatal("Critical bug: this command result isn't supposed to return here");
throw new CriticalError();
}
log.info("placeProductPackageOnShelves command succeed.");
}
use of EmployeeDefs.AEmployeeException.EmployeeAlreadyConnected in project SmartCity-Market by TechnionYP5777.
the class Manager method addProductToCatalog.
@Override
public void addProductToCatalog(CatalogProduct p) throws InvalidParameter, CriticalError, EmployeeNotConnected, ProductAlreadyExistInCatalog, ConnectionFailure {
log.info("Creating addProductToCatalog command wrapper with product: " + p);
String serverResponse = sendRequestWithRespondToServer((new CommandWrapper(getClientId(), CommandDescriptor.ADD_PRODUCT_TO_CATALOG, Serialization.serialize(p))).serialize());
CommandWrapper commandDescriptor = getCommandWrapper(serverResponse);
try {
resultDescriptorHandler(commandDescriptor.getResultDescriptor());
} catch (InvalidCommandDescriptor | EmployeeAlreadyConnected | AuthenticationError | ProductStillForSale | AmountBiggerThanAvailable | ProductPackageDoesNotExist | ProductNotExistInCatalog | WorkerAlreadyExists | ParamIDAlreadyExists | ParamIDDoesNotExist | WorkerDoesNotExist | IngredientStillInUse | ManfacturerStillInUse ¢) {
log.fatal("Critical bug: this command result isn't supposed to return here");
throw new CriticalError();
}
log.info("addProductToCatalog command succeed.");
}
use of EmployeeDefs.AEmployeeException.EmployeeAlreadyConnected in project SmartCity-Market by TechnionYP5777.
the class Manager method editManufacturer.
@Override
public void editManufacturer(Manufacturer m) throws InvalidParameter, CriticalError, EmployeeNotConnected, ConnectionFailure, ParamIDDoesNotExist {
log.info("Creating editManufacturer command wrapper with Manufacturer: " + m);
String serverResponse = sendRequestWithRespondToServer((new CommandWrapper(getClientId(), CommandDescriptor.EDIT_MANUFACTURER, Serialization.serialize(m))).serialize());
CommandWrapper commandDescriptor = getCommandWrapper(serverResponse);
try {
resultDescriptorHandler(commandDescriptor.getResultDescriptor());
} catch (InvalidCommandDescriptor | EmployeeAlreadyConnected | AuthenticationError | ProductStillForSale | AmountBiggerThanAvailable | ProductPackageDoesNotExist | ProductAlreadyExistInCatalog | ProductNotExistInCatalog | WorkerAlreadyExists | ParamIDAlreadyExists | WorkerDoesNotExist | IngredientStillInUse | ManfacturerStillInUse ¢) {
log.fatal("Critical bug: this command result isn't supposed to return here");
throw new CriticalError();
}
log.info("editManufacturer command succeed.");
}
Aggregations