Wednesday 14 November 2012

Common BCC Issues and Solution


Missing Snapshot Id

Some time during the project deployment its found that the snapshot is missing so in that case go to publishing database and follow the below mentioned steps

Step 1) Execute the below mentioned query 

select max(snapshot_id) from EPUB_PRJ_TG_SNSHT where target_id='tar2842'

Note: tar2842 is a sample target id , for your application it will be different so change it accordingly and execute the same 
lets assume that the output of the same is 246902.

but if you are still struggling to find what is the tatget id then go to publishing schema and look for EPUB_WORKFLOW_INFO table , and from there you can easily find the target id.

Step 2) go to dyn/admin of the bcc instance and goto /dyn/admin/nucleus/atg/epub/DeploymentServer/ and force the resulted snapshot id (246902)

step 3) Deploy the project, in this way you can fix and continue with the deployment.


Conflicting project and solution

Problem 1) at the time of deployment some time we face a issue i.e. the project cannot be deployed because of the conflicts with some other project which is actually not deployed, and when you are trying to edit the conflicting project its not available for editing , it generally happens with the cases where we keep on migrating the database without taking the proper care of the existing projects.

In this case run the following two scripts using the dyn admin console (/dyn/admin/nucleus/atg/epub/PublishingRepository/) and try to re create and deploy your project

scripts are : 


 <remove-item id="prj528002" item-descriptor="project" remove-references-to="true"/>
 <remove-item id="prc528002" item-descriptor="project" remove-references-to="true"/>


Note : prj528002 is a conflicting project and corresponding to every project a process is created with prc and the id remains the same.




May more things will come , keep watching,

Tuesday 6 November 2012

ATG Rest Web Service -How To

This Document is to help any ATG developer in writing custom Rest Services.

1) Create a custom Service

For Example :

package common.utils;
import atg.nucleus.GenericService;

public class OrderService  extends GenericService {

public void addOrder(String bookRef) throws Exception {
System.out.println("Hello , its my first webservice..");
}

}

2) Map it to the property file 

$class=common.utils.OrderService
$scope=global
loggingInfo=true


3) Configure the security for the above component in restSecurityConfiguration.xml


<rest-security>
  <resource component="/common/utils/OrderService" secure="false">
<default-acl value="Profile$role$admin:read,write,execute;Profile$role$admin:read,write,execute"/>
  </resource>
</rest-security>


for the user and role please go through ATG docs , but the above will work for all diff env.

4) deploy the application in jboss server { make sure that the module you are deploying on the appserver includes REST module of the ATG}

5) once the server is up validate your service availability by checking http://localhost/rest/common/utils/OrderService

6) write the client using atg-rest-client

Example


package test;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import atg.rest.client.RestClientException;
import atg.rest.client.RestComponentHelper;
import atg.rest.client.RestResult;
import atg.rest.client.RestSession;
/**
 * Method Call implementation through REST API
 *
 * @author ashish
 *
 */
public class RESTClient {

/** The m username. */
private String mUsername;

/** The m password. */
private String mPassword;

/** The m host. */
private String mHost;

/** The m port. */
private int mPort;

/** The m session. */
private RestSession mSession = null;

/**
* Instantiates a new method call by rest.
*/
public RESTClient() {
}
/**
* Execute.
*
* @throws RestClientException the rest client exception
*/
private void execute() {


mSession = RestSession
.createSession(mHost, mPort, mUsername, mPassword);
mSession.setUseHttpsForLogin(false);

Map<String,Object> params = new HashMap<String,Object>();

params.put("atg-rest-input", "json");
RestResult result = null;
try {
result = RestComponentHelper.executeMethod("/thomascook/starfish/common/utils/OrderService", "addOrder", new
Object[] {}, params, mSession);

} catch (RestClientException e1) {
System.out.println(e1);
}

try {
if (result != null && result.getResponseCode() == 200) {
System.out.println("Executed Successfully.");
} else {
System.out
.println("Error while execution : Error Code ["
+ result.getResponseCode()
+ "] and Message ["
+ result.getResponseMessage() + "]");
}
} catch (IOException e) {
System.out.println("Error while execution Successfully.");
}
}

/**
* @param args
*/
public static void main(String[] args) {
RESTClient stepUtils = new RESTClient();
stepUtils.mUsername = "admin";
stepUtils.mPassword = "admin";
stepUtils.mHost = "localhost";
stepUtils.mPort = 8080;
stepUtils.execute();


}

}


Step 7) execute the above client and it will work.

if you follow the steps properly it will definitely work.

Any question please let me know.





Monday 1 October 2012

Some of the best articles and the links that i have found related to ATG are:

http://www.atglaunchchecklist.com/index.php?title=Main_Page

(It contains the best practices that we must follow before going into the production)

  • Site perfromance can be improved by using selective cache invalidation, thumb rule is "it can be applied to item descriptor with cache mode as simple"
        for more details please refer the ATG guide ATG Content Administration Programming Guide