public class OrgManagement {
static OrganizationManager orgManager=null;
static OIMClient client=null;
static Organization organization=null;
public static void createOrg(String orgName, String orgType)
{
try
{
client=ClientOIM.initialise();
if (orgName!=null && orgType!=null)
{
orgManager=client.getService(OrganizationManager.class);
System.out.println("OrgManagement :: createOrg :: org is "+orgManager);
HashMap<String, Object> mapAttrs = new HashMap<String, Object>();
mapAttrs.put(OrganizationManagerConstants.AttributeName.ORG_NAME.getId(),orgName);
mapAttrs.put(OrganizationManagerConstants.AttributeName.ORG_TYPE.getId(),orgType);
Organization org=new Organization(null,mapAttrs);
orgManager.create(org);
System.out.println("OrgManagement :: createOrg :: Organization created");
}
}
catch (OrganizationManagerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (AccessDeniedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (Exception e)
{
System.out.println("OrgManagement :: createOrg :: Exception caught is "+e.getMessage());
e.printStackTrace();
}
}
public String getOrgKey(String orgName)
{
String key=null;
try
{
client=ClientOIM.initialise();
if (orgName!=null && !orgName.equals("")){
orgManager=client.getService(OrganizationManager.class);
final Set<String> returnMap = new HashSet<String>();
System.out.println("Org Constant "+OrganizationManagerConstants.AttributeName.ORG_NAME.getId());
System.out.println("Org Name is "+orgName);
Organization org=orgManager.getDetails(orgName , null , true);
key=org.getEntityId();
System.out.println("key is "+key);
}}
}
catch (OrganizationManagerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (AccessDeniedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (Exception e)
{
System.out.println("OrgManagement :: getOrgKey :: Exception caught is "+e.getMessage());
e.printStackTrace();
}
return key;
}
}
static OrganizationManager orgManager=null;
static OIMClient client=null;
static Organization organization=null;
public static void createOrg(String orgName, String orgType)
{
try
{
client=ClientOIM.initialise();
if (orgName!=null && orgType!=null)
{
orgManager=client.getService(OrganizationManager.class);
System.out.println("OrgManagement :: createOrg :: org is "+orgManager);
HashMap<String, Object> mapAttrs = new HashMap<String, Object>();
mapAttrs.put(OrganizationManagerConstants.AttributeName.ORG_NAME.getId(),orgName);
mapAttrs.put(OrganizationManagerConstants.AttributeName.ORG_TYPE.getId(),orgType);
Organization org=new Organization(null,mapAttrs);
orgManager.create(org);
System.out.println("OrgManagement :: createOrg :: Organization created");
}
}
catch (OrganizationManagerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (AccessDeniedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (Exception e)
{
System.out.println("OrgManagement :: createOrg :: Exception caught is "+e.getMessage());
e.printStackTrace();
}
}
public String getOrgKey(String orgName)
{
String key=null;
try
{
client=ClientOIM.initialise();
if (orgName!=null && !orgName.equals("")){
orgManager=client.getService(OrganizationManager.class);
final Set<String> returnMap = new HashSet<String>();
System.out.println("Org Constant "+OrganizationManagerConstants.AttributeName.ORG_NAME.getId());
System.out.println("Org Name is "+orgName);
Organization org=orgManager.getDetails(orgName , null , true);
key=org.getEntityId();
System.out.println("key is "+key);
}}
}
catch (OrganizationManagerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (AccessDeniedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (Exception e)
{
System.out.println("OrgManagement :: getOrgKey :: Exception caught is "+e.getMessage());
e.printStackTrace();
}
return key;
}
}
Comments
Post a Comment