Unsolved

This post is more than 5 years old

4 Posts

6067

October 31st, 2008 06:00

Why can I not execute a query on the XSystem

In the Java API Documentation I found on side 16 how to create a query over the XSystem.

But if I try this I get an exception.

Here ist the code:

package testTool;
 
import org.snia.xam.AuthenticationExpiredException;
import org.snia.xam.AuthorizationException;
import org.snia.xam.InvalidArgumentException;
import org.snia.xam.InvalidXSetModeException;
import org.snia.xam.XAMException;
import org.snia.xam.XAMLibrary;
import org.snia.xam.XAMLibraryObj;
import org.snia.xam.XSet;
import org.snia.xam.XSetInaccessibleException;
import org.snia.xam.XSystem;
import org.snia.xam.XSystemAbandonException;
import org.snia.xam.XSystemCorruptException;
 
/**
 * TODO: pupose of this class
 * 

* Copyright © Cerner Corporation 2008 All rights reserved. *

* @author Ralf Liesen * @version $Revision$ */ public class QueryXSet { /** * @param args * @throws XAMException * @throws InvalidArgumentException * @throws AuthorizationException * @throws AuthenticationExpiredException * @throws XSystemCorruptException * @throws XSystemAbandonException * @throws XSetInaccessibleException * @throws InvalidXSetModeException */ public static void main(String[] args) throws InvalidXSetModeException, XSetInaccessibleException, XSystemAbandonException, XSystemCorruptException, AuthenticationExpiredException, AuthorizationException, InvalidArgumentException, XAMException { // Connect to the archive system String xri = "snia-xam://centera_vim!128.221.200.60?C:/Ralf/xam/xamconnect.pea"; System.out.println("Store Content to EMC Centera over XAM"); XAMLibrary xam = XAMLibraryObj.getLibrary(); xam.setProperty( XAMLibrary.XAM_LOG_LEVEL, XAMLibrary.XAM_LOG_ALL ); xam.setProperty( XAMLibrary.XAM_LOG_PATH, "C:/Ralf/xam/xam.log" ); System.out.println("Query an XSystem - Centera cluster(" + xri + ")"); XSystem sys = xam.connect(xri); XSet query; query = sys.createXSet( XSet.MODE_RESTRICTED ); query.createProperty( XSet.XAM_JOB_COMMAND, false, XSet.XAM_JOB_QUERY); query.createProperty( XSet.XAM_JOB_QUERY_COMMAND, false, "select \".xset.xuid\"" ); query.submitJob(); // Wait for the job to complete. String queryStatus = query.getString( XSet.XAM_JOB_ERROR ); if( queryStatus.equals( XSet.XAM_JOB_ERRORHEALTH_OK )) { XStream results = query.openXStream( XSet.XAM_JOB_QUERY_RESULTS, XStream.MODE_READ_ONLY ); byte rawXUID[] = new byte[80]; int bytesRead = 0; while( (bytesRead = (int) results.read(rawXUID)) >= 0 ) { XUID localXUID = new XAMXUID(rawXUID); XSet data = sys.openXSet( localXUID, XSet.MODE_READ_ONLY ); // Process results // System.out.println("Test: " + localXUID); data.close(); } results.close(); } query.close(); } }

And here is the exception:

Store Content to EMC Centera over XAM

Query an XSystem - Centera cluster(snia-xam://centera_vim!128.221.200.60?C:/Ralf/xam/xamconnect.pea)

Exception in thread "main" org.snia.xam.JobCommandException: xam/job command invalid

at org.snia.xam.XAMErrors.throwConvertedException(Unknown Source)

at org.snia.xam.XAMErrors.throwConvertedException(Unknown Source)

at org.snia.xam.XSetImpl.submitJob(Unknown Source)

at testTool.QueryXSet.main(QueryXSet.java:60)

Why did I get this exception? What's my mistake?

Thanks Ralf

47 Posts

October 31st, 2008 14:00

Hello Ralf -

Try setting your JOB_COMMAND and QUERY_COMMAND properties as binding (as opposed to non-binding) properties of your query XSet.

Best Regards,

Mike Horgan

4 Posts

November 3rd, 2008 00:00

Hi Mike

I changed the properties to "binding.

But that didn't worked. I got the same exception.

I also changed the "createXSet Mode" to "unrestricted" but that didn't worked too.

Do I have another option?

I printed a list of all fields of this XSystem.

The concerning fields should be:

Field 33: '.xsystem.job.list.xam.job.query'

Mime-Type: application/vnd.snia.xam.boolean

Binding: false

ReadOnly: true

Length: 1

Value:

Field 36: '.xsystem.job.commit.supported'

Mime-Type: application/vnd.snia.xam.boolean

Binding: false

ReadOnly: true

Length: 1

Value:

Field 37: '.xsystem.job.xam.job.query.continuance.supported'

Mime-Type: application/vnd.snia.xam.boolean

Binding: false

ReadOnly: true

Length: 1

Value:

Field 38: '.xsystem.job.xam.job.query.level2.supported'

Mime-Type: application/vnd.snia.xam.boolean

Binding: false

ReadOnly: true

Length: 1

Value:

Field 39: '.xsystem.job.xam.job.query.level1.supported'

Mime-Type: application/vnd.snia.xam.boolean

Binding: false

ReadOnly: true

Length: 1

Value:

Are the settings for these properties OK?

Thanks Ralf

47 Posts

November 4th, 2008 13:00

Hello Ralf -

Sorry for the delayed response, you may have already figured this one out for yourself. But anyway: It took me a while to notice this in your code but the error is quite clear. Because a XAM query expression can reasonably be expected to exceed 512 characters in length, the .xam.job.query.command field is not defined as a string property but as an XStream with MIME type "text/plain;charset=utf-8" (see section 10.7.1 in the 1.0 Architecture specification). If you write your query string out to a stream in a way similar to the 'writeQueryCommand' function in the attached source file I believe it will succeed.

Best Regards,

Mike Horgan

1 Attachment

No Events found!

Top