def get_reference_by_uuid(self, uuid):
   try:
     return self.reference_broker.get_by_uuid(uuid)
   except NothingFoundException as error:
     raise ControllerNothingFoundException(error)
   except BrokerException as error:
     raise ControllerException(error)
コード例 #2
0
 def get_process_item_by_id(self, process_id):
     try:
         return self.process_broker.get_by_id(process_id)
     except NothingFoundException as error:
         raise ControllerNothingFoundException(error)
     except BrokerException as error:
         raise ControllerException(error)
コード例 #3
0
ファイル: objectdefinitions.py プロジェクト: tsmolka/ce1sus
 def get_object_definitions_by_id(self, object_id):
     try:
         return self.obj_def_broker.get_by_id(object_id)
     except NothingFoundException as error:
         raise ControllerNothingFoundException(error)
     except BrokerException as error:
         raise ControllerException(error)
コード例 #4
0
 def get_group_by_name(self, group_name):
     try:
         return self.group_broker.get_by_name(group_name)
     except NothingFoundException as error:
         raise ControllerNothingFoundException(error)
     except BrokerException as error:
         raise ControllerException(error)
 def get_reference_by_id(self, identifier):
   try:
     return self.reference_broker.get_by_id(identifier)
   except NothingFoundException as error:
     raise ControllerNothingFoundException(error)
   except BrokerException as error:
     raise ControllerException(error)
コード例 #6
0
    def __process_observable_get(self, event, requested_object, details,
                                 inflated):
        user = self.get_user()

        try:
            event_permission = self.get_event_user_permissions(event, user)
            uuid = requested_object['object_uuid']
            if uuid:
                # return the given observable
                # TODO: Check if observable belongs to event
                observable = self.observable_controller.get_observable_by_uuid(
                    uuid)
                self.check_item_is_viewable(event, observable)
                if is_object_viewable(observable, event_permission, user):
                    return observable.to_dict(details, inflated,
                                              event_permission, user)
                else:
                    raise ControllerNothingFoundException(
                        u'Cannot find observable with uuid {0}'.format(uuid))

            else:
                # return all observables from the event
                result = list()
                for observable in event.get_observables_for_permissions(
                        event_permission, user):
                    if self.is_item_viewable(event, observable):
                        result.append(
                            observable.to_dict(details, inflated,
                                               event_permission, user))

                return result
        except ControllerException as error:
            raise RestHandlerException(error)
コード例 #7
0
ファイル: objectdefinitions.py プロジェクト: tsmolka/ce1sus
 def get_object_definition_by_chksums(self, chksums):
     try:
         return self.obj_def_broker.get_defintion_by_chksums(chksums)
     except NothingFoundException as error:
         raise ControllerNothingFoundException(error)
     except BrokerException as error:
         raise ControllerException(error)
コード例 #8
0
 def get_user_by_id(self, user_id):
   try:
     return self.user_broker.get_by_id(user_id)
   except NothingFoundException as error:
     raise ControllerNothingFoundException(error)
   except BrokerException as error:
     raise ControllerException(error)
コード例 #9
0
 def get_event_for_observable(self, observable):
     if observable.parent:
         return observable.parent
     else:
         raise ControllerNothingFoundException(
             'Parent for observable {0} cannot be found'.format(
                 observable.identifier))
コード例 #10
0
 def get_user_by_activation_str(self, act_str):
   try:
     return self.user_broker.get_user_by_act_str(act_str)
   except NothingFoundException as error:
     raise ControllerNothingFoundException(error)
   except BrokerException as error:
     raise ControllerException(error)
コード例 #11
0
 def get_all_handlers(self):
     try:
         return self.handler_broker.get_all()
     except NothingFoundException as error:
         raise ControllerNothingFoundException(error)
     except BrokerException as error:
         raise ControllerException(error)
