private static final String PERMISSION_TWO = "INSERT_SECOND_PERMISSION_ID_HERE";
public static void runExample(DfaServices dfaServices, DfaSession session, String subnetworkName,
long networkId, long permissionOneId, long permissionTwoId) throws Exception {
// Request the service.
SubnetworkRemote service = dfaServices.get(session, SubnetworkRemote.class);
// Create subnetwork structure.
Subnetwork subnetwork = new Subnetwork();
subnetwork.setId(0);
subnetwork.setName(subnetworkName);
subnetwork.setNetworkId(networkId);
// Create an array of all permissions assigned to this subnetwork and add
// it to the subnetwork structure. To get list of available permissions,
// run GetAvailablePermissions.java.
long[] permissions = new long[] {permissionOneId, permissionTwoId};
subnetwork.setAvailablePermissions(permissions);
// Create subnetwork.
SubnetworkSaveResult subnetworkSaveResult = service.saveSubnetwork(subnetwork);
// Display subnetwork ID.
System.out.printf("Subnetwork with ID \"%s\" was created.%n", subnetworkSaveResult.getId());
}