18 require_once SQ_PACKAGES_PATH.
'/web_services/api/soap_api/soap_api.inc';
43 parent::__construct($assetid);
58 'SetMetadataSchema' =>
'1',
59 'GetMetadataFieldsOfSchema' =>
'1',
60 'GetMetadataFieldValues' =>
'1',
61 'RegenerateMetadataSchema' =>
'1',
62 'RegenerateMetadataAsset' =>
'1',
63 'GetMetadataValueByIDs' =>
'1',
64 'SetAssetMetadata' =>
'1',
65 'SetMultipleMetadataFields' =>
'1',
66 'SetMetadataFieldDefaultValue' =>
'1',
67 'GetSchemasOnAsset' =>
'1',
90 $request_info = (Array) $request;
91 $assetid = array_get_index($request_info,
'AssetID',
'');
92 $schemaid = array_get_index($request_info,
'SchemaID',
'');
93 $grant = array_get_index($request_info,
'Grant',
'');
94 $grant_level = Array (
99 $grant_val = $grant_level[$grant];
100 $cascade = array_get_index($request_info,
'Cascade',
'1');
101 $dependants = $GLOBALS[
'SQ_SYSTEM']->am->getDependantChildren($assetid);
102 $has_dependants = !empty($dependants);
104 if (!empty($assetid) && !empty($schemaid)) {
105 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
106 $running_vars = Array (
107 'schema_changes' => Array (
109 'assetids' => Array ( $assetid),
110 'granted' => $grant_val,
111 'schemaid' => $schemaid,
112 'cascades' => $cascade,
113 'previous_access' => NULL,
118 $errors = $hh->freestyleHipo(
'hipo_job_edit_metadata_schemas', $running_vars);
119 if (empty($errors)) {
121 'SetSchemaResult' => TRUE,
124 throw new SoapFault(
'Server',
'Unable to set Metadata Schema on Asset');
127 throw new SoapFault(
'Server',
'Asset ID or Schema ID is not valid. Please provide a valid AssetID and SchemaID');
148 $request_info = (Array) $request;
149 $schemaid = array_get_index($request_info,
'SchemaID',
'');
151 if (!empty($schemaid)) {
152 $schema = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($schemaid);
154 throw new SoapFault(
'Server',
'The provided Schema ID does not belong to a metadata schema');
156 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
157 $running_vars = Array (
158 'schemaids' => Array ($schemaid),
160 $errors = $hh->freestyleHipo(
'hipo_job_regenerate_metadata', $running_vars);
161 if (empty($errors)) {
163 'RegenerateMetadataSchemaResult' => TRUE,
167 if (isset($errors[0][
'message'])) $message = $errors[0][
'message'];
168 throw new SoapFault(
'Server',
'Unable To Regenerate Metadata For Schema. '.$message);
171 throw new SoapFault(
'Server',
'Schema ID Is Not Valid. Please Provide A Valid Schema ID');
192 $request_info = (Array) $request;
193 $assetid = array_get_index($request_info,
'AssetID',
'');
195 if (!empty($assetid)) {
196 $mm = $GLOBALS[
'SQ_SYSTEM']->getMetadataManager();
197 $GLOBALS[
'SQ_SYSTEM']->am->acquireLock($assetid,
'metadata');
198 $result = $mm->regenerateMetadata($assetid,
'all');
199 $GLOBALS[
'SQ_SYSTEM']->am->releaseLock($assetid,
'metadata');
202 'RegenerateMetadataAssetResult' => TRUE,
205 throw new SoapFault(
'Server',
'Unable To Regenerate Metadata For Asset');
208 throw new SoapFault(
'Server',
'Asset ID Is Not Valid. Please Provide A Valid Asset ID');
231 $request_info = (Array) $request;
232 $assetid = array_get_index($request_info,
'AssetID',
'');
233 $fieldid = array_get_index($request_info,
'FieldID',
'');
234 $new_value = array_get_index($request_info,
'NewValue',
'');
236 if (!empty($assetid) && !empty($fieldid)) {
237 $field = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($fieldid);
239 throw new SoapFault(
'Server',
'The Field ID provided does not belong to a metadata field');
241 $mm = $GLOBALS[
'SQ_SYSTEM']->getMetadataManager();
242 $GLOBALS[
'SQ_SYSTEM']->am->acquireLock($assetid,
'metadata');
244 $field_asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($fieldid);
245 $field_name = $field_asset->attr(
'name');
250 $metadata_info = Array (
253 'name' => $field_name,
254 'value' => $new_value,
258 $result = $mm->setMetadata($assetid, $metadata_info);
259 $GLOBALS[
'SQ_SYSTEM']->am->releaseLock($assetid,
'metadata');
262 'SetAssetMetadataResult' => $result,
265 throw new SoapFault(
'Server',
'Unable To Regenerate Metadata For Asset');
268 throw new SoapFault(
'Server',
'Please provide both AssetID and FieldID of the metadata field.');
290 $request_info = (Array) $request;
291 $assetid = array_get_index($request_info,
'AssetID',
'');
292 $metadata_info = array_get_index($request_info,
'MetadataInfo', Array());
294 if (!empty($assetid) && !empty($metadata_info)) {
295 $metadata_values = Array();
296 $mm = $GLOBALS[
'SQ_SYSTEM']->getMetadataManager();
297 foreach ($metadata_info as $metadata) {
298 $metadata = (Array) $metadata;
300 $field = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($metadata[
'FieldID']);
303 throw new SoapFault(
'Server',
'Field ID provided, '.$metadata[
'FieldID'].
', does not belong to a metadata field');
307 $field_name = $field->attr(
'name');
312 $metadata_values[$field->id] = Array (
314 'name' => $field_name,
315 'value' => $new_value,
320 $GLOBALS[
'SQ_SYSTEM']->am->acquireLock($assetid,
'metadata');
321 $result = $mm->setMetadata($assetid, $metadata_values);
322 $GLOBALS[
'SQ_SYSTEM']->am->releaseLock($assetid,
'metadata');
326 'SetMultipleMetadataFieldsResult' => $result,
329 throw new SoapFault(
'Server',
'Unable To Set Metadata For Asset');
332 throw new SoapFault(
'Server',
'Please provide both AssetID and Metadata Field id/value info.');
354 $request_info = (Array) $request;
355 $fieldid = array_get_index($request_info,
'FieldID',
'');
356 $new_def_value = array_get_index($request_info,
'NewDefaultValue',
'');
358 if (!empty($new_def_value) && !empty($fieldid)) {
359 $field = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($fieldid);
361 throw new SoapFault(
'Server',
'The provided Field ID does not belong to a Metadata Field');
363 $mm = $GLOBALS[
'SQ_SYSTEM']->getMetadataManager();
365 $GLOBALS[
'SQ_SYSTEM']->am->acquireLock($fieldid,
'attributes');
367 $field->setAttrValue(
'default', $new_def_value);
368 $result = $field->saveAttributes();
370 $GLOBALS[
'SQ_SYSTEM']->am->releaseLock($fieldid,
'attributes');
373 'SetMetadataFieldDefaultValueResult' => TRUE,
376 throw new SoapFault(
'Server',
'Unable To Set New Default Value For Metadata Field');
379 throw new SoapFault(
'Server',
'Please Provide Both FieldID And New Default Value For The Field');
401 $request_info = (Array) $request;
402 $assetid = array_get_index($request_info,
'AssetID',
'');
403 $fieldid = array_get_index($request_info,
'FieldID',
'');
405 if (!empty($assetid) && !empty($fieldid)) {
406 $mm = $GLOBALS[
'SQ_SYSTEM']->getMetadataManager();
407 $values = $mm->getMetadataValueByAssetid($assetid, $fieldid);
408 if (!empty($values)) {
412 'GetMetadataValueByIDsResult' => $mm->escapeMetadata($values),
415 throw new SoapFault(
'Server',
'Unable To Get Metadata Values For Asset');
418 throw new SoapFault(
'Server',
'Please provide both AssetID and FieldID of the metadata field.');
439 $request_info = (Array) $request;
440 $assetid = array_get_index($request_info,
'AssetID',
'');
442 if (!empty($assetid)) {
443 $mm = $GLOBALS[
'SQ_SYSTEM']->getMetadataManager();
444 $schemaids = $mm->getSchemas($assetid);
445 $formatted_result = Array();
447 foreach ($schemaids as $schemaid => $grant) {
448 $formatted_result[$i][
'SchemaID'] = $schemaid;
449 $formatted_result[$i][
'Grant'] = $grant;
453 'GetSchemasOnAssetResult' => $formatted_result,
456 throw new SoapFault(
'Server',
'Asset ID Is Not Valid. Please Provide A Valid Asset ID');
477 $request_info = (Array) $request;
478 $schemaid = array_get_index($request_info,
'SchemaID',
'');
480 if (!empty($schemaid)) {
481 $schema = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($schemaid);
483 throw new SoapFault(
'Server',
'The schema ID provided does not belong to a metadata schema');
485 $mm = $GLOBALS[
'SQ_SYSTEM']->getMetadataManager();
486 $fieldids = $mm->getMetadataFields($schemaid);
488 'GetMetadataFieldsOfSchemaResult' => array_keys($fieldids),
491 throw new SoapFault(
'Server',
'The schema ID provided is not valid. Please provide a valid ID.');
513 $request_info = (Array) $request;
514 $assetid = array_get_index($request_info,
'AssetID',
'');
515 $field_names = array_get_index($request_info,
'FieldNames',
'');
517 if (!empty($assetid)) {
518 $mm = $GLOBALS[
'SQ_SYSTEM']->getMetadataManager();
519 $schemas = $mm->getSchemas($assetid);
520 if (empty($schemas)) {
521 throw new SoapFault(
'Server',
'There is no metadata schema applied on this asset');
523 if(empty ($field_names)) {
524 $field_names = Array();
526 else if (!is_array($field_names)) {
527 $field_names = Array ($field_names);
529 $field_values = $mm->getMetadataFieldValues($assetid, $field_names);
530 $field_values_final = Array();
532 foreach ($field_values as $field_name => $field_value) {
533 $field_values_final[$i][
'FieldName'] = $field_name;
536 $field_values_final[$i][
'FieldValue'] = $mm->escapeMetadata($field_value);
541 'GetMetadataFieldValuesResult' => $field_values_final,
544 throw new SoapFault(
'Server',
'Asset ID Is Not Valid. Please Provide A Valid Asset ID');
558 $schema_info = self::getArgType(
'SchemaSetInfo', 0,
'unbounded', TRUE);
559 $field_values = self::getArgType(
'FieldInfo', 0,
'unbounded', TRUE);
560 $grant_type = self::getArgType(
'Grant', 1, 1);
561 $metadata_info = self::getArgType(
'MetadataInfo', 0,
'unbounded', TRUE);
563 $complex_types = Array (
564 'SetMetadataSchema' => Array (
565 'SetMetadataSchema' => Array (
566 'AssetID' => self::$string_non_optional,
567 'SchemaID' => self::$string_non_optional,
568 'Grant' => $grant_type,
569 'Cascade' => self::$boolean_optional,
571 'SetMetadataSchemaResponse' => Array (
572 'SetSchemaResult' => self::$boolean_optional,
575 'RegenerateMetadataSchema' => Array (
576 'RegenerateMetadataSchema' => Array (
577 'SchemaID' => self::$string_non_optional,
579 'RegenerateMetadataSchemaResponse' => Array (
580 'RegenerateMetadataSchemaResult' => self::$boolean_optional,
583 'RegenerateMetadataAsset' => Array (
584 'RegenerateMetadataAsset' => Array (
585 'AssetID' => self::$string_non_optional,
587 'RegenerateMetadataAssetResponse' => Array (
588 'RegenerateMetadataAssetResult' => self::$boolean_optional,
591 'SetAssetMetadata' => Array(
592 'SetAssetMetadata' => Array (
593 'AssetID' => self::$string_non_optional,
594 'FieldID' => self::$string_non_optional,
595 'NewValue' => self::$string_non_optional,
597 'SetAssetMetadataResponse' => Array (
598 'SetAssetMetadataResult' => self::$boolean_optional,
601 'SetMultipleMetadataFields' => Array(
602 'SetMultipleMetadataFields' => Array (
603 'AssetID' => self::$string_non_optional,
604 'MetadataInfo' => $metadata_info,
606 'SetMultipleMetadataFieldsResponse' => Array (
607 'SetMultipleMetadataFieldsResult' => self::$boolean_optional,
610 'SetMetadataFieldDefaultValue' => Array(
611 'SetMetadataFieldDefaultValue' => Array (
612 'FieldID' => self::$string_non_optional,
613 'NewDefaultValue' => self::$string_non_optional,
615 'SetMetadataFieldDefaultValueResponse' => Array (
616 'SetMetadataFieldDefaultValueResult' => self::$boolean_optional,
619 'GetMetadataValueByIDs' => Array (
620 'GetMetadataValueByIDs' => Array (
621 'AssetID' => self::$string_non_optional,
622 'FieldID' => self::$string_non_optional,
624 'GetMetadataValueByIDsResponse' => Array (
625 'GetMetadataValueByIDsResult' => self::$string_non_optional,
628 'GetSchemasOnAsset' => Array (
629 'GetSchemasOnAsset' => Array (
630 'AssetID' => self::$string_non_optional,
632 'GetSchemasOnAssetResponse' => Array (
633 'GetSchemasOnAssetResult' => $schema_info,
636 'GetMetadataFieldsOfSchema' => Array (
637 'GetMetadataFieldsOfSchema' => Array (
638 'SchemaID' => self::$string_non_optional,
640 'GetMetadataFieldsOfSchemaResponse' => Array (
641 'GetMetadataFieldsOfSchemaResult' => self::$string_optional_unbounded,
644 'GetMetadataFieldValues' => Array (
645 'GetMetadataFieldValues' => Array (
646 'AssetID' => self::$string_non_optional,
647 'FieldNames' => self::$string_optional_unbounded,
649 'GetMetadataFieldValuesResponse' => Array (
650 'GetMetadataFieldValuesResult' => $field_values,
655 $complex_types_available = parent::getComplexElements($complex_types);
657 return $complex_types_available;
671 $simple_restricted_types = Array (
672 'SetMetadataSchema' => Array (
674 'restriction_base' =>
'string',
675 'enumeration' => Array (
676 'Apply',
'Deny',
'Revoke',
682 $simple_restricted_types_available = parent::processSimpleRestrictedTypes($simple_restricted_types);
684 return $simple_restricted_types_available;
697 $complex_types = Array (
698 'GetMetadataFieldValues' => Array (
699 'FieldInfo' => Array (
700 'FieldName' => self::$string_non_optional,
701 'FieldValue' => self::$string_non_optional,
704 'GetSchemasOnAsset' => Array (
705 'SchemaSetInfo' => Array (
706 'SchemaID' => self::$string_non_optional,
707 'Grant' => self::$int_non_optional,
710 'SetMultipleMetadataFields' => Array (
711 'MetadataInfo' => Array (
712 'FieldID' => self::$string_non_optional,
713 'FieldValue' => self::$string_non_optional,
718 $complex_types_available = parent::getComplexElements($complex_types);
720 return $complex_types_available;