コード例 #12
0
 def get_user_by_username(self, username):
   try:
     return self.user_broker.getUserByUserName(username)
   except NothingFoundException as error:
     raise ControllerNothingFoundException(error)
   except BrokerException as error:
     raise ControllerException(error)
コード例 #13
0
 def get_defintion_by_name(self, name):
     try:
         return self.attr_def_broker.get_defintion_by_name(name)
     except NothingFoundException as error:
         raise ControllerNothingFoundException(error)
     except BrokerException as error:
         raise ControllerException(error)
コード例 #14
0
 def get_event_for_obj(self, obj):
     try:
         return self.get_event_for_observable(obj.observable)
     except NothingFoundException as error:
         raise ControllerNothingFoundException(error)
     except BrokerException as error:
         raise ControllerException(error)
コード例 #15
0
ファイル: assembler.py プロジェクト: tsmolka/ce1sus
    def get_reference_definition(self, json, seen_ref_def=None):
        if seen_ref_def is None:
            seen_ref_def = dict()
        uuid = json.get('definition_id', None)
        if not uuid:
            definition_json = json.get('definition', None)
            if definition_json:
                uuid = definition_json.get('identifier', None)
        if uuid:
            rd = seen_ref_def.get(uuid, None)
            if rd:
                return rd
            else:
                try:
                    definition = self.reference_definiton_broker.get_by_uuid(
                        uuid)
                    seen_ref_def[uuid] = definition
                except NothingFoundException as error:
                    raise ControllerNothingFoundException(error)
                except BrokerException as error:
                    raise ControllerException(error)

                return definition
        raise ControllerException(
            'Could not find "{0}" definition in the reference'.format(
                definition_json))
コード例 #16
0
 def remove_observable(self, observable, user, commit=True):
     try:
         self.observable_broker.remove_by_id(observable.identifier)
         self.observable_broker.do_commit(commit)
     except NothingFoundException as error:
         raise ControllerNothingFoundException(error)
     except BrokerException as error:
         raise ControllerException(error)
コード例 #17
0
 def get_event_group_by_uuid(self, uuid):
     try:
         return self.event_broker.get_group_by_uuid(uuid)
     except NothingFoundException as error:
         self.logger.debug(error)
         raise ControllerNothingFoundException(error)
     except BrokerException as error:
         raise ControllerException(error)
コード例 #18
0
 def get_group_by_id(self, identifier):
     try:
         return self.group_broker.get_by_id(identifier)
     except NothingFoundException as error:
         self.logger.debug(error)
         raise ControllerNothingFoundException(error)
     except BrokerException as error:
         raise ControllerException(error)
コード例 #19
0
 def get_object_by_uuid(self, uuid):
     try:
         obj = self.object_broker.get_by_uuid(uuid)
         return obj
     except NothingFoundException as error:
         raise ControllerNothingFoundException(error)
     except BrokerException as error:
         raise ControllerException(error)
コード例 #20
0
 def get_parent_object_by_object(self, obj):
     try:
         obj = self.object_broker.get_parent_object_by_object(obj)
         return obj
     except NothingFoundException as error:
         raise ControllerNothingFoundException(error)
     except BrokerException as error:
         raise ControllerException(error)
コード例 #21
0
 def get_object_by_id(self, identifier):
     try:
         obj = self.object_broker.get_by_id(identifier)
         return obj
     except NothingFoundException as error:
         raise ControllerNothingFoundException(error)
     except BrokerException as error:
         raise ControllerException(error)
コード例 #22
0
 def get_composition_by_observable(self, observable):
     try:
         composition = self.composed_observable_broker.get_by_observable_id(
             observable.identifier)
         return composition
     except NothingFoundException as error:
         raise ControllerNothingFoundException(error)
     except BrokerException as error:
         raise ControllerException(error)
コード例 #23
0
 def get_composed_observable_by_uuid(self, uuid):
     try:
         composed_observable = self.composed_observable_broker.get_by_uuid(
             uuid)
         return composed_observable
     except NothingFoundException as error:
         raise ControllerNothingFoundException(error)
     except BrokerException as error:
         raise ControllerException(error)
