Hello All
Can anybody tell me why I am getting this error when I am trying to create a repository session of an existing repository?Here is the code:
import java.util.Locale;
import com.sap.mdm.commands.AuthenticateRepositorySessionCommand;
import com.sap.mdm.commands.CommandException;
import com.sap.mdm.commands.CreateRepositorySessionCommand;
import com.sap.mdm.commands.DestroySessionCommand;
import com.sap.mdm.commands.GetRepositoryRegionListCommand;
import com.sap.mdm.commands.GetRunningRepositoryListCommand;
import com.sap.mdm.data.MultilingualString;
import com.sap.mdm.data.RegionProperties;
import com.sap.mdm.data.RegionalString;
import com.sap.mdm.ids.TableId;
import com.sap.mdm.net.ConnectionException;
import com.sap.mdm.net.ConnectionPool;
import com.sap.mdm.net.ConnectionPoolFactory;
import com.sap.mdm.schema.FieldKeywordType;
import com.sap.mdm.schema.FieldProperties;
import com.sap.mdm.schema.FieldSortType;
import com.sap.mdm.schema.TableProperties;
import com.sap.mdm.schema.commands.CreateFieldCommand;
import com.sap.mdm.schema.commands.GetFieldListCommand;
import com.sap.mdm.schema.commands.GetTableListCommand;
import com.sap.mdm.schema.commands.ModifyFieldCommand;
import com.sap.mdm.schema.fields.FixedWidthTextFieldProperties;
import com.sap.mdm.server.DBMSType;
import com.sap.mdm.server.RepositoryIdentifier;
public class ModifyField {
private ModifyField() {
}
/**
Creates a multi-lingual string based on the list of regions.
@param regionPropertiesList the list of regions
@param baseString the base string
@return a multi-lingual string
*/
/**
private static MultilingualString createMultilingualString(RegionProperties[] regionPropertiesList, String baseString) {
MultilingualString mlString = new MultilingualString();
for (int i = 0; i < regionPropertiesList.length; i++) {
Locale locale = regionPropertiesList<i>.getLocale();
String regionCode = regionPropertiesList<i>.getRegionCode();
String string = baseString + "_" + locale.getLanguage() + "_" + locale.getCountry();
RegionalString regionalString = new RegionalString(string, regionCode);
mlString.set(regionalString);
}
return mlString;
}
/**
Creates a fixed-width field.
@param tableId the table from which the field will be create in
@param regionPropertiesList the list of regions
@return the new fixed-width field
*/
/**
private static FixedWidthTextFieldProperties createFixedWidthField(TableId tableId, RegionProperties[] regionPropertiesList) {
MultilingualString fieldName = createMultilingualString(regionPropertiesList, "NewField" + System.currentTimeMillis());
FixedWidthTextFieldProperties field = new FixedWidthTextFieldProperties();
field.setTableId(tableId);
field.setName(fieldName);
field.setKeywordType(FieldKeywordType.NORMAL);
field.setMultiLingual(true);
field.setModifyOnce(true);
field.setRequired(true);
field.setSortType(FieldSortType.CASE_SENSITIVE);
field.setWidth(60);
return field;
}
*/
public static void main(String[] args) {
// create connection pool to a MDM server
String tag = "172.18.139.200";
ConnectionPool connections = null;
try {
connections = ConnectionPoolFactory.getInstance(tag);
} catch (ConnectionException e) {
e.printStackTrace();
return;
}
// specify the repository to use
// alternatively, a repository identifier can be obtain from the GetMountedRepositoryListCommand
String repositoryName = "GDS_1";
String dbmsName = "Oracle";
RepositoryIdentifier reposId = new RepositoryIdentifier(repositoryName, dbmsName, DBMSType.MS_SQL);
// create a repository session
CreateRepositorySessionCommand sessionCommand = new CreateRepositorySessionCommand(connections);
sessionCommand.setRepositoryIdentifier(reposId );
try {
sessionCommand.execute();
System.out.println("8888");
} catch (CommandException e) {
e.printStackTrace();
System.out.println("7777777" + e);
return;
}
String sessionId = sessionCommand.getRepositorySession();
// authenticate the repository session
String userName = "Admin";
String userPassword = "";
AuthenticateRepositorySessionCommand authCommand = new AuthenticateRepositorySessionCommand(connections);
authCommand.setSession(sessionId);
authCommand.setUserName(userName);
authCommand.setUserPassword(userPassword);
try {
authCommand.execute();
} catch (CommandException e) {
e.printStackTrace();
return;
}
// retrieve the list of tables and pick the main table for creating a new field
GetTableListCommand tableListCommand = new GetTableListCommand(connections);
tableListCommand.setSession(sessionId);
try {
tableListCommand.execute();
} catch (CommandException e) {
e.printStackTrace();
return;
}
TableProperties mainTable = null;
TableProperties[] tables = tableListCommand.getTables();
for ( int i = 0; i < tables.length; i++) {
if (tables<i>.getType() == TableProperties.MAIN)
mainTable = tables<i>;
}
// retrieve the list of fields from the main table
// this is useful for resolving conflicting field names the new field might create
GetFieldListCommand getFieldListCommand = new GetFieldListCommand(connections);
getFieldListCommand.setSession(sessionId);
getFieldListCommand.setTableId(mainTable.getId());
try {
getFieldListCommand.execute();
} catch (CommandException e) {
e.printStackTrace();
return;
}
/**
// get the change stamp
// this is required when we make any kind of changes to the repository
int changeStamp = getFieldListCommand.getChangeStamp();
// retrieve the available regions (languages) for the repository
// we need this to set up the field name for each region
GetRepositoryRegionListCommand getReposRegionListCommand = new GetRepositoryRegionListCommand(connections);
getReposRegionListCommand.setRepositoryIdentifier(reposId);
try {
getReposRegionListCommand.execute();
} catch (CommandException e) {
e.printStackTrace();
return;
}
RegionProperties[] regionPropertiesList = getReposRegionListCommand.getRegions();
// set up the field to create
FieldProperties newField = createFixedWidthField(mainTable.getId(), regionPropertiesList);
// create the new field
CreateFieldCommand createFieldCommand = new CreateFieldCommand(connections);
createFieldCommand.setSession(sessionId);
createFieldCommand.setField(newField);
createFieldCommand.setInChangeStamp(changeStamp);
try {
createFieldCommand.execute();
} catch (CommandException e) {
e.printStackTrace();
return;
}
// a new change stamp is required.
changeStamp = createFieldCommand.getOutChangeStamp();
// setup the field for modification
FixedWidthTextFieldProperties modifiedField = (FixedWidthTextFieldProperties) newField;
modifiedField.setWidth(100);
modifiedField.setRequired(false);
// modify the field
ModifyFieldCommand modifyFieldCommand = new ModifyFieldCommand(connections);
modifyFieldCommand.setSession(sessionId);
modifyFieldCommand.setInChangeStamp(changeStamp);
modifyFieldCommand.setField(modifiedField);
try {
modifyFieldCommand.execute();
} catch (CommandException e) {
e.printStackTrace();
return;
}
*/
// finally destroy the session
DestroySessionCommand destroySessionCommand = new DestroySessionCommand(connections);
destroySessionCommand.setSession(sessionId);
try {
destroySessionCommand.execute();
} catch (CommandException e) {
e.printStackTrace();
return;
}
}
}
and this is the error
43424GDS_1
com.sap.mdm.commands.CommandException: com.sap.mdm.internal.protocol.manual.ServerException: The specified MDM repository was not found on the server.
at com.sap.mdm.commands.CreateRepositorySessionCommand.execute(CreateRepositorySessionCommand.java:79)
at com.sap.mdm.examples.ModifyField.main(ModifyField.java:150)
Caused by: com.sap.mdm.internal.protocol.manual.ServerException: The specified MDM repository was not found on the server.
at com.sap.mdm.internal.protocol.manual.AbstractProtocolCommand.execute(AbstractProtocolCommand.java:112)
at com.sap.mdm.commands.CreateRepositorySessionCommand.execute(CreateRepositorySessionCommand.java:74)
... 1 more
7777777com.sap.mdm.commands.CommandException: com.sap.mdm.internal.protocol.manual.ServerException: The specified MDM repository was not found on the server.