예제 #1
0
 /**
  * Construct an asset object
  *
  * @param AssetOperationHandlerService $service    The service object
  * @param stdClass                     $identifier The identifier of the asset
  * @throws NullServiceException        if the service object is NULL
  * @throws NullIdentifierException     if the identifier object is NULL
  * @throws NullAssetException          if the asset cannot be retrieved
  */
 public function __construct(aohs\AssetOperationHandlerService $service, \stdClass $identifier)
 {
     if ($service == NULL) {
         throw new e\NullServiceException(c\M::NULL_SERVICE);
     }
     if ($identifier == NULL) {
         throw new e\NullIdentifierException(c\M::NULL_IDENTIFIER);
     }
     if (self::DEBUG && self::DUMP) {
         u\DebugUtility::dump($identifier);
     }
     // get the property
     $property = $service->retrieve($identifier, c\T::$type_property_name_map[$identifier->type]);
     if ($property == NULL) {
         if (isset($identifier->id)) {
             $id = $identifier->id;
         }
         if (isset($identifier->path)) {
             $path = $identifier->path->path;
             if (isset($identifier->path->siteName)) {
                 $site_name = $identifier->path->siteName;
             }
         }
         if (!isset($id)) {
             $id = $path;
         }
         throw new e\NullAssetException(S_SPAN . "The " . c\T::$type_property_name_map[$identifier->type] . " cannot be retrieved. ID/Path: " . $id . ". " . (isset($site_name) ? "Site: " . $site_name . ". " : "") . E_SPAN . BR . $service->getMessage());
     }
     // store information
     $this->service = $service;
     $this->identifier = $identifier;
     //stdClass
     $this->type = $identifier->type;
     $this->property_name = c\T::$type_property_name_map[$this->type];
     $this->property = $property;
     if (isset($property->id)) {
         $this->id = $property->id;
     }
     if (isset($property->name)) {
         $this->name = $property->name;
     }
     if (isset($property->path)) {
         $this->path = $property->path;
     }
     if (isset($property->siteId)) {
         $this->site_id = $property->siteId;
     }
     if (isset($property->siteName)) {
         $this->site_name = $property->siteName;
     }
 }
 public static function initialize(aohs\AssetOperationHandlerService $service)
 {
     try {
         $service->listMessages();
         if ($service->isSuccessful()) {
             $messages = $service->getListedMessages();
             $temp_msg = array();
             if (!($messages->message == NULL)) {
                 if (!is_array($messages->message)) {
                     $temp_msg[] = $messages->message;
                 } else {
                     $temp_msg = $messages->message;
                 }
                 foreach ($temp_msg as $message) {
                     $id = $message->id;
                     $to = $message->to;
                     $from = $message->from;
                     $date = $message->date;
                     $subject = trim($message->subject);
                     $body = $message->body;
                     self::$all_message_ids[] = $id;
                     $message_obj = new Message($message);
                     // store all messages
                     self::$all_messages[] = $message_obj;
                     self::$id_obj_map[$id] = $message_obj;
                     // from whom?
                     if (!isset($message_ids_from[$from])) {
                         self::$message_ids_from[$from] = array();
                     }
                     self::$message_ids_from[$from][] = $id;
                     if ($from != 'system') {
                         self::$non_system_messages[] = $message_obj;
                     }
                     if (self::DEBUG) {
                         u\DebugUtility::out($message_obj->getType());
                     }
                     if ($message_obj->getType() == Message::TYPE_EXPIRATION) {
                         self::$asset_expiration_message[] = $message_obj;
                         self::$asset_expiration_message_ids[] = $id;
                     } else {
                         if ($message_obj->getType() == Message::TYPE_PUBLISH) {
                             self::$publish_messages[] = $message_obj;
                             self::$publish_message_ids[] = $id;
                             // no issues
                             if (strpos($subject, "(0 issue(s))") !== false) {
                                 if (self::DEBUG) {
                                     echo "L::121 " . $id . BR;
                                 }
                                 self::$publish_message_ids_without_issues[] = $id;
                                 self::$publish_messages_without_issues[] = $message_obj;
                             } else {
                                 if (self::DEBUG) {
                                     echo "L::124 " . $id . BR;
                                 }
                                 self::$publish_message_ids_with_issues[] = $id;
                                 self::$publish_messages_with_issues[] = $message_obj;
                             }
                         } else {
                             if ($message_obj->getType() == Message::TYPE_UNPUBLISH) {
                                 self::$unpublish_messages[] = $message_obj;
                                 self::$unpublish_message_ids[] = $id;
                                 // no issues
                                 if (strpos($subject, "(0 issue(s))") !== false) {
                                     self::$unpublish_message_ids_without_issues[] = $id;
                                     self::$unpublish_messages_without_issues[] = $message_obj;
                                 } else {
                                     self::$unpublish_message_ids_with_issues[] = $id;
                                     self::$unpublish_messages_with_issues[] = $message_obj;
                                 }
                             } else {
                                 if ($message_obj->getType() == Message::TYPE_SUMMARY) {
                                     self::$summary_messages[] = $message_obj;
                                     self::$summary_message_ids[] = $id;
                                     // 0 failures
                                     if (strpos($subject, "(0 failures)") !== false) {
                                         self::$summary_message_ids_no_failures[] = $id;
                                         self::$summary_messages_no_failures[] = $message_obj;
                                     } else {
                                         self::$summary_message_ids_with_failures[] = $id;
                                         self::$summary_messages_with_failures[] = $message_obj;
                                     }
                                 } else {
                                     if ($message_obj->getType() == Message::TYPE_WORKFLOW) {
                                         self::$workflow_messages[] = $message_obj;
                                         self::$workflow_message_ids[] = $id;
                                         // is complete
                                         if (strpos($subject, "is complete") !== false) {
                                             self::$workflow_message_ids_is_complete[] = $id;
                                             self::$workflow_messages_complete[] = $message_obj;
                                         } else {
                                             self::$workflow_message_ids_other[] = $id;
                                             self::$workflow_messages_other[] = $message_obj;
                                         }
                                     } else {
                                         self::$other_messages[] = $message_obj;
                                         self::$other_message_ids[] = $id;
                                     }
                                 }
                             }
                         }
                     }
                     // date
                 }
                 usort(self::$all_messages, self::NAME_SPACE . "\\" . 'Message::compare');
                 usort(self::$publish_messages, self::NAME_SPACE . "\\" . 'Message::compare');
                 usort(self::$unpublish_messages, self::NAME_SPACE . "\\" . 'Message::compare');
                 usort(self::$workflow_messages, self::NAME_SPACE . "\\" . 'Message::compare');
                 usort(self::$other_messages, self::NAME_SPACE . "\\" . 'Message::compare');
                 usort(self::$publish_messages_with_issues, self::NAME_SPACE . "\\" . 'Message::compare');
                 usort(self::$unpublish_messages_with_issues, self::NAME_SPACE . "\\" . 'Message::compare');
                 usort(self::$workflow_messages_other, self::NAME_SPACE . "\\" . 'Message::compare');
                 usort(self::$non_system_messages, self::NAME_SPACE . "\\" . 'Message::compare');
             }
             //var_dump( $workflow_message_ids_is_complete );
         } else {
             echo "Failed to list messages. " . $service->getMessage();
         }
     } catch (\Exception $e) {
         echo S_PRE . $e . E_PRE;
     }
 }