コード例 #24
0
 def get_attribute_definitions_by_uuid(self, uuid):
     """
 Returns the attribute definition by the given id
 """
     try:
         return self.attr_def_broker.get_by_uuid(uuid)
     except NothingFoundException as error:
         raise ControllerNothingFoundException(error)
     except BrokerException as error:
         raise ControllerException(error)
コード例 #25
0
 def remove_observable_composition(self,
                                   compoed_observable,
                                   user,
                                   commit=True):
     try:
         for observable in compoed_observable.observables:
             self.observable_broker.remove_by_id(observable.identifier)
         self.composed_observable_broker.remove_by_id(
             compoed_observable.identifier)
     except NothingFoundException as error:
         raise ControllerNothingFoundException(error)
     except BrokerException as error:
         raise ControllerException(error)
コード例 #26
0
ファイル: assembler.py プロジェクト: tsmolka/ce1sus
 def get_object_definition(self, json, seen_obj_defs):
     uuid = json.get('definition_id', None)
     if not uuid:
         definition = json.get('definition', None)
         if definition:
             uuid = definition.get('identifier', None)
     if uuid:
         od = seen_obj_defs.get(uuid, None)
         if od:
             return od
         else:
             try:
                 definition = self.obj_def_broker.get_by_uuid(uuid)
             except NothingFoundException as error:
                 raise ControllerNothingFoundException(error)
             except BrokerException as error:
                 raise ControllerException(error)
             seen_obj_defs[uuid] = definition
             return definition
     raise ControllerException('Could not find a definition in the object')
コード例 #27
0
    def __process_event_report(self, method, event, requested_object, details,
                               inflated, json, headers):

        user = self.get_user()
        if method == 'GET':
            event_permission = self.get_event_user_permissions(event, user)
            uuid = requested_object['object_uuid']
            if uuid:
                # return the given observable
                # TODO: Check if observable belongs to event
                report = self.report_controller.get_report_by_uuid(uuid)
                self.check_item_is_viewable(event, report)
                if is_object_viewable(report, event_permission):
                    return report.to_dict(details, inflated, event_permission,
                                          user)
                else:
                    raise ControllerNothingFoundException(
                        u'Cannot find observable with uuid {0}'.format(uuid))

            else:
                # return all observables from the event
                result = list()
                for report in event.get_reports_for_permissions(
                        event_permission, user):
                    if self.is_item_viewable(event, report):
                        result.append(
                            report.to_dict(details, inflated, event_permission,
                                           user))
                return result
        if method == 'POST':
            event_permission = self.get_event_user_permissions(event, user)
            self.check_if_user_can_add(event)
            report = self.assembler.assemble_report(
                event, json, user, self.is_event_owner(event, user),
                self.is_rest_insert(headers))

            self.report_controller.insert_report(report, user)
            return report.to_dict(details, inflated, event_permission, user)
        else:
            raise RestHandlerException('Operation not supported')
        return list()
コード例 #28
0
ファイル: assembler.py プロジェクト: tsmolka/ce1sus
 def get_attribute_definition(self, json, seen_attr_defs=None):
     if seen_attr_defs is None:
         seen_attr_defs = dict()
     uuid = json.get('definition_id', None)
     if not uuid:
         definition = json.get('definition', None)
         if definition:
             uuid = definition.get('identifier', None)
     if uuid:
         ad = seen_attr_defs.get(uuid, None)
         if ad:
             return ad
         else:
             try:
                 definition = self.attr_def_broker.get_by_uuid(uuid)
             except NothingFoundException as error:
                 raise ControllerNothingFoundException(error)
             except BrokerException as error:
                 raise ControllerException(error)
             seen_attr_defs[uuid] = definition
             return definition
     raise ControllerException(
         'Could not find a definition in the attribute')