I'm planning to redirect all my traffic to a new domain, but I don't want to lose my google rankings. Should I do a 301 or 302 redirect?
To preserve your rankings, you need to do a 301 redirect. 301 means "Moved Permanently", and will transfer all of the PageRank and other value to the destination URL. 301 means "Moved Temporarily", and the search engines do not handle them predictably. It will take time (usually several weeks) for all of the link value to be transferred to your new domain name. It's also a good idea to use the domain moving tool in the Google Webmaster Tools console to help speed things along.
301 redirects are the way forward. If the site is going to be on a new domain and contain similar content (e.g. the same products or services) then you need to redirect the old pages to the new ones. E.g. Old category page for office desks redirected to new category page for office desks. Remember that Google positions relate to content - so ensure that on the new homepage (or other pages) on the new site content appropriate content with respect to your current google positions.... if that makes any sense....