cancel
Showing results for 
Search instead for 
Did you mean: 

Reading property from a resource via api, tricky one

Former Member
0 Kudos

I customer of our company has defined a metadata property

with the following settings:

Property ID: * prop_created

Namespace Alias: *company_namespace

Type: *Timestamp

Key for Label:cm_created

Folder Validity Patterns (csv)/

Document Validity Patterns (csv)/

Property Renderer creationdate

In a project i need to change the value of about 1000 documents over api.

This should normaly be not a problem, but even when the property exists on an document and see the it in the flexible user interface,

it's not possible to read it over the api.

I also tried to iterate over all properties, but this one don't come up.

Any ideas?

Btw, i allready tried it over the IApplicationPropertiesService..Same results here...Property can not be looked up..

Regards,

Thomas

Accepted Solutions (1)

Accepted Solutions (1)

former_member188556
Active Contributor
0 Kudos

Hi Thomas,

If u want to change the property of 1000 documents, try this [Help|http://help.sap.com/saphelp_nw04s/helpdata/en/44/8d6f90d85c6572e10000000a11466f/frameset.htm]

Regards

BP

Answers (3)

Answers (3)

Former Member
0 Kudos

i can't see the whole property. but i can see this property exists on the resource with value in the km admin

Former Member
0 Kudos

Hi,

I can't see a reason why this could happen. Try to access for the resource with the property value set (so you can see the value through detail iview) directly:


...
IPropertyName pName = PropertyName.getPN("property_namespace_you_can_see_when_hovering_in_detail_iview", "property_name_from_detail_iview");
response.write("<br>pName:"+pName);
prop = res.getProperty(propName);
response.write("<br>prop:"+prop);
...

what is the output?

Romano

Former Member
0 Kudos

Here is the code of the property viewer i created to see all the existing properties

public class PropertyViewerForResource {

	public static void outputProperties(
		IResource item,
		IPortalComponentResponse response) {

		IPropertyMap map;

		try {
			
		
			map = item.getProperties();

			response.write(
				"<font color=\"red\">------------------------Property Viewer MetadatyProperties----------------------<br>");
			response.write(
				"Displaying properties for the following resource:<br>");
			response.write(item.getName() + "<br>");

			if (map != null) {

				IPropertyIterator itr = map.iterator();

				while (itr.hasNext()) {

					String multi = "No";

					IProperty prop = itr.next();
					if (prop.isMultivalued()) {

						multi = "Yes";
					}

					response.write(
						"Property Name:"
							+ prop.getPropertyName().getName()
							+ "<br>");
					response.write(
						"Property Namespace:"
							+ prop.getPropertyName().getNamespace()
							+ "<br>");
					response.write("Property is multivalue: " + multi + "<br>");
					response.write(
						"Property Value: " + prop.getValueAsString() + "<br>");

				}
			}

			response.write(
				"----------------------------End of Output-------------<br></font>");
		} catch (NotSupportedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (AccessDeniedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (ResourceException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		try {
			IApplicationPropertiesService apService =
				GetApplicationPropertyServiceInstance
					.getApplicstionPropertyService();

			response.write(
				"<font color=\"blue\">----------------------------Property Viewer Application Properties----------------<br>");

			IAppPropertyMap mapapp = apService.getProperties(item);

			IAppPropertyIterator itrapp = mapapp.iterator();

			while (itrapp.hasNext()) {
				String multi = "No";
				IAppProperty propapp = itrapp.next();
				if (propapp.isMultivalued()) {

					multi = "Yes";
				}
				response.write(
					"Property Name: " + propapp.getPropertyName() + "<br>");
				response.write("Property is multivalue: " + multi + "<br>");
			}
		} catch (ResourceException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		} catch (WcmException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

}

Former Member
0 Kudos

Hi,

what you cannot see? The value of the property or all the propertyname/propertyNamespace/value?

btw: you cannot read the property unless it is set to some value...but I suppose you can see it through resource detail iview

Romano

Former Member
0 Kudos

Okay, but that will not help in this case.

Cause the change is based on logic in an program.

My question was related to the fact, why i don't see this property over the api.

Former Member
0 Kudos

Can you see it over WebDAV?

former_member188556
Active Contributor
0 Kudos

Thomas,

Paste the code that u use to read/set the property

Regards

BP