We have Vignette 7
Hi I can connect to the VCMS with the code below but
I got an error trying to access a project by path no matter
What I give as a Path.
Here is the console log:
Logging in to VCMS...
Logged in.
26-Sep-2012 1:48:55 PM com.ibm.ws.naming.java.javaURLContextFactory
SEVERE: javaAccessorNotSet
I’m using the vignette jdk for weblogic and all required
Libraries, I use it through a standalone java project
In RAD. It compiles and run ok…
Regards
---------------------------------------------
package com.bnc.batch;
import com.vignette.as.client.common.AttributeData;
import com.vignette.as.client.common.RequestParameters;
import com.vignette.as.client.exception.ApplicationException;
import com.vignette.as.client.exception.AuthorizationException;
import com.vignette.as.client.exception.ValidationException;
import com.vignette.as.client.javabean.IPagingList;
import com.vignette.as.client.javabean.ManagedObject;
import com.vignette.as.client.javabean.Project;
import com.vignette.authn.AuthnBundle;
import com.vignette.authn.AuthnException;
import com.vignette.authn.LoginMgr;
import java.util.Iterator;
import java.util.List;
public class GetTest {
private static final String USERNAME = "";
private static final String PASSWORD = "";
private static final String HOST = "";
private static final String PORT = "";
private static final String PROJECT_PATH = "";
private static boolean loggedOn = false;
/**
* Log the user in to the VCM
* @param username
* @param password
* @param host
* @param port
* @throws AuthnException
*/
public static void login(String username, String password, String host, String port) throws AuthnException{
if(!loggedOn){
System.out.println("Logging in to VCMS...");
// Set the bundle details for login
AuthnBundle authBundle = new AuthnBundle();
authBundle.setUsername(username);
authBundle.setPassword(password);
authBundle.setHost(host);
authBundle.setPort(port);
LoginMgr login = new LoginMgr();
// Perform the login
login.login(authBundle);
System.out.println("Logged in.");
}
loggedOn = true;
}
public static void main(String[] args) throws ApplicationException, ValidationException, AuthorizationException, AuthnException{
login(USERNAME, PASSWORD, HOST, PORT);
Project project = Project.findProjectByPath(PROJECT_PATH);
IPagingList projectContents =
project.getManagedObjects(RequestParameters.requestParametersFullRelation);
List items = projectContents.asList();
Iterator it = items.iterator();
while(it.hasNext()){
ManagedObject testMo = (ManagedObject)it.next();
System.out.println("Mgmt id: "+testMo.getContentManagementId());
System.out.println("Getting attributes directly:");
AttributeData[] data = testMo.getAttributes();
System.out.println("found "+data.length+" attributes");
for(int i = 0;i<data.length;i++){
AttributeData attributeData = data[i];
System.out.println("Attr name: '"+attributeData.getName()+"' Attr value: '"+attributeData.getValue()+"'");
}
ManagedObject newMo = ManagedObject.findByContentManagementId(testMo.getContentManagementId());
System.out.println("Getting attributes after finding by CM ID:");
data = newMo.getAttributes();
System.out.println("found "+data.length+" attributes");
for(int i = 0;i<data.length;i++){
AttributeData attributeData = data[i];
System.out.println("Attr name: '"+attributeData.getName()+"' Attr value: '"+attributeData.getValue()+"'");
}
}
}
}